The error i’mg etting is ‘Assignment makes pointer from integer without cast’. Here is my code:
typedef enum {
UIIconTypeCustom = 0,
UIIconTypeStandard,
} UIIconType;
.
-(void)addIconWithType:(UIIconType *)iconType {
...
}
And this is the line it has a problem with:
[iconView addIconWithType:UIIconTypeStandard];
Your method has a pointer as parameter:
and you are passing it an integer:
Change your method definition to this:
Also, don’t define your own enums, classes, or anything else with the prefix
UI. That prefix is reserved by Apple and you will cause pointless headaches for yourself by using it. Use your initials or the initials of your company or of the project.The reason that almost all Objective-C methods have parameters with the asterisk is that when you are using an object, the object stays in one place in memory, and you just pass around a pointer to that object. That’s what
MyClass *indicates — a pointer to an object of typeMyClass. The pointer gives you the address of the object’s location in memory, so that you can avoid having to move the entire object from place to place when you want to use it. In this case, the thing that you want to pass to the method isn’t an object, but a simple integer, so you can just pass the integer directly.