0
任何人都可以告诉我为什么记录[self.giftees count]一直返回0,即使我将对象添加到它?NSMutableArray addObject不影响计数?
头:
#import <UIKit/UIKit.h>
@interface Test2AppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
NSMutableArray *giftees;
}
@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) NSMutableArray *giftees;
@end
从didFinishLaunchingWithOptions称为:
- (void)bootstrapGiftees
{
NSArray *gifteeNames = [NSArray arrayWithObjects:@"Jesse",,nil];
for (NSString *gifteeName in gifteeNames)
{
GifteeModel *g = [[GifteeModel alloc] init];
g.name = gifteeName;
[self.giftees addObject:g];
NSLog(@"giftees count = %d", [self.giftees count]);
[g release];
}
}
非常感谢Eiko – 2010-09-13 06:26:51