-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

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • If you're trying to parse the JSON string into an array/object, you can use [`json_decode()`](http://php.net/json_decode) – Amal Murali Mar 22 '14 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. – mah Mar 22 '14 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. – Chris Trahey Mar 22 '14 at 16:31

1 Answers1

-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

Community
  • 1
  • 1
Fernando Martínez
  • 1,057
  • 10
  • 13