私は5つのプロパティで定義されたクラスを持っています。これらのプロパティをNSMutableArray(listOfSites)に配置したいと思います。これは私のコードです:NSMutableArrayにクラスが追加されていません。なぜですか?
FMResultSet *rs = [fmdb executeQuery: @"SELECT SITE_ID, SITE_DESC, DATE FROM SiteData WHERE SITE_ID <> '0'"];
while([rs next]) {
sArray *sa = [[sArray alloc] init];
sa.sSiteID = [rs stringForColumnIndex:0];
sa.sJobDesc = [rs stringForColumnIndex:1];
sa.sJobDate = [rs stringForColumnIndex:2];
[listOfSites addObject:sa]; // add class object to array
}
[fmdb close];
sArray(いない配列が、クラスの名前)正しい内容を持っていますが、「のaddObject:SA」のメッセージがクラスにクラスを配置しません。
私は間違っていますか?
UPDATE: "listOfSites" の宣言: "listOfSites" の
@interface slSQLite : NSObject {
sqlite3 *dataBase; // declare pointer to database
UILabel *status;
BOOL newFlag;
int siteCount;
int seqNbr;
NSDate *date;
NSString *dbCmd;
NSMutableArray *listOfSites; // populated by sqlite
}
初期化:
@implementation slAppDelegate { }
@synthesize window = _window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
slSQLite *sqlite = [[slSQLite alloc] init]; // allocate class
[sqlite checkForDatabase]; // check for database
NSMutableArray *listOfSites = [[NSMutableArray alloc] init];
return YES;
}
'listOfSites'が宣言され、初期化されたコードを表示します。 –
合意しました。あなたの質問にlistOfSitesが宣言されていますか? sArray saも漏れています。 saをlistOfSitesに追加した後に、saを解放する必要があります。 –
ダーレン:私はARCを使用しています... – SpokaneDude