开发者

Is there a native YAML library for iPhone?

I'm considering using YAML as part of my next iPhone application, but I haven't been able to find an Objective-C library to use.

The Wikipedia page for YAML mentions one开发者_StackOverflow, but the link is dead.

Is there an Objective-C library that can parse YAML into native collection objects (NSArray, NSDictionary, etc...)?


The Cocoa extensions for Syck are probably what you're looking for -- it's where the library that Shaggy Frog mentioned seems to be living these days.


You can try YAML.framework it's LibYAML based, it's fast and easy to use. Follows the same pattern as standard NSPropertyListSerialization.

You can use it for iOS (iPhone/iPad) development.


The YAMLKit framework is a thin wrapper around LibYAML. It does exactly what you want. For example:

[[YKParser alloc] init];
[p readString:@"- foo\n- bar\n- baz"];
id result = [p parse];
/* result is now an NSArray containing an NSArray with elements:
   @"foo", @"bar", @"baz" */
[p release];


I recently wrote modern ObjC-YAML bindings, based on the standard NSCoder/NSKeyedArchiver interface: http://github.com/th-in-gs/YACYAML. I'm using them in my own projects, and intend to maintain them for at least as long as I continue to do so.

More here: http://www.blog.montgomerie.net/yacyaml


IF you are doing alot of c++ in your iPhone projects, then please have a look at yaml-cpp:

http://code.google.com/p/yaml-cpp/

  1. has native iPhone support (via it's cmake build system)
  2. has no dependencies beyond a good compiler and cmake
  3. is very c++ friendly (thus, the name) with solid documentation (see the wiki/HowToParseADocument page)


I found this right from YAML's front page. But it looks like it might be out of date (c. 2004?), and the CVS link doesn't work for me.

I would bet that it's just a thin wrapper around an underlying C library like this or this... C code being "native" code that the Objective-C compiler will grok.


I found this question looking for YAML + objective C options. I ended up using this solution: https://github.com/icanzilb/JSONModel. Very cool, up to date and easy to use. Parses yaml directly into objective C models that you create inheriting the JSONModel class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