Using C Arrays UInt8 MyArray[10]; MyArray[0] = 0x00; MyArray[1] = 0x01; int LengthOfMyArray = length:sizeof(MyArray);
Category: Arrays
Const Static Arrays
Create your array of values, in your .m file or before the @interface in your .h file, like this: static const UInt8 encryptionKey[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09}; Use it like this = encryptionKey[1]; while (offset >= (sizeof(encryptionKey) / sizeof(UInt8))) offset -= (sizeof(encryptionKey) / sizeof(UInt8));
Sorting Arrays
Basic Array Sort In Ascending Order [SomeArrayName sortUsingSelector:@selector(compare:)]; SomeArrayName = [SomeArrayName sortedArrayUsingSelector:@selector(compare:)]; Sorting In Descending Order NSSortDescriptor *sortOrder = [NSSortDescriptor sortDescriptorWithKey: @”self” ascending: NO]; [SomeArrayName sortUsingDescriptors:[NSArray arrayWithObject: sortOrder]]; SomeArrayName = [SomeArrayName sortedArrayUsingDescriptors:[NSArray arrayWithObject: sortOrder]]; Sorting Classes This can be used with classes that contain a varaible or object you want to sort the entire class […]
Using Arrays
Arrays in Objective-C do not contain the objects that belong to it, they hold a pointer (reference) to each object in the array. So when you use :addObject you are simply storing the address of that object inside the array. This means that you can have different types in a single array. This is a […]