In order to make older files capable to compiled under ARC, set the switch -fno-objc-arc under Build phase.
But only .m files listed which I can add -fno-objc-arc.
but I have some .h files that caused ARC errors too. I need to set that switch to those .h files. but I don't see them under Build phase.
So, how do I set the switch for the .h files?
Here's a sample of .h file
\
__object__=__array__->arr[0]; for(NSUInteger i=0, num=__array__->num; i<num; i++, __object__=__array__->arr[i]) \
typedef struct ccArray {
NSUInteger num, max;
id *arr;
} ccArray;
/** Allocates and initializes a new array with specified capacity */
static inline ccArray* ccArrayNew(NSUInteger capacity) {
if (capacity == 0)
capacity = 1;
ccArray *arr = (ccArray*)malloc( sizeof(ccArray) );
arr->num = 0;
arr->arr = (id*) malloc( capacity * sizeof(id) );
arr->max = capacity;
return arr;
}
static inline void ccArrayRemoveAllObjects(ccArray *arr);
/** Frees array after removing all remaining objects. Silently ignores nil arr. */
static inline void ccArrayFree(ccArray *arr)
{
if( arr == nil ) return;
ccArrayRemoveAllObjects(arr);
free(arr->arr);
free(arr);
}
/** Doubles array capacity */
static inline void ccArrayDoubleCapacity(ccArray *arr)
{
arr->max *= 2;
id *newArr = (id *)realloc( arr->arr, arr->max * sizeof(id) );
// will fail when there's not enough memory
NSCAssert(newArr != NULL, @"ccArrayDoubleCapacity failed. Not enough memory");
arr->arr = newArr;
}
/** Increases array capacity such that max >= num + extra. */
static inline void ccArrayEnsureExtraCapacity(ccArray *arr, NSUInteger extra)
{
while (arr->max < arr->num + extra)
ccArrayDoubleCapacity(arr);
}
/** shrinks the array so the memory footprint corresponds with the number of items */
static inline void ccArrayShrink(ccArray *arr)
{
NSUInteger newSize;
//only resize when necessary
if (arr->max > arr->num && !(arr->num==0 && arr->max==1))
{
if (arr->num!=0)
{
newSize=arr->num;
arr->max=arr->num;
}
else
{//minimum capacity of 1, with 0 elements the array would be free'd by realloc
newSize=1;
arr->max=1;
}
arr->arr = (id*) realloc(arr->arr,newSize * sizeof(id) );
NSCAssert(arr->arr!=NULL,@"could not reallocate the memory");
}
}
(id*) causing the issue.