how to extract only the 1st 2 bytes of NSString in Objective-C for iPhone programming
Posted
by suse
on Stack Overflow
See other posts from Stack Overflow
or by suse
Published on 2010-04-23T06:50:55Z
Indexed on
2010/04/23
6:53 UTC
Read the original article
Hit count: 426
objective-c
Hello,
1) How to read the data from read stream in Objective-C, Below code would give me how many bytes are read from stream, but how to know what data is read from stream?
CFIndex cf = CFReadStreameRead(Stream, buffer, length);
2) How to extract only the 1st 2bytes of NSString in Objective-C in iPhone programming. For Ex: If this is the string
NSString *str = 017MacApp;
1st byte has 0 in it, and 2nd byte has 17 in it.
how do i extract o and 17 into byte array?
I know that the below code would give me back the byte array to int value.
((b[0] & 0xFF) << 8)+ (b[1] & 0xFF);
but how to put 0 into b[0] and 17 into b[1]?
plz help me to solve this.
© Stack Overflow or respective owner