View Full Version : Objective C Porting
justmyself
Jan 27, 2009, 01:19 AM
Wanting to develop for the iPhone I thought it would be good practice to develop it on the Mac first on 10.4 assuming I could cut and past most of the code. I decided to start simple with a high / low game. However I found several things that don't seem to work.
Here is the code that doesn't work.
[instructions setFont:[NSFont fontWithName:@"Times" size:14.0]];
[[NSSound soundNamed:@"click.wav"] play];
[myButton setTitle:@"Play again?"];
Strangely enough this doesn't work
[instructions setStringValue:@"Pick of a number between 1 and 10"];
however, this does
instructions.text=@"Pick a number between 1 and 10";
all the good stuff like setIntValue and setStringValue doesn't work. What's going on? Any help would be appreciated.
Thank you
dejo
Jan 27, 2009, 02:04 AM
What class is 'instructions'?
Also, 'instructions.text = ...' is the same as '[instructions setText:...]'.
justmyself
Jan 27, 2009, 02:29 AM
What class is 'instructions'?
Also, 'instructions.text = ...' is the same as '[instructions setText:...]'.
Instructions is a UILabel.
jnic
Jan 27, 2009, 05:16 AM
UILabel won't respond to setStringValue. Class reference from the docs. (https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UILabel_Class/Reference/UILabel.html)
justmyself
Jan 27, 2009, 05:46 AM
With much searching and experimenting the following does work
[instructions setFont:[UIFont fontWithName:@"Helvetica" size:18.0]];
Still needing help with sound though. argh... something about Audio Queue Services???
UILabel won't respond to setStringValue. Class reference from the docs.
Apples docs have always been difficult for me. I learn best with small simple examples. I'm working on it though. I did however find that the iPhone has a very limited set of fonts. Guess my only work around is an array of pictures of text. Crazy.
jnic
Jan 27, 2009, 06:57 AM
I did however find that the iPhone has a very limited set of fonts. Guess my only work around is an array of pictures of text. Crazy.
List of supported fonts: http://daringfireball.net/misc/2007/07/iphone-osx-fonts
Loading custom fonts: http://forums.macrumors.com/showthread.php?t=569311
ghayenga
Jan 27, 2009, 01:20 PM
Still needing help with sound though. argh... something about Audio Queue Services???
If all you need to do is *play* sound files then I would recommend using the AVAudioPlayer class from the AVFoundation framework. Audio Queue Services is very powerful, but very awkward to use and overkill if you don't need all that power.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.