iphone - JSON.framework add in xcode -


i have copy json.framework in

developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator4.0.sdk/system/library/frameworks

/developer/platforms/iphoneos.platform/developer/sdks/iphoneos4.0.sdk/system/library/frameworks

both folder , importing

#import <json/sbjsonparser.h> 

but when using giving me linking error error command /developer/platforms/iphonesimulator.platform/developer/usr/bin/gcc-4.2 failed exit code 1

ld build/debug-iphonesimulator/hellothere.app/hellothere normal i386 cd /users/samargupta/desktop/hellothere setenv macosx_deployment_target 10.6 setenv path "/developer/platforms/iphonesimulator.platform/developer/usr/bin:/developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /developer/platforms/iphonesimulator.platform/developer/usr/bin/gcc-4.2 -arch i386 -isysroot /developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator4.0.sdk -l/users/samargupta/desktop/hellothere/build/debug-iphonesimulator -f/users/samargupta/desktop/hellothere/build/debug-iphonesimulator -filelist /users/samargupta/desktop/hellothere/build/hellothere.build/debug-iphonesimulator/hellothere.build/objects-normal/i386/hellothere.linkfilelist -mmacosx-version-min=10.6 -xlinker -objc_abi_version -xlinker 2 -framework foundation -framework uikit -framework coregraphics -framework corelocation -framework mapkit -framework json -o /users/samargupta/desktop/hellothere/build/debug-iphonesimulator/hellothere.app/hellothere

ld: framework not found json collect2: ld returned 1 exit status command /developer/platforms/iphonesimulator.platform/developer/usr/bin/gcc-4.2 failed exit code 1

plz tell me wrong??

i wrote json-parser myself. can use if want copying code class source.

you use in way:

nsobject *obj = [self jsontoobj:yourjsonstring]; 

it returns nsdictionary, nsstring or nsarray depending on input. difference between parser , others is, accepts numerical keys, not allowed in json-standard. can't guarantee there no bugs in or works json-strings. please give me feedback, if works you!

