hatferro.blogg.se

Build app interface builder
Build app interface builder






build app interface builder

build app interface builder

When you're asked for a name, call it 'EditController' - this is what we'll be using to edit to-do list items, and Xcode will create 'Edit Controller.h', 'EditController.m' and 'EditController.xib' for us. Select 'UIViewController subclass' and leave the checkboxes below deselected, except for the one marked 'With XIB for user interface' - that's the bit that lets us drag and drop user interface elements as we need them. Right-click 'Classes' and choose 'Add | New file'. When a new item is added, we create it as a mutable string and add it to our collection, so all we need now is a simple user interface to allow editing of items. Only one thing remains: we need to be able to edit to-do list items. We're on the last leg of our project now. INTERFACE BUILDER: The UI is split across four windows, so if you were planning to use a 13in MacBook for your coding, you might want to reconsider It's still not useful though, because you can't actually edit anything - let's do that next.

build app interface builder

If you run the app now, you can add new rows by tapping the button. Note that all NSStrings in Objective C must start with to distinguish them from plain C character constants. Put this new method somewhere in your 'RootViewController.m' file:Īs you can see, to add an object to an NSMutableArray you just need to use the 'addObject' method, although what follows might confuse you a bit - it creates a new NSMutableString out of a plain text string. We don't actually have the 'addTapped' method yet, but it's not complicated - all it needs to do is create a new 'NSMutableString' with some default text in, then reload the table so that it appears.

#BUILD APP INTERFACE BUILDER CODE#

That single line of code creates a new button with a '+' symbol and sets it up to call 'addTapped' in 'RootViewController.m' when it's tapped, then add its to the navigation bar. It won't be freed, though, because the 'leftBarButton' will retain it. 'autorelease' decrements the use count of the button. 'Target:self' means that when the button is tapped, the message saying so will be passed to selector(addTapped)' is how 'RootViewController.m' will be told the button was tapped - the 'addTapped' method will be run. This means it will be displayed with a '+' symbol. 'UIBarButton Item alloc' creates the new button, and 'initWithBarButtonSystem Item' creates the button using the 'UIBarButtonSystemItemAdd' style.








Build app interface builder