Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 当NSArray项显示为NSObject而不是实际类时,这意味着什么?_Iphone_Objective C_Tableview - Fatal编程技术网

Iphone 当NSArray项显示为NSObject而不是实际类时,这意味着什么?

Iphone 当NSArray项显示为NSObject而不是实际类时,这意味着什么?,iphone,objective-c,tableview,Iphone,Objective C,Tableview,我有一个QuoteMap对象的NSMutableArray。当我使用下面的代码添加一个并导航到另一个使用相同数据的视图时,在尝试访问该数组时,它会以EXC_BAD_访问方式崩溃 您可以在下面看到,数组中的最后一个对象是“NSObject”,而不是“QuoteMap” 下面是我添加quoteMap的地方: - (void)insertQuoteMap:(QuoteMap*)qm { // THEN TAKE THE QUOTE_MAP_ID, SUBJECT_ID AND QUOTE_ID

我有一个QuoteMap对象的NSMutableArray。当我使用下面的代码添加一个并导航到另一个使用相同数据的视图时,在尝试访问该数组时,它会以EXC_BAD_访问方式崩溃

您可以在下面看到,数组中的最后一个对象是“NSObject”,而不是“QuoteMap”

下面是我添加quoteMap的地方:

- (void)insertQuoteMap:(QuoteMap*)qm  {

// THEN TAKE THE QUOTE_MAP_ID, SUBJECT_ID AND QUOTE_ID AND INSERT INTO QUOTE_MAP TABLE

NSInteger quoteMapId = [qm.quote_map_id intValue];
NSInteger subIdInt = [qm.subject_id intValue];
NSInteger quoteIdInt = [qm.quote_id intValue];

QuotesAppDelegate *appDelegate = (QuotesAppDelegate *)[[UIApplication sharedApplication] delegate];
FMDatabase *database = [FMDatabase databaseWithPath:appDelegate.getDBPath];    

if ([database open]) {
    [database executeUpdate:@"insert into QUOTE_MAP(quote_map_id, quote_id, subject_id) values(?, ?, ?)", 
     [NSNumber numberWithInt:quoteMapId], [NSNumber numberWithInt:quoteIdInt], [NSNumber numberWithInt:subIdInt]];

    [database close];
}

NSLog(@"QuoteMap inserted the quote_map_id of: %@", qm.quote_map_id);

//Add the object
[appDelegate addQuoteMap:qm];

[qm autorelease];
};
这就是所谓的上述方法:

QuotesAppDelegate *appDelegate = (QuotesAppDelegate *)[[UIApplication sharedApplication] delegate];
QuoteMap *qm = [[QuoteMap alloc] init];

NSInteger newQuoteMapId = [appDelegate getNextQuoteMapId];
NSLog(@"quote_map_id= %d   subId = %@   quoteId = %@", newQuoteMapId, stringOfSubjectId, selectedQuote.quote_id);

// INSERT INTO QUOTE_MAP TABLE
NSString *stringOfId = [NSString stringWithFormat:@"%d", newQuoteMapId];

qm.quote_map_id = stringOfId;
qm.subject_id   = stringOfSubjectId;
qm.quote_id     = selectedQuote.quote_id;
//qm.isDirty      = YES;

[qm insertQuoteMap:qm];

//Add it to the array.
[qmv.quoteMaps addObject:qm];
[qmv.tableView reloadData];

if (tableAlert.type == SBTableAlertTypeMultipleSelct) {
    UITableViewCell *cell = [tableAlert.tableView cellForRowAtIndexPath:indexPath];
    if (cell.accessoryType == UITableViewCellAccessoryNone)
        [cell setAccessoryType:UITableViewCellAccessoryCheckmark];
    else
        [cell setAccessoryType:UITableViewCellAccessoryNone];

    [tableAlert.tableView deselectRowAtIndexPath:indexPath animated:YES];
}

//release
[qm autorelease];
您的
-(void)insertQuoteMap:(QuoteMap*)qm
不拥有传递给它的QuoteMap,因此它不应该在最后自动释放它

当类在运行时发生这样的更改时,这通常是过度扩展的结果,原始对象不再存在,并且它在内存中占用的区域已被另一个对象填充。

您的
-(void)insertQuoteMap:(QuoteMap*)qm
不拥有传递给它的QuoteMap,所以它不应该在最后自动释放它


当类在运行时发生这样的更改时,这通常是过度扩展的结果,原始对象不再存在,并且它在内存中占用的区域已被另一个对象填充。

只是一个旁注,
-(void)insertQuoteMap:QuoteMap*)qm
不拥有传递给它的QuoteMap,所以它不应该在最后自动释放它。这就解决了它。非常感谢你!你能用这个回答这个问题吗,这样我就可以接受了?只是一个旁注,
-(void)insertQuoteMap:(QuoteMap*)qm
不拥有传递给它的QuoteMap,所以它不应该在最后自动释放它。这就解决了它。非常感谢你!你能回答这个问题吗?这样我就可以接受了?