iosobjective-cobjectidobject-identity

Using one method in place of many


I am trying to learn Objective-C for iOS. I have tried researching this, but I must not be using the right keywords.

I have several labels that are simply named, Label1, Label2, etc. I also have a ton of code that basically looks the same except the Label# changes. Can I build one method and pass the number to it and shrink my app significantly?


Solution

  • You probably want to have those object in an NSArray or another type of collection. Then you will be able to loop through the content and do the same operation on each element.