Ich erhalte diese Fehlermeldung:Warum erhalte ich einen isEqualToString-Fehler in diesem Cocoa-Code?
alt text http://img514.imageshack.us/img514/2203/help.tif
Was ist das? Ich habe nie "isEqualToString" aufgerufen.
ist hier mein Joke.M
@implementation Joke
@synthesize joke;
@synthesize rating;
- (id)init {
[super init];
return self;
}
- (void)dealloc {
[joke release];
[super dealloc];
}
+ (id)jokeWithValue:(NSString *)joke {
Joke *j = [[Joke alloc] init];
j.joke = joke;
return [j autorelease];
}
@end
Und hier ist joke.h
@interface Joke : NSObject {
NSString *joke;
int rating;
}
+ (id)jokeWithValue:(NSString *)joke;
@property (readwrite, copy) NSString *joke;
@property (readwrite) int rating;
@end
Und hier ist, wo ist Witz
#import "TableViewController.h"
#import "Joke.h"
@implementation TableViewController
@synthesize jokes;
- (id)initWithCoder:(NSCoder *)coder {
if (self = [super initWithCoder:coder]) {
self.jokes = [NSMutableArray arrayWithObjects:
[Joke jokeWithValue:@"If you have five dollars and Chuck Norris has five dollars, Chuck Norris has more money than you"],
[Joke jokeWithValue:@"There is no 'ctrl' button on Chuck Norris's computer. Chuck Norris is always in control."],
[Joke jokeWithValue:@"Apple pays Chuck Norris 99 cents every time he listens to a song."],
[Joke jokeWithValue:@"Chuck Norris can sneeze with his eyes open."],
nil];
}
return self;
}
- (void)viewDidLoad {
self.navigationItem.leftBarButtonItem = self.editButtonItem;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Saying how many sections wanted (Just like in address, where sorts by first name)
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return [jokes count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Team";
UITableViewCell *cell =
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithFrame:CGRectZero
reuseIdentifier:CellIdentifier] autorelease];
}
cell.text = [jokes objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)dealloc {
[jokes release];
[super dealloc];
}
@end
Dank
verwendet wird
Ein Objekt wird wie eine Zeichenfolge verglichen. Sie müssen mehr Informationen geben und Code anzeigen. Zeigen Sie den Code, wo dies geschieht. –
Kk Ich habe meinen Code dort hinzugefügt. Entschuldigung, dass ich nicht vor –
hinzugefügt habe Könnten Sie den Code, wo Joke verwendet wird, nicht nur dort, wo es definiert ist, posten? – chaos