how do we write this vb.net code in objective c
Code:dim b = New Byte() {&HAA, &HFF, &HAA}
typedef unsigned char BYTE;
BYTE b[3] = {0xAA,0xFF,0xAA};
Code:typedef unsigned char BYTE; BYTE b[3] = {0xAA,0xFF,0xAA};
would be one way. Given no other context...
Since this looks like an RGB triplet. Something else is probably better...
B
Sckclnt.Delimiter = New Byte() {&HAA, &HFF, &HAA}
#define Delimiter @"1234"
NSMutableData* pl = [[NSMutableData alloc] init];
[pl appendData:data];
NSData *delimiter = [Delimiter dataUsingEncoding:NSUTF8StringEncoding];
[pl appendData:delimiter];
Take a break and read these two fine articles:
http://mattgemmell.com/2008/12/08/what-have-you-tried/
http://www.mikeash.com/getting_answers.html
Then please rephrase your question with an appropriate amount of context.
B
i have updated my last answer please read
how do we write this vb.net code in objective c
Code:dim b = New Byte() {&HAA, &HFF, &HAA}
const unsigned char bytes[] = {0xFF, 0xAA, 0xFF};
NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)];
NSLog(@"%@", data);
Just rename your source file from .m to .mm
Not necessary. A .m file contains Objective-C source. Since Objective-C is a pure superset of C, any .m file can contain pure C and be perfectly valid.
A .mm file is Objective-C++. Since C++ is not a pure superset of C, then pure C will actually be compiled as Objective-C++ in a .mm file.
Almost, but not quite:C++ is a pure superset of C.
Almost, but not quite:
http://en.wikipedia.org/wiki/C++#With_C
C++ is often considered to be a superset of C, but this is not strictly true.[39] Most C code can easily be made to compile correctly in C++, but there are a few differences that cause some valid C code to be invalid or behave differently in C++.http://en.wikipedia.org/wiki/Objective-C#Syntax
One commonly encountered difference is that C allows implicit conversion from void* to other pointer types, but C++ does not (for type safety reasons). Another common portability issue is that C++ defines many new keywords, such as new and class, that may be used as identifiers (e.g. variable names) in a C program.
Objective-C is a thin layer on top of C, and moreover is a strict superset of C; it is possible to compile any C program with an Objective-C compiler, and to freely include C code within an Objective-C class.Note that Objective-C avoids the keyword collision problem by prefixing new keywords with @, as in @interface, @protocol, etc.
There are valid C programs that won't compile as C++ until certain changes are made, such as implicit conversion of void* being changed to explicit conversion (i.e. explicit type-cast).
Forgive my earlier use of "pure superset"; I meant to write "strict superset". I don't think this changes anything, since a "pure superset" still implies (I think) that every valid C program is also a valid C++ program, and as noted already, this isn't strictly true.
Isn't the typing a compiler setting?