私はこのエラーを取得しておいてください。このCocoaコードでisEqualToStringエラーが発生するのはなぜですか?
alt text http://img514.imageshack.us/img514/2203/help.tif
それは何ですか?私は "isEqualToString"を呼んでいません。ここで
は私の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
であり、ここで
@interface Joke : NSObject {
NSString *joke;
int rating;
}
+ (id)jokeWithValue:(NSString *)joke;
@property (readwrite, copy) NSString *joke;
@property (readwrite) int rating;
@end
joke.hであり、ここで冗談を
#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
おかげ
一部のオブジェクトは文字列のように比較されています。あなたはより多くの情報を与え、いくつかのコードを表示する必要があります。これが起こっている場所のコードを表示してください。 –
Kk私のコードをそこに追加しました。申し訳ありませんが前に追加する –
どこに定義されているだけでなく、ジョークが使用されているコードを投稿できますか? – chaos