-1

how can I parse php file:

var data = { "count" : "22", "objects": [{"id" : "23", "name" : "NAME", "photo" : "http://link", "morning" : "1", "day" : "1", "evening" : "1", "night" : "0"} ]};

in xcode for ios app

thx

3
  • If you're trying to parse the JSON string into an array/object, you can use json_decode() Commented Mar 22, 2014 at 14:47
  • If the only thing this has to do with Xcode is that you happen to use Xcode as your IDE and you're trying to do something within your program, the question is unrelated to Xcode. Commented Mar 22, 2014 at 14:47
  • That is not PHP; it looks like javascript. Can you provide more details on where you are getting that data from? If you drop the var data = bit (and the closing semi-colon), it's JSON, which is natively supported in iOS. Seeing more about where your included line of come lives or where the data comes from will help. Commented Mar 22, 2014 at 16:31

1 Answer 1

-1
  1. First, Why do you need to parse a PHP file in iOS app?
  2. If you need to parse a response in JSON format from a PHP Webservice you can use this library https://github.com/MantleFramework/Mantle (It's a cocoapod too).
  3. If I'm wrong and you really need to parse a PHP file to objective-c you need to see something about compilers.

To complement the second point you also can use the NSDictionary or NSArray as below: Parsing Plain JSON Array in Objective C

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.