Ben S
Ben S

Reputation: 69372

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, but the link is dead.

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

Upvotes: 26

Views: 8450

Answers (7)

santuxus
santuxus

Reputation: 3702

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.

Upvotes: -1

th_in_gs
th_in_gs

Reputation: 549

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

Upvotes: 3

Mirek Rusin
Mirek Rusin

Reputation: 19472

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.

Upvotes: 6

sebnow
sebnow

Reputation: 1380

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];

Upvotes: 5

vizionary
vizionary

Reputation: 106

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)

Upvotes: 1

John Biesnecker
John Biesnecker

Reputation: 3812

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.

Upvotes: 6

Shaggy Frog
Shaggy Frog

Reputation: 27601

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.

Upvotes: 0

Related Questions