As an iOS programmer I sometimes delve into C to achieve faster results (well actually for fun) and I'm struggling to modify a C-array's values inside a function call. Although I think this answer may help (Modifying a array in a function in C), I don't know where to begin in implementing it.
Currently I have:
[object.guestlists enumerateObjectsUsingBlock:^(id obj, BOOL *stop) {
NSObject *someNSObject = [NSObject new];
NSInteger array[3] = {totalIncomingMales,totalIncomingFemales,
totalIncomingGuestsCount};
[self callMethod:object withCArray:cArray];
}];
- (void) callMethod:(NSObject*) object withCArray:(NSInteger*) cArray {
// do something with that object
NSInteger totalIncomingMales = cArray[0],
totalIncomingFemales = cArray[1],
totalIncomingGuestsCount = cArray[2];
// modify these integers internally so that the C-array passed in is also modified
}
Obviously this passes a pointer and therefore doesn't modify the value. I tried replacing the NSinteger * with NSInteger ** and making, e.g. totalIncomingMales = * cArray[0], but alas I wasn't able to pass the c-array as a parameter (even with an ampersand).
Some useful material and potentially a solution to this would be much appreciated!
arrayOfIntegerscome from?