Objective C Porting

Discussion in 'iOS Programming' started by justmyself, Jan 26, 2009.

  1. justmyself macrumors member

    Joined:
    Jan 2, 2009
    #1
    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:mad:"Times" size:14.0]];
    [[NSSound soundNamed:mad:"click.wav"] play];
    [myButton setTitle:mad:"Play again?"];

    Strangely enough this doesn't work
    [instructions setStringValue:mad:"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
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    What class is 'instructions'?

    Also, 'instructions.text = ...' is the same as '[instructions setText:...]'.
     
  3. justmyself thread starter macrumors member

    Joined:
    Jan 2, 2009
    #3
    Instructions is a UILabel.
     
  4. jnic macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
  5. justmyself thread starter macrumors member

    Joined:
    Jan 2, 2009
    #5
    With much searching and experimenting the following does work

    [instructions setFont:[UIFont fontWithName:mad:"Helvetica" size:18.0]];

    Still needing help with sound though. argh... something about Audio Queue Services???

    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.
     
  6. jnic macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #6
  7. ghayenga macrumors regular

    Joined:
    Jun 18, 2008
    #7
    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.
     

Share This Page