Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add and read a json file in the iPhone app

I have created a simple Xcode 4.2 project with a empty view controller. I added a json file to this project (i not had a resouces folder/group and so i have create these resouces folder and group). So, in my iphone simulator i can read this json file correctly. When i have tested my example app on my device I had a error: i can't read the json file: Why? I use this simple code lines:

NSString *filePath = [[NSBundle mainBundle] pathForResource:CONFIGURATION_FILE_NAME ofType:CONFIGURATION_FILE_TYEPE]; 
NSString *jsonString = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error: NULL];
like image 606
Safari Avatar asked Mar 17 '12 22:03

Safari


People also ask

How can I read JSON files on my iPhone?

With JSON VIEWER, opening, searching and managing JSON files on your iPhone or iPad will no longer be a problem. To use it, touch the JSON file in any application, select "Open with .." And select JSON VIEWER.

What Apple App Can I see JSON text in?

Jayson is a simple yet powerful JSON viewer and editor with Siri Shortcuts, Share Sheet Actions and URL schemes. Features include: - Browse JSON files stored on your device. - Toggle between viewing JSON in a table or as syntax highlighted text.


1 Answers

I have solved... in my code the CONFIGURATION_FILE_TYEPE is a define @"JSON".. i have changed this with @"json".. this work well on device and simulator!

like image 157
Safari Avatar answered Sep 24 '22 00:09

Safari