I'm using the iOS device to access data on a local module, and it gets info from http://.../path_to/file.bin, and the response is in plain-text as:
[Header]
Version=1
[Data]
SomeData=aValue
StringKey=Value
TimestampKey=DDD:HH:MM:SS
NumberKey=8321
[Blob]
MoreData=moreValues
[EOF]
Lines=11
(timestamp only occurs once and is a time from the current time)
I would like to put all of the information in the string above into aNSDictionary
to be more easily accessible. Something appearing like:
Dictionary (
Header => Dictionary (
Version => 1
开发者_运维问答 )
Data => Dictionary (
SomeData => aValue,
StringKey => anotherValue,
TimestampKey => "DDD:HH:MM:SS", //(format into NSDate if you like)
NumberKey => 8321 //(format into int if you like)
}
Blob => Dictionary (
MoreData => moreValues
)
)
So I would enjoy a function that would format the string input into the dictionary output.
two solutions:
- reformat your data (plist or json) to load them with existing frameworks
- write your own parser
Here's an example on CocoaWithLove
精彩评论