【发布时间】:2009-12-27 08:25:50
【问题描述】:
我花了太长时间试图找出问题所在,所以我希望她能帮助我。
我的代码:
- (IBAction)fedDog {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"dogsFedDays.plist"];
NSMutableArray *dogsFedSave = [[NSMutableArray alloc] arrayWithCapacity: 48];
for (int i = 0; i < 48; i++) {
NSDictionary *myDict = [[NSDictionary alloc] initWithObjectsAndKeys:
date[i], @"string",
fed[i], @"Yes",
nil];
[dogsFedSave addObject:myDict];
[myDict release];
}
if (![dogsFedSave writeToFile:path atomically:YES])
NSLog(@"not successful in completing this task");
}
我已经将动作连接到一个按钮,但是当按下按钮时,模拟器冻结,并且 Documents 目录中没有文件出现。
【问题讨论】:
-
一个问题不要问两个不相关的问题
标签: iphone sdk nsmutablearray nsarray nsdictionary