Created
December 2, 2011 04:34
-
-
Save mschulkind/1421772 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Construct and run the javascript. SBJsonParser only works with objects or | |
| // arrays, so we wrap the result in an array in case the result is not either | |
| // an object or an array. | |
| NSString* wrappedJavascript = | |
| [NSString stringWithFormat:@"JSON.stringify([%@])", javascript]; | |
| NSString* resultJSON = [componentPlugin writeJavascript:wrappedJavascript]; | |
| // Parse and return the result, making sure to unwrap the result first. | |
| SBJsonParser* jsonParser = [[[SBJsonParser alloc] init] autorelease]; | |
| NSArray* wrappedResult = [jsonParser objectWithString:resultJSON]; | |
| return [wrappedResult objectAtIndex:0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment