EzDevInfo.com

TouchJSON

A humane JSON Objective-C un-framework. (TouchJSON has been deprecated - see README) Touchcode: Home

Json and images

I've got a db on a server and want to get some data fro my iphone. I use TouchJson and everything works fine but I've got a little problem. I don't know how to download images. When I try to build and run the app the emulator just crashes. Got any ideas what to do?


Source: (StackOverflow)

TouchJSON on iOS: dictionaryWithJSONString unrecognized selector sent to class

I have a static library with TouchJSON in it and I am trying to use dictionaryWithJSONString:error: (within the static library) but I keep getting the runtime exception shown in the title.

I have included the NSDictionary category header file and the implementation file of the extension is definitely in the compiled resources list of the static library.

What else could be the problem?


Source: (StackOverflow)

Advertisements

Monotouch binding for TouchJSON?

The admob sdk for iPhone uses a proprietary libAdMobNoThumb.a library and an Objective-C source based TouchJSON library.

Does anybody know of a C# binding for TouchJSON so that we can include it?

Or does anybody know how to build a library that can be included?

We created an iPhone Library project with Xcode and added the full TouchJSON source tree. We've than linked the resulting libTouchJSON.a in a test iPhone app with following gcc_flags:

-v -v -v -gcc_flags "-L${ProjectDir}/Lib -lAdMobNoThumb -lTouchJSON -force_load ${ProjectDir}/Lib/libAdMobNoThumb.a -force_load ${ProjectDir}/Lib/libTouchJSON.a"

This produced following error output (thanks to the -v -v -v):

Error 1: mtouch failed with the following message:
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m: In function 'monotouch_debug_connect':
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:1779: warning: implicit declaration of function 'select'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m: In function 'main':
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:1821: warning: implicit declaration of function 'chdir'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:1838: warning: implicit declaration of function 'monotouch_enable_debug_tracking'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:1914: warning: implicit declaration of function 'dup2'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:1921: warning: implicit declaration of function 'mini_get_debug_options'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:1925: warning: implicit declaration of function 'mono_debugger_agent_parse_options'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:2052: warning: implicit declaration of function 'getpagesize'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:2055: warning: cast from pointer to integer of different size
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmpe374af5.tmp/main.m:2055: warning: initialization makes pointer from integer without a cast
Undefined symbols:
  "_OBJC_CLASS_$_CJSONSerializer", referenced from:
      objc-class-ref-to-CJSONSerializer in libAdMobNoThumb.a(AdMobAd.o)
      objc-class-ref-to-CJSONSerializer in libAdMobNoThumb.a(AdMobWebView.o)
      objc-class-ref-to-CJSONSerializer in libAdMobNoThumb.a(AdMobFlexWebView.o)
  "_OBJC_CLASS_$_CJSONDeserializer", referenced from:
      objc-class-ref-to-CJSONDeserializer in libAdMobNoThumb.a(AdMobOpener.o)
      objc-class-ref-to-CJSONDeserializer in libAdMobNoThumb.a(AdMobSearchViewController.o)
      objc-class-ref-to-CJSONDeserializer in libAdMobNoThumb.a(AdMobAd.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
 (1) (AdMobber)

Any suggestions to get around this problem?

TIA, Mollyke.


Source: (StackOverflow)

Parse JSON array

I fetch a JSON array from a web service with touchJSON. Which looks like this:

[{"icecream": {"title": "Banana"}}, {"icecream": {"title": "Strawberry"}}]

I'm not able to parse this into a NSDictionary, because touchJSON doesn't support JSON arrays.

How do I get my JSON array into a NSDicitionary?

Regards


Source: (StackOverflow)

Using AdMob in MonoTouch Projects with iOS SDK 4.2

Using AdMob in MonoTouch Projects with iOS SDK 4.2

We have a test project to try using AdMob with MonoTouch. The setup is as follows:

We created a (fat) TouchJSON library as described in post Monotouch binding for TouchJSON?

We have a Libs library which contains this libTouchJSON.a and the libAdMobNoThumb.a library supplied by AdMob. In there I also have an AdMob.dll procuced by btouch from an AdMob.cs file that defines the (limited set of) Admob methods that we want to use. This dll is added to the references for the project

We supply following extra flags:

-v -v -v -gcc_flags "-L${ProjectDir}/../Libs -lAdMobNoThumb -lTouchJSON -force_load ${ProjectDir}/../Libs/libAdMobNoThumb.a -force_load ${ProjectDir}/../Libs/libTouchJSON.a"

and we select "Don't Link" as linker behaviour.

This used to work with the pre-SDK 4.2 version of the admob library. But now with the 4.2 version we get the

ld: framework not found AudioUnit 

error. We've read that the solution would be to 'turn the linker back on'. But if we do link (leaving the rest of the setup as described above), we get a lot of unknown symbols from the admob library:

Error 1: mtouch failed with the following message:
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m: In function 'monotouch_debug_connect':
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1779: warning: implicit declaration of function 'select'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m: In function 'main':
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1821: warning: implicit declaration of function 'chdir'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1838: warning: implicit declaration of function 'monotouch_enable_debug_tracking'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1914: warning: implicit declaration of function 'dup2'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1921: warning: implicit declaration of function 'mini_get_debug_options'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:1925: warning: implicit declaration of function 'mono_debugger_agent_parse_options'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:2055: warning: implicit declaration of function 'getpagesize'
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:2058: warning: cast from pointer to integer of different size
/var/folders/hF/hF42FIdhEUmY1y-pGRsu1k+++TI/-Tmp-/tmp2685841f.tmp/main.m:2058: warning: initialization makes pointer from integer without a cast
Undefined symbols:
"_CGColorSpaceGetModel", referenced from:
    +[AdMobFlexAd(DictionaryParsing) arrayWithColor:] in libAdMobNoThumb.a(AdMobFlexAd.o)
"_CGRectZero", referenced from:
    _CGRectZero$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    _CGRectZero$non_lazy_ptr in libAdMobNoThumb.a(AdMobUtil.o)
    (maybe you meant: _CGRectZero$non_lazy_ptr)
"_OBJC_CLASS_$_CATransition", referenced from:
    objc-class-ref-to-CATransition in libAdMobNoThumb.a(AdMobModalViewController.o)
"_CGContextClip", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
"_CGRectGetMaxX", referenced from:
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobVideoPlayerOverlayView addTitleBar:] in libAdMobNoThumb.a(AdMobVideoPlayerOverlayView.o)
"_CGRectGetMaxY", referenced from:
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
"_kCATransitionMoveIn", referenced from:
    _kCATransitionMoveIn$non_lazy_ptr in libAdMobNoThumb.a(AdMobModalViewController.o)
    (maybe you meant: _kCATransitionMoveIn$non_lazy_ptr)
