how to read data from CFG file for iphone

I want to read data from a CFG (configuration file). How do I read it? Is it the same as XML?

lets say i have this text messge in text.cfg

Restaurant,tab0.png,tab0/index1.html Shop,tab1.png,tab1/index1.html Office,tab2.png,tab2/index1.html Apartment,tab3.png,tab3/index1.html

now i want to parse them and create 4 dynamic button each have their own Png and open html file on click .

so whats the best way to parse them( xml or something else) ??as i want this to be generic and i have to update this data as well

-------------Problems Reply------------

How is the file formatted?

If the file is an XML document containing the configuration details then you can read it in and parse it with an XML parser the same as you do with other XML files.

If the file is formatted differently, Eg., using comma or tab delimiters, then you'll have to write your own code to parse the configuration details.

There are a few options to read in a file, one of which follows:

NSData *fileData = [[NSData alloc] initWithContentsOfFile:filePath];
NSString *fileText = [[NSString alloc] initWithData:fileData encoding:NSUTF8StringEncoding];

Don't forget to release them when you're done. Also this code makes some assumptions.

  • You know the file path
  • The file is using UTF8 encoding
Category:iphone Views:0 Time:2010-08-06
Tags: iphone

Related post

  • how to save data to XML file on iPhone 2011-06-07

    I want to save data to xml file , which include Create xml file insert in it delete from it update certain node read all the elements any suggestion please , any sample tutorial code will be highly appreciated --------------Solutions------------- NSU

  • Fetching data from CSV file locally, iphone application 2011-12-20

    I am developing an iphone app which will fetch the data from CSV file as per the keyword entered in to the UITextFiled, eg. if user enters london than all the possible entries containing the same keyword should be listed down, I have tried CHCSVParse

  • how to pick data from .xls file in iPhone 2011-03-08

    I have go through the already asked questions on this website but did not get my answer. this says that webview can load the .xls file but i have to get the data from it. My thinking is converting this file to some xml format.but i have never done th

  • Log Accelerometer data to a file on Iphone IOS 2011-07-15

    Hi I am trying to write to a file from the accelerometer data. Here is my code: -(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { //xax.text = [NSString stringWithFormat:@"X:[%2.6f]",acceleration.x];

  • Parsing a .cfg file using Ruby? 2011-01-07

    I have a .cfg file with the following data: *.*.key_val = { key1= "value1"; key2 = "value2"; key3 = "value3"; }; I want to read this file and store the key value pairs in a hash @var[key][val]. How it can be done? --------------Solutions-------------

  • How to retrieve key value pair from a cfg file 2012-04-28

    I am new to python. I have a config file as shown below in the same order. I need to retrieve key, value pairs from config file and will use those values in my script # Name and details ( { group => 'abc', host => 'pqr.com', user => 'anonymo

  • How can I alter a cfg. file on Flight Simulator? 2012-05-29

    I need to change the cfg file for an aircraft in Flight Simulator X to increase the power of the brakes. Notebook will let me modify the code line of the file,but when saved will not let me copy and paste to replace the original code. Windows 7 seems

  • Unable to run Aerotow, error message "Access denied, needs to access the FSX.cfg file in my Documents and Settings folder". 2013-03-28

    Original Title: I need help with my Documents and Settings folder I have Windows XP, Norton Internet security. Ok, so I have FSX. I have a fun little program called "Aerotow". In order to run, it needs to access the FSX.cfg file in my Documents and S

  • Attaching Informix .dat and .idx files 2008-09-22

    We are trying to duplicate one of our informix database on a test server, but without Informix expertise in house we can only guess what we need to do. I am learning this stuff on the fly myself and nowhere near the expertise level needed to operate

  • How can I use C to change the last modified date of a file in Windows? 2008-11-11

    Is there a C function call that can change the last modified date of a file or directory in Windows? --------------Solutions------------- You can use the SetFileTime function, for the directories, you have to use the CreateFile function with the FILE

  • software that store data in flat file, what are common encoding/file format techniques 2008-12-19

    I have been spoiled by either using sql server to store data, or using xml files. What are common techniques for storing data in flat files other than xml and CSV. I know many times when I open files that data is all jumbled up, which means it is enc

  • Shell script to compare dates from multiple files in Linux 2008-12-30

    I have lots of home directories under /ifshome on Linux. I want to see which users have not logged in for the past 6 months, and my solution is to parse the /ifshome/user/.lastlogin file. Each .lastlogin file has the same format, 1 line: Last Login:

  • Cannot delete SQLServer2005 data or log files 2009-01-19

    I was trying to restore a backup but I kept getting OS error 32 - cannot delete because in use. Couldn't figure out what was locking the data and log files - so I rebooted the machine, stopped the service but still no luck. Then I deleted the DB but

  • How do I programatically change the create, modify, access date on a file? 2009-02-24

    I need to change the modify date on a file in windows so that it doesn't clutter up my sort order. How can I do that with a script (I may need to do that to the file in the future as well)? thanks. BTW: I don't want to have to install apps to do this

  • Storing data in txt file in specific format 2009-04-11

    my question is related to my previous question (How to display data from txt file in specific format). I was wondering if it is possible at the first place, to store data on txt file in specific format rather than store it first and then retreived it

  • What is the most efficient method to write data to the file? 2009-04-17

    I need to write a large amount of data in my application. Data arrive periodically and pushed into the queue. //producer queue_.push( new_data );// new_data is a 64kb memory range PostThreadMessage(worker_thread_id_, MyMsg, 0, 0);//notify the worker

  • Storing Real Time data into 1000 files 2009-05-29

    I have a program that receives real time data on 1000 topics. It receives -- on average -- 5000 messages per second. Each message consists of a two strings, a topic, and a message value. I'd like to save these strings along with a timestamp indicatin

  • load data into text file from oracle database views 2009-06-05

    I want to load data into text file that is generated after executing "views" in Oracle?How can I achieve this in oracle using UNIX.for example- I want the same in Oracle on unix box.Please help me out as it alredy cosume lots of time. your early resp

  • How to write binary data to a file so that it can be read fast back [gcc/C++]? 2009-06-19

    I need to write a file format that writes out data to a file and can read it back. It should be able to read the data back fairly fast, which should involve blitting a large block of data into a std::vector (since their storage is always implemented

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.167 (s). 11 q(s)