I know how to fix the problem that I am going to describe, however I am a little puzzled by why the code script works in the iOS simulator, but not on my iPad.
I have a method that checks various properties and then sets the background color of CALayer depending on the state of the property. The following code is similar to my color assignment method:
The above code works without problems in the simulator. However, when I launch the application on my iPad, it crashes with the purpose of backgroundColor .
I can fix this by getting rid of the CGColor variable and assigning the background color directly in my switch / case statement, and about what I plan to do.
However, I am curious. Why does this work in one environment and not in another?
UPDATE
A couple of things. First, it's worth mentioning that this is an ARC project using Xcode 4.2 targeting iOS devices 5. Also, my color assignment code is not exactly what it looks like, because I have a number of definitions that I use for setting these colors because they are listed throughout my application.
Here are some of the #define :
#define BLUE [UIColor colorWithRed:8.0/255.0 green:80.0/255.0 blue:150.0/255.0 alpha:1.0].CGColor #define GREEN (UIColor.blueColor.CGColor)
I tried to simplify my code because the compiler should replace refs with my references to my definitions. However, it is worth mentioning just in case.
Rlh
source share