"_CGRectGetMidX", referenced from:
    -[AdMobModalViewController setupWindowScreenshot:original:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobModalViewController setupCenterForFullscreenView:withOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobModalViewController viewDidAppear:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobModalHelper juggleSubviews:] in libAdMobNoThumb.a(AdMobModalHelper.o)
    -[AdMobSingleAdView animationDidStop:finished:] in libAdMobNoThumb.a(AdMobSingleAdView.o)
"_CGRectGetMidY", referenced from:
    -[AdMobModalViewController setupWindowScreenshot:original:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobModalViewController setupCenterForFullscreenView:withOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobModalViewController viewDidAppear:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobVideoViewController moveOverlayToLandingPage] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobModalHelper juggleSubviews:] in libAdMobNoThumb.a(AdMobModalHelper.o)
    -[AdMobSingleAdView animationDidStop:finished:] in libAdMobNoThumb.a(AdMobSingleAdView.o)
"_CGRectGetMinX", referenced from:
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
"_CGRectGetMinY", referenced from:
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    +[AdMobModalViewController convertApplicationFrame:toOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
"_MPMoviePlayerPlaybackDidFinishNotification", referenced from:
    _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr in libAdMobNoThumb.a(AdMobVideoViewController.o)
    _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr in libAdMobNoThumb.a(AdMobMovieView.o)
    (maybe you meant: _MPMoviePlayerPlaybackDidFinishNotification$non_lazy_ptr)
"_CGRectContainsPoint", referenced from:
    -[AdMobFlexAdContainerView touchIsInSelf:] in libAdMobNoThumb.a(AdMobFlexAdContainerView.o)
    -[AdMobOldSchoolSingleAdView touchIsInSelf:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobVideoPlayerButton touchIsInSelf:] in libAdMobNoThumb.a(AdMobVideoPlayerButton.o)
"_kCAMediaTimingFunctionEaseInEaseOut", referenced from:
    _kCAMediaTimingFunctionEaseInEaseOut$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _kCAMediaTimingFunctionEaseInEaseOut$non_lazy_ptr)
"_CGContextAddArcToPoint", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
"_CATransform3DMakeAffineTransform", referenced from:
    +[AdMobFlexAd(DictionaryParsing) valueOfType:withValue:defaultValueProvider:] in libAdMobNoThumb.a(AdMobFlexAd.o)
