Last active
March 31, 2017 01:58
-
-
Save mexelout/afd78e2cf42f67341c09045394ecdbd4 to your computer and use it in GitHub Desktop.
保存したミュータブルな2次元配列の実装方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// これだとアウト | |
- (bool)loadFunc1 { | |
NSUserDefaults* ud = [NSUserDefaults standardUserDefaults]; | |
NSArray* ary = [ud arrayForKey:load_name]; | |
if(ary) { | |
NSMutableArray* lists = [[NSMutableArray alloc] initWithArray:ary]; | |
return true; | |
} else { | |
return false; | |
} | |
} | |
// これだといける | |
- (bool)loadFunc2 { | |
NSUserDefaults* ud = [NSUserDefaults standardUserDefaults]; | |
NSArray* ary = [ud arrayForKey:load_name]; | |
if(ary) { | |
lists = [[NSMutableArray alloc] init]; | |
for(int i = 0; i < ary.count; i++) { | |
[lists addObject:[[NSMutableArray alloc] initWithArray:[ary objectAtIndex:i]]]; | |
} | |
return true; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment