tags:

views:

11

answers:

1

How is it possible create a reference for an uibutton to check if it was pressed and do something like make the value for that button true in order to be able to use that value later on. I heard of ivars but i havent seen any documentation on how to use them and im not sure if they would work for my ibaction uibutton...

A: 

This is really a fundamental question and a full explanation will take along time.

Basically, you need to understand the concept of MVC (Model-View-Controller). In this case, the "View" will be your UIButton created in Interface Builder. It needs to have a target/action setup to point to some "Controller". This will be a custom class you design that performs some action when the UIButton is released. This controller can also track finger up/down/move/drag and what not. This Controller will store the fact the button was pressed in a "Model" class.

Here is some more reading: http://developer.apple.com/iphone/library/documentation/general/conceptual/devpedia-cocoacore/MVC.html

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html

In the simplest cases, this can be done with Core Data and IB without writing any code and simply making connections.

Steven Noyes