"_CGContextRestoreGState", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGAffineTransformIdentity", referenced from:
    _CGAffineTransformIdentity$non_lazy_ptr in libAdMobNoThumb.a(AdMobModalViewController.o)
    _CGAffineTransformIdentity$non_lazy_ptr in libAdMobNoThumb.a(AdMobVideoViewController.o)
    _CGAffineTransformIdentity$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _CGAffineTransformIdentity$non_lazy_ptr)
"_CGColorGetColorSpace", referenced from:
    +[AdMobFlexAd(DictionaryParsing) arrayWithColor:] in libAdMobNoThumb.a(AdMobFlexAd.o)
"_OBJC_CLASS_$_MPMoviePlayerController", referenced from:
    objc-class-ref-to-MPMoviePlayerController in libAdMobNoThumb.a(AdMobVideoViewController.o)
    objc-class-ref-to-MPMoviePlayerController in libAdMobNoThumb.a(AdMobMovieView.o)
"_CGColorGetComponents", referenced from:
    +[AdMobFlexAd(DictionaryParsing) arrayWithColor:] in libAdMobNoThumb.a(AdMobFlexAd.o)
"_CGAffineTransformRotate", referenced from:
    -[AdMobVideoViewController setMoviePlayerOrientation:] in libAdMobNoThumb.a(AdMobVideoViewController.o)
    -[AdMobVideoViewController setMoviePlayerOrientation:] in libAdMobNoThumb.a(AdMobVideoViewController.o)
"_CGContextSetLineWidth", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_OBJC_CLASS_$_CAKeyframeAnimation", referenced from:
    objc-class-ref-to-CAKeyframeAnimation in libAdMobNoThumb.a(AdMobFlexAd.o)
    objc-class-ref-to-CAKeyframeAnimation in libAdMobNoThumb.a(AdMobSingleAdView.o)
"_CGSizeZero", referenced from:
    _CGSizeZero$non_lazy_ptr in libAdMobNoThumb.a(AdMobOpener.o)
    _CGSizeZero$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _CGSizeZero$non_lazy_ptr)
"_kCATransitionFromTop", referenced from:
    _kCATransitionFromTop$non_lazy_ptr in libAdMobNoThumb.a(AdMobModalViewController.o)
    (maybe you meant: _kCATransitionFromTop$non_lazy_ptr)
"_OBJC_CLASS_$_CAAnimationGroup", referenced from:
    objc-class-ref-to-CAAnimationGroup in libAdMobNoThumb.a(AdMobFlexAd.o)
"_CGAffineTransformMakeScale", referenced from:
    -[AdMobPagingScrollView setNumberOfPages:touchDelegate:] in libAdMobNoThumb.a(AdMobPagingScrollView.o)
"_kCAFillModeBoth", referenced from:
    _kCAFillModeBoth$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _kCAFillModeBoth$non_lazy_ptr)
"_kCAMediaTimingFunctionEaseIn", referenced from:
    _kCAMediaTimingFunctionEaseIn$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _kCAMediaTimingFunctionEaseInEaseOut$non_lazy_ptr, _kCAMediaTimingFunctionEaseIn$non_lazy_ptr )
"_CATransform3DIdentity", referenced from:
    _CATransform3DIdentity$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    _CATransform3DIdentity$non_lazy_ptr in libAdMobNoThumb.a(AdMobSingleAdView.o)
    (maybe you meant: _CATransform3DIdentity$non_lazy_ptr)
"_CGImageCreateWithImageInRect", referenced from:
    +[AdMobSearchBar tileImageViewWithFrame:image:searchBar:] in libAdMobNoThumb.a(AdMobSearchBar.o)
"_kCAMediaTimingFunctionEaseOut", referenced from:
    _kCAMediaTimingFunctionEaseOut$non_lazy_ptr in libAdMobNoThumb.a(AdMobModalViewController.o)
    _kCAMediaTimingFunctionEaseOut$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _kCAMediaTimingFunctionEaseOut$non_lazy_ptr)
"_CGAffineTransformScale", referenced from:
    -[AdMobVideoViewController setMoviePlayerOrientation:] in libAdMobNoThumb.a(AdMobVideoViewController.o)
