したがって、100か所すべてに数値0を格納する辞書がありますが、これらの0を使用して、画像なしで100個の画像を初期化します。後で、別の番号が保存された0(つまり、1)を置き換えると、画像が変更されます。私は次のコードを持っています、それはすべて最後の行まで機能します:
NSMutableDictionary *myDict = [[NSMutableDictionary alloc] init];
for (int i = 1; i <= 100; i ++) {
if(myDict)
{
[myDict setObject:[NSNumber numberWithInt:0] forKey:[NSString stringWithFormat:@"block%.3istored",i]];
}
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [paths objectAtIndex:0];
NSString *path = [documentPath stringByAppendingPathComponent:@"blocks.save"];
BOOL successfulWrite = [myDict writeToFile: path atomically: YES];
if(successfulWrite == NO);
[myDict setObject:[NSNumber numberWithInt:1] forKey:@"block002stored"];
for (int z = 1; z <= 100; z ++) {
NSString *mapblock=@"mapblock";
NSString *blocktocheck=[mapblock stringByAppendingFormat:@"%d",z];
NSLog(@"%d", z);
NSLog(@"%@", blocktocheck);
{if (forKey:@"block%.3zstored" == 0) [@"%@", blocktocheck].image = [[UIImage imageNamed:@""];
}
どんな助けでもいただければ幸いです。