所以我有一个类,此时只包含一个简单的 NSMutableArray 对象。我正在从视图控制器设置这个对象,但由于某种原因......愚蠢的东西在我的 ipad 上不起作用。然而,它在模拟器上完美运行。
有没有人遇到过这种情况?
我知道这不是很多事情要做,但任何关于在哪里看的提示/指针都会有所帮助。不知道在这个上搜索什么。
谢谢
视图控制器.h
#import "DBEntries.h"
DBEntries *dbEntries;
视图控制器.m:
[database open];
NSMutableArray *arrayAdder = [[NSMutableArray alloc] init];
NSString *filterNameFirst = [NSString stringWithFormat:@"%@", nameFirstTextField.text];
NSString *filterNameLast = [NSString stringWithFormat:@"%@", nameLastTextField.text];
NSString *filterStringFirst = [NSString stringWithFormat:@"%%%@%%", filterNameFirst]; // Works on first name only.
NSString *filterStringLast = [NSString stringWithFormat:@"%%%@%%", filterNameLast]; // Works on last name only.
FMResultSet *results = [database executeQuery:[NSString stringWithFormat:@"SELECT * FROM users WHERE firstname LIKE ? AND lastname LIKE ?", filterStringFirst, filterStringLast]];
while([results next])
{
NSString *firstname = [results stringForColumn:@"firstname"];
NSString *lastname = [results stringForColumn:@"lastname"];
// Add db entries to array in DBEntries.
NSString *objectAdder = [NSString stringWithFormat:@"%@ %@", firstname, lastname];
NSLog(@"objectAdder: %@", objectAdder);
[arrayAdder addObject:objectAdder];
}
[dbEntries setUsersFiltered:arrayAdder];
[arrayAdder release];
[database close];
isUpdatingEntriesForTableView = YES;
[dbTableView reloadData];
NSLog(@"dbEntries.usersFiltered: %@", dbEntries.usersFiltered); // This logs 0 on device, but works on simulator.
类.h:
NSMutableArray *usersFiltered;
@property (strong, nonatomic) NSMutableArray *usersFiltered;
类.m:
@synthesize usersFiltered;