Search code examples
iosios5xcode4database-connectionxcode4.4

write an iOS 5.1 app that uses a web service


I am fairly new to iOS programming and I'm trying to make an iOS 5.1 app that communicates with a server to receive information from a database. I got the server returning the needed information from the database by following this tutorial: http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app

But then I tried to follow a the other half of the tutorial by the same guy: http://www.raywenderlich.com/2965/how-to-write-an-ios-app-that-uses-a-web-service

In this one we use JSON, ASIHTTPRequest and MBProgressHUD, but I get a lot of errors when I run this because ASIHTTPRequest is no longer supported in iOS 5.1.

Can anyone point me in the right direction here? I you can show me another tutorial that works for iOS 5.1 that would be great. I have looked but I can't find any.

Thanks


Solution

  • ASIHTTPRequest is most likely returning errors in your iOS 5.1 app because you're using ARC. ASIHTTPRequest wasn't written in ARC, which is why it's throwing tons of errors. But there's an easy workaround:

    1. In Xcode 4's groups and files pane, select your project file at the top of the list.
    2. Select your target towards the left hand panel.
    3. You should now see a list of all the implementation (.m) files referenced and compiled throughout the course of the program.
    4. Double click the implementation files for ASIHTTPRequest and add the following linker flag: -fno-objc-arc. This linker flag acts as a crossbridge between the old non-ARC files and your ARC-based project.

    Although there may be residual warnings left, this trick should remove all other error messages associated with ASIHTTPRequest.