"_CGGradientCreateWithColors", referenced from:
    -[AdMobGradientView drawRect:] in libAdMobNoThumb.a(AdMobGradientView.o)
    -[AdMobOldSchoolSingleAdView drawShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_kCAFillModeForwards", referenced from:
    _kCAFillModeForwards$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    _kCAFillModeForwards$non_lazy_ptr in libAdMobNoThumb.a(AdMobSingleAdView.o)
    (maybe you meant: _kCAFillModeForwards$non_lazy_ptr)
"_kCAMediaTimingFunctionLinear", referenced from:
    _kCAMediaTimingFunctionLinear$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _kCAMediaTimingFunctionLinear$non_lazy_ptr)
"_kCAFillModeBackwards", referenced from:
    _kCAFillModeBackwards$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _kCAFillModeBackwards$non_lazy_ptr)
"_CGContextSaveGState", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGContextMoveToPoint", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGAffineTransformMakeRotation", referenced from:
    -[AdMobModalViewController calculateScreenshotTransform:original:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobModalViewController transformFromOrientation:] in libAdMobNoThumb.a(AdMobModalViewController.o)
"_CGContextSetStrokeColorWithColor", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGContextDrawLinearGradient", referenced from:
    -[AdMobGradientView drawRect:] in libAdMobNoThumb.a(AdMobGradientView.o)
    -[AdMobOldSchoolSingleAdView drawShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGContextAddArc", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
"_CATransform3DMakeScale", referenced from:
    +[AdMobSingleAdView pulseAnimationWithDelegate:] in libAdMobNoThumb.a(AdMobSingleAdView.o)
    +[AdMobSingleAdView pulseAnimationWithDelegate:] in libAdMobNoThumb.a(AdMobSingleAdView.o)
"_CGImageGetHeight", referenced from:
    +[AdMobSearchBar tileImageViewWithFrame:image:searchBar:] in libAdMobNoThumb.a(AdMobSearchBar.o)
"_CGContextFillRect", referenced from:
    -[AdMobGradientView drawRect:] in libAdMobNoThumb.a(AdMobGradientView.o)
    -[AdMobOldSchoolSingleAdView drawShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGContextSetShouldAntialias", referenced from:
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_OBJC_CLASS_$_CAMediaTimingFunction", referenced from:
    objc-class-ref-to-CAMediaTimingFunction in libAdMobNoThumb.a(AdMobModalViewController.o)
    objc-class-ref-to-CAMediaTimingFunction in libAdMobNoThumb.a(AdMobFlexAd.o)
"_CGContextTranslateCTM", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
"_CGContextAddLineToPoint", referenced from:
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_OBJC_CLASS_$_CATransaction", referenced from:
    objc-class-ref-to-CATransaction in libAdMobNoThumb.a(AdMobFlexAdContainerView.o)
"_kCATransition", referenced from:
    _kCATransition$non_lazy_ptr in libAdMobNoThumb.a(AdMobModalViewController.o)
    (maybe you meant: _kCATransitionMoveIn$non_lazy_ptr, _kCATransition$non_lazy_ptr , _kCATransitionFromTop$non_lazy_ptr )
"_CGContextBeginPath", referenced from:
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGContextStrokePath", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    +[AdMobOldSchoolSingleAdView drawImage:atPoint:withBevelsAndRoundedCornersOfRadius:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGContextScaleCTM", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
"_CGPointZero", referenced from:
    _CGPointZero$non_lazy_ptr in libAdMobNoThumb.a(AdMobOpener.o)
    _CGPointZero$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    _CGPointZero$non_lazy_ptr in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    (maybe you meant: _CGPointZero$non_lazy_ptr)
"_CGGradientRelease", referenced from:
    -[AdMobGradientView drawRect:] in libAdMobNoThumb.a(AdMobGradientView.o)
    -[AdMobOldSchoolSingleAdView drawShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_OBJC_CLASS_$_CABasicAnimation", referenced from:
    objc-class-ref-to-CABasicAnimation in libAdMobNoThumb.a(AdMobFlexAd.o)
"_kCAFillModeRemoved", referenced from:
    _kCAFillModeRemoved$non_lazy_ptr in libAdMobNoThumb.a(AdMobFlexAd.o)
    (maybe you meant: _kCAFillModeRemoved$non_lazy_ptr)
"_CGRectEqualToRect", referenced from:
    -[AdMobWebViewController loadViewWithBounds:] in libAdMobNoThumb.a(AdMobWebViewController.o)
    -[AdMobModalHelper juggleSubviews:] in libAdMobNoThumb.a(AdMobModalHelper.o)
"_CGContextSetFillColorWithColor", referenced from:
    -[AdMobModalViewController newScreenshotOfWindow:addGrayMask:] in libAdMobNoThumb.a(AdMobModalViewController.o)
    -[AdMobGradientView drawRect:] in libAdMobNoThumb.a(AdMobGradientView.o)
    -[AdMobOldSchoolSingleAdView drawRect:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobOldSchoolSingleAdView drawShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobOldSchoolSingleAdView.o)
    -[AdMobSearchAdView setAd:] in libAdMobNoThumb.a(AdMobSearchAdView.o)
    -[AdMobShineView drawTranslucentShineBackgroundWithBaseColor:] in libAdMobNoThumb.a(AdMobShineView.o)
"_CGContextDrawImage", referenced from:
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
    -[AdMobImageView drawRect:] in libAdMobNoThumb.a(AdMobImageView.o)
"_OBJC_CLASS_$_MFMailComposeViewController", referenced from:
    objc-class-ref-to-MFMailComposeViewController in libAdMobNoThumb.a(AdMobWebView.o)
"_CGImageRelease", referenced from:
    +[AdMobSearchBar tileImageViewWithFrame:image:searchBar:] in libAdMobNoThumb.a(AdMobSearchBar.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
(1) (Proggy)

Please advise, we have no idea how to proceed.

Thanks in advance.


Source: (StackOverflow)

How do I get the value's of name & url from a nsdictionary object?

I am using touch JSON which worked out pretty well for me. I was able to take an array, put it in a dictionary, serialize it via touchJSON and send it out via http.

Now on the return end, I received the data, and put it into a dictionary (I'm using trends.json from twitter as an example JSON).

If I try to get the value for trends from the dictionary object, I get this:

2010-08-02 00:23:31.069 rateMyTaxi[30610:207] ANSWER: (
  {
    name = "Fried Chicken Flu";
    url = "http://search.twitter.com/search?q=Fried+Chicken+Flu";
  },
  {
    name = "Lisa Simpson";
    url = "http://search.twitter.com/search?q=Lisa+Simpson";
  },
  {
    name = "#breakuplines";
    url = "http://search.twitter.com/search?q=%23breakuplines";
  },
  {
    name = "#thingsuglypeopledo";
    url = "http://search.twitter.com/search?q=%23thingsuglypeopledo";
  },
  {
    name = "Inception";
    url = "http://search.twitter.com/search?q=Inception";
  },
  {
    name = "#sharkweek";
    url = "http://search.twitter.com/search?q=%23sharkweek";
  },
  {
    name = "JailbreakMe";
    url = "http://search.twitter.com/search?q=JailbreakMe";
  },
  {
    name = "Kourtney";
    url = "http://search.twitter.com/search?q=Kourtney";
  },
  {
    name = "Shark";
    url = "http://search.twitter.com/search?q=Shark";
  },
  {
    name = "Boondocks";
    url = "http://search.twitter.com/search?q=Boondocks";
  }
)

If I try to get the value for name or URL, I get nothing which is frustrating. That is the data I will need. You can tell it is in a dictionary format because it is formatted and it is reading properly sort of for trends. I'm pretty sure I'm missing something, so please let me know which direction to follow.

Here is the code:

// this is all touch JSON magic. responseString has the full contents of trends.json

 NSString *response = [request responseString];
 NSLog(@"response value is:%@",response);

 NSString *jsonString = response;
 NSData *jsonData = [jsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding];
 NSError *error = nil;
 NSDictionary *dictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
//end of touchJSON.  It is in a dictionary now.

 NSLog(@"dictionary:%@, error %@", dictionary, error); //http://cl.ly/adb6c6a974c3e70fb51c

 NSString *twitterTrends = (NSString *) [dictionary objectForKey:@"trends"];
 NSLog(@"ANSWER:%@",twitterTrends); //http://cl.ly/fe270fe7f05a0ea8d478

Source: (StackOverflow)

TouchJson memory leak?

I'm using TouchJson to parse json data from facebooks graph api. I'm getting some memory leaks though, and I don't really understand why...

In my effort to find the leak, I've removed everything else, so the following code is what I'm left with. The leak is one NSCFString for each loop, and I understand that it comes from the assignement to myItem.date, but I don't understand why?

I'm using the latest version of TouchJson

NSError *error;
NSDictionary *jsonDictionary = [[CJSONDeserializer deserializer] deserializeAsDictionary:data error:&error];
NSArray *jsonArray = [jsonDictionary objectForKey:@"data"];

for (NSDictionary *jsonEntry in jsonArray) {
    NSDictionary *fromDictionary = [jsonEntry objectForKey:@"from"];
    NSString *userId = [fromDictionary objectForKey:@"id"];

    // Continue if it is a post from Atlas
    if (userId != nil && [userId isEqualToString:@"10465958627"]){
        MyItem *myItem = [[MyItem alloc] init];

        // This uncommented causes the leak, why?
        myItem.date = [jsonEntry objectForKey:@"created_time"];

        [myItem release];
    }
}

Thank you for your help!

Edit: I forgot to mention that MyItem is just an object with a property like so

@property (nonatomic, copy) NSString *date;

Source: (StackOverflow)

iPhone unable to parse JSON results from YELP

I'm attempting to parse validated JSON from a yelp search result.

This correctly spits out the json as expected (confirmed in simulator browser and my own).

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    NSString *dump = [[[NSString alloc] initWithData: data encoding:NSUTF8StringEncoding] autorelease];

    NSLog(@"Did Recieve data: %@",  dump);
    [JSONData appendData:data];
}

But when my connection finishes loading I'm having a hard time extracting the results and parsing the data:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{   
    NSLog(@"Connection Did Finish Loading");

    NSError *error = nil;
    id cureLocations = [[CJSONDeserializer deserializer] deserializeAsDictionary:JSONData error:&error];
    [JSONData release];

    NSLog(@"Connection finished loading: %@", error);
}

I get: Connection finished loading: Error Domain=CJSONDeserializerErrorDomain Code=-11 "The operation couldn’t be completed. (CJSONDeserializerErrorDomain error -11.)"

I switched to TouchJSON from SBJSON because I wasn't able to extract it from that framework either. I've attempted loading it into Dictionaries and Arrays with null as the result. At this point I've been banging my head on the keyboard for hours and would greatly appreciate any input.

JSON sample

Update:

I am a dummy. I hadn't initialized JSONData. Please accept my apologies for wasting your time and thanks for your suggestions.


Source: (StackOverflow)

iPhone: fastest way to fire API calls and parse JSON?

I currently have a UITableViewController that parses a JSON response (using TouchJSON) fired asynchronously using an ASIHTTPRequest.

I'm very concerned with the performance of my application.. 6 out of 10 API calls on average would lead to request timeouts and the combined time to fire an API call and parse an API call for 20 objects (each with about 10 attributes) ..takes around 8-9 seconds.

What can I do to speed up/streamline this process? Any methods / libraries I should be looking at to strip down the time to 2 seconds or less?


Source: (StackOverflow)

TOUCHJSON Serialization from NSDictionary

I've read through the questions and answers related to TouchJSON serialization and I'm still not getting it to work.

I create an NSDictionary with sample data and used the JSONTouch serializer to convert the NSDictionary to JSON. However, when I log the NSData object 'theJSONData', it gives me this as a result:

<7b223131 31353535 34343434 223a2250 ... 65227d>

Additionally, when I send this 'theJSONData' data to the web service (that's expecting JSON) this is what I get back:

2011-07-31 18:48:46.572 Street Lights[7169:207] Serialization Error: (null)

2011-07-31 18:48:46.804 Street Lights[7169:207] returnData: (null)

2011-07-31 18:48:46.805 Street Lights[7169:207] Error: Error Domain=kJSONScannerErrorDomain Code=-201 "Could not scan array. Array not started by a '[' character." UserInfo=0x4d51ab0 {snippet=!HERE>!?xml version="1.0" , location=0, NSLocalizedDescription=Could not scan array. Array not started by a '[' character., character=0, line=0}

What am I doing wrong? Does the JSON NSData object 'theJSONData' need to be converted to another type before I send it to the web service? Is there another step I'm missing?

// Create the dictionary
NSDictionary *outage = [[NSDictionary alloc] initWithObjectsAndKeys:
                        @"YCoord", @"12678967.543233",
                        @"XCoord", @"12678967.543233",
                        @"StreetLightID", @"666",
                        @"StreetLightCondition", @"Let's just say 'BAD'",
                        @"PhoneNumber", @"1115554444",
                        @"LastName", @"Smith",
                        @"Image",@"",
                        @"FirstName", @"Dawn",
                        @"Comments", @"Pole knocked down",
                        nil];
NSError *error = NULL;

// Serialize the data
NSData *theJSONData = [[CJSONSerializer serializer] serializeDictionary:outage error:&error];
NSLog(@"theJSONData: %@", theJSONData);
NSLog(@"Serialization Error: %@", error);

// Set up the request and send it
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://24.52.35.127:81/StreetLight/StreetlightService/CreateStreetLightOutage"]];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: theJSONData];

// Deserialize the response
NSData *returnData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error:&error];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding];
NSData *theReturnData = [returnString dataUsingEncoding:NSUTF8StringEncoding];
id theObject = [[CJSONDeserializer deserializer] deserializeAsArray:theReturnData error:&error];
NSLog(@"returnData: %@",theObject);
NSLog(@"Error: %@", error);

Source: (StackOverflow)

Problem Comparing Value Returned by valueForKey Method of NSDictionary

I use TouchJSON to convert the following to an NSDictionary object

// sample JSON object
{
data =     (
            {
        companyId = 4779;
        companyName = "ABC Corporation";
    },
            {
        companyId = 4806;
        companyName = "EFG Corporation";
    }
);
dataCount = 2;
success = 1;
}

NSString *src = @"http://mysite/app1/companyList.php";
NSURL *url = [[NSURL alloc] initWithString:src];    
NSData *data = [[NSData alloc] initWithContentsOfURL:url];
NSError *error = nil;
NSDictionary *dic = [[CJSONDeserializer deserializer] deserializeAsDictionary:data error:&error];

int dataCount = (int) [dic valueForKey:@"dataCount"];

// This is where I have problem with. The (dataCount == 1) expression never evaluates to true even if value of dataCount from the JSON object equals to 1.
if ( dataCount == 1 ){
  // do something
} else {
  // do something else
}

Have I done anything wrong?

I'd appreciate any help.


Source: (StackOverflow)

Parsing JSON using Grand Central Dispatch in connectionDidFinishLoading:?

I'm am performing JSON deserialization with JSONTouch, but it's taking too long and it's blocking the UI, so I've tried to make a GCD background queue to put the serialization in a background thread. Sometimes it runs fine, but sometimes I get a EXC_BAD_ACCESS on deserializeAsDictionary:weakSelf.mutableData error:&theError];.

I'm at a loss as to why. I've made mutableData an atomic property. I'm making 3 requests at once, so I guess something it has to do with threads trying to access the mutableData? or perhaps mutableData is not in a good state when the block runs?

Thanks a lot!

-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
     __weak myViewController *weakSelf = self;

    dispatch_queue_t updateQueue = dispatch_queue_create("parse json", NULL);
    dispatch_async(updateQueue, ^{
        NSError *theError = nil;

    // This is the call that gives me EXC_BAD_ACCESS
    NSDictionary *dict = [[CJSONDeserializer deserializer] 
       deserializeAsDictionary:weakSelf.mutableData error:&theError];

   dispatch_async(dispatch_get_main_queue(), ^{
            [weakSelf setMutableData: nil];
      });
   });
   dispatch_release(updateQueue);
}

