PDA

View Full Version : Help with objective-c with xcode




TheCandyMan
Jul 6, 2009, 08:22 PM
I am quite new to the whole Objective-C thing and pretty much to programming in general. I am currently writing a TicTacToe app. There are two things I need help with as of now and could possibly grow to many more in the future.

#1
I have the Preferences button in the main menu open up a new window nib name "PreferenceController" and I make a subclass of NSWindowController named "preferenceController" and I want to use a button at the bottom close the window. I really have no idea how to go about doing that. Help would be appreciated.

#2
I want to make one function call another one. I could go with out this but copy and pasting it nine times just seems like some ugly coding.



larkost
Jul 7, 2009, 01:37 AM
#1

You just need to create a method in your controller to handle this and in that method call [self close]. Then you create a button in the interface and wire it up to that method. If any of that does not make sense, then you need to go back and go through whatever Cocoa tutorial you are working through.

#2

This should be covered in whatever you are using to learn Cocoa. If you are calling Obj-C style methods then it is [self methodname] (or more complicated if there are variables to pass in), or you can use a straight-c method. Either way this should be covered in the tutorials you are working through.

GorillaPaws
Jul 7, 2009, 10:27 AM
I want to use a button at the bottom close the window

Can you think of any other app that has a "close" button on the bottom of its preferences window? I think you might want to re-think your UI a bit.