-1

I hv a lot of data that format like this: 『 No.1 introduction: explanation: Parts1: Parts2: .. .. parts8.

No.2 introduction: explanation: .... .... .... .... No.100 ... 』

I am setting up of my app's model that hold the data as NSMutableDictionary. So that i can find the data by input a key.

The problem is that there is a lot of data(over 500 sets), Can i have a efficient ways to insert the data without "boring typing"?????

please help.

thank You!^_^"

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Steve Lai
  • 633
  • 1
  • 7
  • 18

2 Answers2

1

Create either a JSON file or a property list file and use the built-in JSON or property list parsing facilities to read the file. Much better than building your own parser.

Hot Licks
  • 47,103
  • 17
  • 93
  • 151
  • So....How to create that? – Steve Lai Jun 02 '13 at 12:49
  • @SteveLai - You mean create the file? Sometimes you can get a lot accomplished with a text editor and find/replace actions, if you think about it. Otherwise you may have to just edit in the needed changes, or else write a quick program (eg, in Java or OSx Objective-C) to pre-process the data somehow and take care of part of the editing work. – Hot Licks Jun 02 '13 at 13:25
0

They way I would approach this problem is to open your file in a text pad and change all the : to pipes |. Now you have a pipe delimited file that you can use to parse.

No.1 introduction| explanation| Parts1| Parts2| parts3| (this is on line1)

No.2 introduction| explanation| Parts1| Parts2| parts3| (this is on line2)

Now put this file into a string and go over line by line to parse the string. Get each of the values put them in an array and then save the array in your NSDictonary with a key value. I will try to search for some sample code. From here you know

array(0) is - No.1 introduction
array(1) is - explanation
...

Check this post NSString tokenize in Objective-C

Community
  • 1
  • 1
Sam B
  • 27,273
  • 15
  • 84
  • 121