Source: (StackOverflow)

touchJSON gives NSInvalidException NSNull isEqualtoString:

Hello I am new to Cocoa Development, and I'm trying to figure out what I did wrong. I followed a (tutorial) that uses touchJSON to fill a tableView with a mySQL database in Xcode. When I run the application everything is working fine, but when I scroll down the tableView I get an NSInvalidExeption error:

Terminating app due to uncaught exception 'NSInvalidArgumentException',
    reason: '-[NSNull isEqualToString:]: unrecognized selector sent to 
        instance 0x1469cd8'

I don't really know if this has something to do with the php code (and database) or the code in Xcode.

This is my php code:

<?php

$link = mysql_pconnect("localhost", "root", "root") or die("Could not connect");
mysql_select_db("PartyON") or die("Could not select database");

$arr = array();
$rs = mysql_query("SELECT id, Maand, Naam, Locatie, Plaats FROM tblWebData");

while($obj = mysql_fetch_object($rs)) {
    $arr[] = $obj;
}

echo '{"tblWebData":'.json_encode($arr).'}';

?> 

This is my code from Xcode:

#import "GentDataView.h"
#import "CJSONDeserializer.h"
#import "GentDetailCell.h"

@implementation GentDataView

@synthesize rows, tableview;

- (void)viewDidLoad {

    [super viewDidLoad];    

    NSURL *url = [NSURL URLWithString:@"http://localhost:8888/example3.php"]; //URL Modification

    NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:url]; // Pulls the URL

    //  NSLog(jsonreturn); // Look at the console and you can see what the restults are 

    NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];

    NSError *error = nil;   

    // In "real" code you should surround this with try and catch

    NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];

    if (dict)
    {
        rows = [dict objectForKey:@"tblWebData"];
    }

    NSLog(@"Array: %@",rows);   

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [rows count];

}

