Created
August 20, 2014 04:13
-
-
Save danielgomezrico/25859aa59308c4eff9bb to your computer and use it in GitHub Desktop.
Category to get a string from an array of JSONModel objects using JSONModel 1.0.1
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 "JSONModel.h" | |
@interface NSArray (CRNSArrayJSON) | |
- (NSString*)toJSONString; | |
@end |
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 "NSArray+JSON.h" | |
@implementation NSArray (CRNSArrayJSON) | |
-(NSString*) toJSONString | |
{ | |
// src=http://stackoverflow.com/a/18219972/273119 | |
NSMutableArray* jsonObjects = [NSMutableArray new]; | |
for ( id obj in self ) | |
{ | |
[jsonObjects addObject:[obj toJSONString]]; | |
} | |
return [NSString stringWithFormat:@"[%@]", | |
[jsonObjects componentsJoinedByString:@","]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment