Created
June 25, 2012 11:46
-
-
Save ttsubono/2988138 to your computer and use it in GitHub Desktop.
JsonFrameworkで取って来た値をプロパティにセット
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
// なんか無駄な処理入ってる気がするが・・・、一応残しておく | |
#import "JSON.h" //JsonFramework | |
// JSONがNSDictionaryを持つ配列の場合 | |
- (void)something { | |
id *jsonResult = [result JSONValue]; | |
if (![jsonResult isKindOfClass:[NSArray class]]) return; | |
NSArray jsonArray = jsonResult; | |
for (id dic in jsonArray) { | |
[self setDistanceWithIdType:[[(NSDictionary *)dic objectForKey:@"firstKey"] objectForKey:@"secondKey"]]; | |
} | |
} | |
// 値が空のときを判定して、それ以外で値をセット | |
- (void)setDistanceWithIdType:(id)d { | |
if (d == nil || d == [NSNull null]) return; | |
if ([d isKindOfClass:[NSNumber class]]) { | |
self.distance = [d floatValue]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment