rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

Error when parsing JSON string produced from NSData instance #428

Closed hboon closed 9 years ago

hboon commented 9 years ago
text = NSString.alloc.initWithData(some_json_string.to_data, encoding:NSUTF8StringEncoding)
parsed = BW::JSON.parse(text)

generates:

NSInvalidArgumentException: -[__NSCFString bytes]: unrecognized selector sent to instance 0x10887000

It's possible to just pass some_json_string directly to #parse: and it will work, but sometimes we wouldn't know where the string came from.