-1

I am trying to convert an NSString to a byte array. Then I need to save the byte array in a dictionary. So I do

[dict setObject:[plainString UTF8String] forKey: key];

But I get the compile error

Implicit conversion of a non-Objective-C pointer type 'const char *' to ‘id’ is disallowed with ARC
learner
  • 11,490
  • 26
  • 97
  • 169
  • I am using AFNetwork to send data to Google blobstore. I seem to need byte array to be successful. – learner Aug 04 '14 at 22:18
  • Use NSString or NSData. – Hot Licks Aug 05 '14 at 01:25
  • See - http://stackoverflow.com/questions/901357/how-do-i-convert-an-nsstring-value-to-nsdata - You can simply convert your string to NSData and you should then be able to pass this to AFNetworing – Paulw11 Aug 05 '14 at 02:48

2 Answers2

1

NSDictionary requires keys/values to be Objective-C objects. Is there a reason you can't use your NSString in the dictionary you are trying to produce?

If you really need just the raw bytes, you will need to box those bytes inside an NSValue or NSData object.

Jeff Holliday
  • 760
  • 6
  • 7
  • I am attempting to solve a bigger question: http://stackoverflow.com/questions/24747809/using-afnetworking-to-post-both-text-and-multiple-images-to-google-blobstore – learner Aug 04 '14 at 22:35
0

if dict is an NSDictionary you cannot store non-objects. There is a Cocoa data structure NSMapTable that can store non-object pointers, or you can wrap the non object data in an NSData instance.

I have to question why you want to do this. Why not just store the NSString and call convert only when needed?

Brad Allred
  • 7,323
  • 1
  • 30
  • 49
  • I am attempting to solve a more difficult question: http://stackoverflow.com/questions/24747809/using-afnetworking-to-post-both-text-and-multiple-images-to-google-blobstore – learner Aug 04 '14 at 22:36