所以我在我的 appDelegate.h 中声明了这一点
@property(nonatomic,strong) NSMutableArray *featured;
我在我的 appDelegate.m 中像这样合成了它
@synthesize featured;
当我使用存储在其中的对象在 appDelegate 中将其注销时,我得到了它应该具有的值
在 viewController.h 文件中,我声明了这一点
@property(nonatomic,strong) NSMutableArray *featured;
在 viewController.m 文件中,我像这样合成了它
@synthesize featured;
然后我打印出这一行并得到一个空值
NSLog(@"HERE %@", featured);
同一行在我的 appDelegate.m 文件中打印出正确的值。我完全迷路了。我已经按照我在之前的课堂练习中所做的方式进行了设置。提前致谢!
编辑:
我在 appDelegate.m 文件中创建了数组,就像在我称为 loadFeatured 的方法中一样
featured = [NSMutableArray array];
for (id dict in tempArray)
{
//NSLog(@"dict=%@",dict);
NSString *shopName = [dict objectForKey:@"shopName"];
NSString *drinkName = [dict objectForKey:@"drinkName"];
NSNumber *likes = [dict objectForKey:@"likes"];
NSNumber *dislikes = [dict objectForKey:@"dislikes"];
NSString *review = [dict objectForKey:@"review"];
Featured *feat = [[Featured alloc] initWithName:shopName drinkName:drinkName likes:likes dislikes:dislikes review:review];
NSLog(@"feat=%@\n\n",feat);
[featured addObject:feat];
}
NSLog(@"there is %d featured",[featured count]);
NSLog(@"HERE %@", featured);