我有一个 favDatabase 从我的数据库中读取数据:
。H
@interface favDatabase : NSObject {
UIWindow *window;
UINavigationController *navigationController;
NSString *databaseName;
NSString *databasePath;
NSMutableArray *idSPBData;
}
.m
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Setup some globals
databaseName = @"usualBike.sql";
// Get the path to the documents directory and append the databaseName
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
// Execute the "checkAndCreateDatabase" function
[self checkAndCreateDatabase];
// Query the database for all favorites
[self getFavorites];
// Configure and show the window
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
现在在我最喜欢的视图中,我尝试读取数据:
favDatabase *fav = (favDatabase *)[UIApplication sharedApplication];
return fav.idSPBData.count;
但是,它崩溃了:
2012-09-03 13:44:13.692 usualBike[1857:11603] -[UIApplication idSPBData]: unrecognized selector sent to instance 0x6e2f5a0
2012-09-03 13:44:13.693 usualBike[1857:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIApplication idSPBData]: unrecognized selector sent to instance 0x6e2f5a0'
我正在使用 Xcode 4.3,这是发布问题吗?