HTTP 纯文本数据到数组
我正在使用 iOS 设备访问本地模块上的数据,它从 http:// 获取信息。 ../path_to/file.bin,响应为纯文本格式:(
[Header]
Version=1
[Data]
SomeData=aValue
StringKey=Value
TimestampKey=DDD:HH:MM:SS
NumberKey=8321
[Blob]
MoreData=moreValues
[EOF]
Lines=11
时间戳仅出现一次,并且是距当前时间的一个时间)
我想将上面字符串中的所有信息放入 NSDictionary
中,以便更轻松地访问。看起来像这样:
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
)
)
所以我会喜欢一个将字符串输入格式化为字典输出的函数。
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 a NSDictionary
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两种解决方案:
这是一个关于 CocoaWithLove 的示例
two solutions:
Here's an example on CocoaWithLove