View Full Version : Get UIButton Reference Outlet and compare UIColor

Nov 19, 2008, 10:52 PM
I have two questions bugging me as a still newb iPhone programmer.

One: I have a grid of buttons set up for an app and I want to be able to get the title of a buttons outlet reference when the button is clicked on. The reason is I have an array of numeric data and an array of my IBOutlets. During view load, I am able to run through the array of data and outlets side by side and plug the relevant data in for each title and it works great. But when I run my touch down method that I linked, I'm having trouble figuring out which grid item was touched so that I know which spot in my array to modify with new data. Is there a way in code to get the outlet title or is there a better way to do this?

Two: Is it possible to compare two UIColors? For instance comparing [selected currentTitleColor] to [UIColor blackColor] to see if they're equal where the variable selected is a UIButton?

Thanks in advanced!


Nov 20, 2008, 04:41 AM
1. Try button.tag; it's an integer which you'll find under the Identity Inspector in IB as "Object ID".

2. Try color.CGColor. You'll get a CFType (CGColorRef) which you can compare with CFEqual (https://developer.apple.com/iphone/library/documentation/CoreFoundation/Reference/CFTypeRef/Reference/reference.html#//apple_ref/c/func/CFEqual).