// Customize the appearance of table view cells.
- (GentDetailCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    


    static NSString *CellIdentifier = @"Cell";

    GentDetailCell *cell = (GentDetailCell *) [tableview dequeueReusableCellWithIdentifier:CellIdentifier];

        if (cell == nil) {

        cell = [[GentDetailCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }

    // Configure the cell.  
    NSSortDescriptor *sorteerDiscriptor = [[NSSortDescriptor alloc] initWithKey:@"id" ascending:NO];

    rows = [rows sortedArrayUsingDescriptors:[NSArray arrayWithObject:sorteerDiscriptor]];

    NSDictionary *dict = [rows objectAtIndex: indexPath.row];

    cell.Naam.text = [dict objectForKey:@"Naam"];
    cell.Plaats.text = [dict objectForKey:@"Plaats"];
    cell.Maand.text = [dict objectForKey:@"Maand"]; 
    cell.Locatie.text = [dict objectForKey:@"Locatie"]; 
    cell.imageView.image = [NSURL URLWithString:@"http://www.iconarchive.com/show/flags-icons-by-iconscity/belgium-icon.html"];

    //cell.textLabel.text = [dict objectForKey:@"post_title"];
    //cell.detailTextLabel.text = [dict objectForKey:@"post_content"];  
    //tableView.backgroundColor = [UIColor cyanColor];  

    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 125;
}
@end

As I already told I'm new to this, so any help would be very very welcome! I'm trying to figure out this issue for days now but I can't seem to find an accurate answer or a solution!

Thank you very much for your efforts in advance!


Source: (StackOverflow)

Iphone TouchJson jsonData to Dict

Hi i'm making app that take json from web page but its not converting the jsonData to Dict using touchJson (Framework, Library, Class)

The Json

{SFP:[{"Group":"Oil"},{"Group":"Sugar"}]}

TheCode

NSStringEncoding *Encoding;
NSError *Error;
    NSURL *PriceURL = [NSURL URLWithString:@"http://xxx.co/SFP/?Q=P1"];
    NSString *JsonString = [[NSString alloc] initWithContentsOfURL:PriceURL usedEncoding:Encoding error:&Error];
    NSData *JsonData = [JsonString dataUsingEncoding:NSUTF32BigEndianStringEncoding];
    NSDictionary *Dict = [[[CJSONDeserializer deserializer] deserializeAsDictionary:JsonData error:&Error] retain];
    NSArray *Rows = [Dict objectForKey:@"SFP"];
    NSLog(@"%@", JsonString);
    NSLog(@"%@", JsonData);
    NSLog(@"%@", Dict);

The Consol

2012-08-05 14:49:02.794 SFP[23791:f803] {SFP:[{"Group":"Oil"},{"Group":"Sugar"}]}
2012-08-05 14:49:02.795 SFP[23791:f803] <0000007b 00000053 00000046 00000050 0000003a 0000005b 0000007b 00000022 00000047 00000072 0000006f 00000075 00000070 00000022 0000003a 00000022 0000004f 00000069 0000006c 00000022 0000007d 0000002c 0000007b 00000022 00000047 00000072 0000006f 00000075 00000070 00000022 0000003a 00000022 00000053 00000075 00000067 00000061 00000072 00000022 0000007d 0000005d 0000007d>
2012-08-05 14:49:02.795 SFP[23791:f803] (null)

Source: (StackOverflow)

High memory usage when parsing JSON

I'm currently parsing all of my data from JSON and storing it in an array. However when it starts parsing the memory usage jumps up from about 25mb to 800mb. After doing some research I was told to put an @autoreleasepool in the GCD block but to no avail.

Here's the code I've got so far:

 self.channelSchedules = [NSMutableArray new];
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    // Add code here to do background processing
    //Loop through each channel object and download schedule
    @autoreleasepool {
        for (atlas_channel* channel in self.channels) {
            NSLog(@"Updating listings for %@", [channel getChannelTitle]);
            [self.channelSchedules addObject:[[channel getChannelSchedule] returnCurrentContentObject]];
            [self.tableView reloadData];
            [self scrollViewDidScroll:nil];
        }
    }
    dispatch_async( dispatch_get_main_queue(), ^{
        // Add code here to update the UI/send notifications based on the
        // results of the background processing
        [self.tableView reloadData];
    });
});

I'm using TouchJSON to parse the data.

Upon further research I think this has something to do with the fact that I'm storing all values once parsed into an NSArray which retains each object in memory. I'm thinking I'll have to use CoreData or something along those lines.


Source: (StackOverflow)