Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

donaghy

macrumors member
Original poster
Aug 6, 2009
49
0
Is it possible to convert a NSString to a byte array? I'm not sure how to do this, help appreciated.

cheers.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
Is it possible to convert a NSString to a byte array? I'm not sure how to do this, help appreciated.

I'm not sure why you would want to do this, and usually with questions like this you are barking up the completely wrong tree.

Please tell us exactly what it is that you actually want to achieve (and "I want to access the contents of the string as bytes" is _not_ what you want to achieve).
 

donaghy

macrumors member
Original poster
Aug 6, 2009
49
0
I've got a response from a webservice that i've parsed, its contains a timestamp field. I use this timestamp field when i want to update a record. To update a record I sent another request to a webservice passing the timestamp as a parameter, however I get the error cannot convert string to byte[]. The timestamp value that i store from the initial response looks something like 'AAAAAAAA1A4=' and is stored as an NSString.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,739
8,415
A sea of green
I've got a response from a webservice that i've parsed, its contains a timestamp field. I use this timestamp field when i want to update a record. To update a record I sent another request to a webservice passing the timestamp as a parameter, however I get the error cannot convert string to byte[]. The timestamp value that i store from the initial response looks something like 'AAAAAAAA1A4=' and is stored as an NSString.

Is this Java or Objective-C? I'm wondering because there is no byte[] type in Objective-C, AFAIK. Maybe you're paraphrasing the error message wrong, which fails on another count: never paraphrase error messages, always copy and paste them exactly.

What type does your webservice request need? Be specific. If it's unclear, simply post the failing code, along with the type declarations of any variables it's using.
 

donaghy

macrumors member
Original poster
Aug 6, 2009
49
0
The webservice is coded in VB.Net, its currently being used by a .net based mobile application. We are lookin to move from the .net mobile platform to an iphone app but want to maintain our .net webservice.

The webservice itself requests a username (string), password(string), Id(int), description (string) and timestamp (object). The error message is 'could not convert string to byte[]', i get the same error message when i test this directly through a .net environment against the web service.
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,565
The webservice is coded in VB.Net, its currently being used by a .net based mobile application. We are lookin to move from the .net mobile platform to an iphone app but want to maintain our .net webservice.

The webservice itself requests a username (string), password(string), Id(int), description (string) and timestamp (object). The error message is 'could not convert string to byte[]', i get the same error message when i test this directly through a .net environment against the web service.

So the error message doesn't come from your own software, but from the web service? In that case, what kind of data does the service expect? HTMP Post messages? XML? You'd need to get the documentation what the web service expects, and send exactly what it wants.
 

donaghy

macrumors member
Original poster
Aug 6, 2009
49
0
The webservice is expecting a parameter that is a Byte[], which according to msdn documentation is an 8-bit unsigned integer. The value i'm reading from the webservice is 'AAAAAAAAs00='. The exact error generated by the webservice is "Failed to convert parameter value from a string to a Byte[]". Would it be a matter of converting the value 'AAAAAAAAs00=' to an unsigned 8-bit integer? Im not aware of how the value is being encoded to achieve 'AAAAAAAAs00=', would this be something the xml response is doing as its says encoding="utf-8"?
 

donaghy

macrumors member
Original poster
Aug 6, 2009
49
0
Ok i think i've got a little further. It appears to be base64binary conversion and i think i can handle in conversion in the webservice, although if anyone knows how to convert from base64binary let me know.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,739
8,415
A sea of green
Ok i think i've got a little further. It appears to be base64binary conversion and i think i can handle in conversion in the webservice, although if anyone knows how to convert from base64binary let me know.

Google search term: base64

Wikipedia search term: base64

You can find any number of freely available base64 conversions simply by looking. To find ones for a particular computer language, add the language name to the search terms.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.