アプリケーションにシングルトンがあり、別のクラスからの引数を使用してその関数を呼び出す必要がありますが、呼び出すと nil 引数が渡されます...コードは次のとおりです。
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog([Singleton sharedMySingleton].test);
NSDictionary *story = [self.filters objectAtIndex: indexPath.row];
MainAppRecord *record = [[[MainAppRecord alloc]init]retain];
record.name = [story objectForKey:@"Name"];
record.searchUrl = [story objectForKey:@"SearchUrl"];
record.icon = [imageCash objectForKey:indexPath];
[[Singleton sharedMySingleton] changeMainFilterTo:record atPosition:indexOfFilterToChange];
}
Singleton.h とその関数は次のとおりです。
@interface Singleton : NSObject {
NSMutableArray *mainFilters;
NSString *test;
}
@property (nonatomic, retain) NSMutableArray *mainFilters;
@property (nonatomic, retain) MainAppRecord *filterToChange;
-(void) initWithPlist;
-(void) saveToPlist;
-(void)changeMainFilterTo:(MainAppRecord*)record atPosition:(int)position;
+(Singleton *)sharedMySingleton;
@end
-(void)changeMainFilterTo:(MainAppRecord*)record atPosition:(int)position
{
[mainFilters insertObject:record atIndex:position];
}
アプリがクラッシュします
2012-10-20 16:24:52.789 TableView[1957:207] -[__NSArrayI insertObject:atIndex:]: 認識されないセレクターがインスタンス 0x68410f0 に送信されました
ありがとう