-(nsobject*)jsontoobj:(nsstring *)json {     int nextoffset;     return [self jsontoobj:json offset:0 nextoffset:&nextoffset]; }  static int indexofchar(nsstring *str, unichar c, int offset) {     int length = [str length];     (int = offset; < length; i++) {         if ([str characteratindex:i] == c) {             return i;         }     }     return -1; }  static int indexofnonwhitespace(nsstring *str, int offset) {     int len = [str length];     nscharacterset *cset = [nscharacterset whitespaceandnewlinecharacterset];     (int = offset; < len; i++) {         if (![cset characterismember:[str characteratindex:i]]) {             return i;         }     }     return -1; }  static int indexofnonnumber(nsstring *str, int offset) {     int len = [str length];     (int = offset; < len; i++) {         unichar c = [str characteratindex:i];         if (c != '-' && c != '.' && (c < '0' || c > '9')) return i;      }     return -1; }  static int parsehex(nsstring *hexstr) {     unsigned int result = 0;     int len = [hexstr length];     (int = 0; < len; i++) {         result <<= 4;         unsigned int v = 0;         unichar c = [hexstr characteratindex:i];         if (c >= '0' && c <= '9') {             v = c-'0';         } else if (c >= 'a' && c <= 'f') {             v = c-'a'+10;         } else if (c >= 'a' && c <= 'f') {             v = c-'a'+10;         }         result += v;     }     return result; }  -(nsobject*)jsontoobj:(nsstring *)json offset:(int)offset nextoffset:(int*)nextoffset {     offset = indexofnonwhitespace(json, offset);     static nsstring *jsonexceptionname = @"invalidjsonexception";     if (offset == -1) {         @throw [nsexception exceptionwithname:jsonexceptionname reason:@"no non-whitespace 1" userinfo:nil];     }     unichar startchar = [json characteratindex:offset];     if (startchar == '{') {          nsmutabledictionary *result = [nsmutabledictionary dictionary];          int curpos = offset+1;         while (yes) {             curpos = indexofnonwhitespace(json, curpos);             if (curpos == -1) {                 @throw [nsexception exceptionwithname:jsonexceptionname reason:@"no non-whitespace 2" userinfo:nil];             }             unichar curchar = [json characteratindex:curpos];             if (curchar == ',') {                 curpos++;                 continue;             } else if (curchar == '}') {                 *nextoffset = curpos+1;                 return result;             }             unichar quotchar = curchar;             if ((quotchar != '\'' && quotchar != '"') || [json characteratindex:curpos-1]=='\\') {                 quotchar = 0;             }             nsstring *key = nil;             int semiindex = 0;             if (quotchar != 0) {                 int quotstart = curpos+1;                 int quotend = quotstart;                 while (yes) {                     quotend = indexofchar(json, quotchar, quotend);                     if (quotend == -1) {                         @throw [nsexception exceptionwithname:jsonexceptionname reason:@"quotation-end not found 1" userinfo:nil];                     }                     if ([json characteratindex:quotend-1] != '\\') break;                     else quotend++;                 }                 key = [json substringwithrange:nsmakerange(quotstart, quotend-quotstart)];                 semiindex = indexofchar(json, ':', quotend);                 if (semiindex == -1) {                     @throw [nsexception exceptionwithname:jsonexceptionname reason:@"semicolon not found 1" userinfo:nil];                 }             } else {                 semiindex = indexofchar(json, ':', curpos);                 if (semiindex == -1) {                     @throw [nsexception exceptionwithname:jsonexceptionname reason:@"semicolon not found 2" userinfo:nil];                 }                 key = [[json substringwithrange:nsmakerange(curpos, semiindex-curpos)] stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]];             }              [result setobject:[self jsontoobj:json offset:semiindex+1 nextoffset:&curpos] forkey:key];         }     } else if (startchar == '[') {          nsmutablearray *result = [nsmutablearray array];          int curpos = offset+1;         while (yes) {             curpos = indexofnonwhitespace(json, curpos);             if (curpos == -1) {                 @throw [nsexception exceptionwithname:jsonexceptionname reason:@"no non-whitespace 3" userinfo:nil];             }             unichar curchar = [json characteratindex:curpos];             if (curchar == ',') {                 curpos++;                 continue;             } else if (curchar == ']') {                 *nextoffset = curpos+1;                 return result;             }             [result addobject:[self jsontoobj:json offset:curpos nextoffset:&curpos]];         }     } else {         unichar quotchar = startchar;         if ((quotchar != '\'' && quotchar != '"') || [json characteratindex:offset-1]=='\\') {             quotchar = 0;         }         if (quotchar != 0) {             int quotstart = offset+1;             int quotend = quotstart;             while (yes) {                 quotend = indexofchar(json, quotchar, quotend);                 if (quotend == -1) {                     @throw [nsexception exceptionwithname:jsonexceptionname reason:@"quotation-end not found 2" userinfo:nil];                 }                 if ([json characteratindex:quotend-1] != '\\') break;                 else quotend++;             }             *nextoffset = quotend+1;             nsstring *str = [json substringwithrange:nsmakerange(quotstart, quotend-quotstart)];             str = [str stringbyreplacingoccurrencesofstring:@"\\\"" withstring:@"\""];             nsmutablestring *result = [nsmutablestring stringwithcapacity:[str length]];             int len = [str length];             (int = 0; < len; i++) {                 unichar c = [str characteratindex:i];                 if (c != '\\') {                     [result appendstring:[nsstring stringwithcharacters:&c length:1]];                 } else if (i+1 < len) {                     unichar c2 = [str characteratindex:i+1];                     if (c2 == '\\') {                         [result appendstring:[nsstring stringwithcharacters:&c2 length:1]];                         i++;                     } else if (c2 == 'u') {                         unichar cuni = parsehex([str substringwithrange:nsmakerange(i+2, 4)]);                         [result appendstring:[nsstring stringwithcharacters:&cuni length:1]];                         += 5;                     }                 }             }             return result;         } else {             int numberend = indexofnonnumber(json, offset);             if (numberend == -1) {                 @throw [nsexception exceptionwithname:jsonexceptionname reason:@"number-end not found" userinfo:nil];             }             //bool isfloat = indexofchar(json, '.', offset)!=-1;             nsstring *numberstr = [json substringwithrange:nsmakerange(offset, numberend-offset)];             *nextoffset = numberend;             return numberstr;         }     } } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -