Difference between revisions of "Objective-C Sandbox"

From Wikicliki
Jump to: navigation, search
(Traces)
(The C Comparisions are lost upon me but maybe at a later date this will make more sense)
Line 46: Line 46:
 
=== The C Comparisions are lost upon me but maybe at a later date this will make more sense ===
 
=== The C Comparisions are lost upon me but maybe at a later date this will make more sense ===
  
getMovie -- one method
+
<pre>getMovie //one method
getMovieRatingForMovie: thatHasAnActor -- another method
+
getMovieRatingForMovie: thatHasAnActor //another method
  
 
COMPARED TO C which would be like
 
COMPARED TO C which would be like
  
movieName(char * movieName, char * actorName);
+
movieName(char * movieName, char * actorName);</pre>

Revision as of 03:55, 2 March 2013

A haphazardly conducted class

Hello World

  • Open Xcode
  • You'll see templates - select single view
  • Create new "Hello World" - check local git if you want versioning - select a folder and you will have created the project
  • Uncheck storyboards, uncheck include unit tests, select universal
  • Iosoptions1.png
  • Check out the views button on top right hand corner
  • Nav on left, editor in center, utility on right, debug at bottom
  • Iosoptions.png
  • Uncheck Autolayout:

Iosoptions2.png

  • Select some tiny box (3rd on bottom row), drag a label to the panel, click on top row 4th button to see the label editing options, type hello world, and then press run.

Iosoptions3.png Iosoptions5.png

  • Published a hello world screen in the simulator

Iosoptions4.png


Traces

inside viewcontroller.m

    NSLog(@"trace");
    NSDate *dateObj = [[NSDate alloc] init];
    NSLog(@"date is %@", dateObj);
  • Syntax: MyNotes is the class:
MyNotes *notesObj = [[MyNotes alloc] init];
// pass single argument
[notesObj createNewNoteWithTItle:@"First Note"];
// pass multiple arguments
[notesObj createNewNoteWithTItle:@"First Note" andDescription:@"I Love ObjectiveC"];
  • Instructor is trying to say these are two methods.
@implementation Movie : NSObject
-(void)playMovie:(NSString *)movieName;
-(void)getMovieRatingForMovie:(NSString *)movieNamethatHasAnActor:(NSString *)actorName;
@end

The C Comparisions are lost upon me but maybe at a later date this will make more sense

getMovie //one method
getMovieRatingForMovie: thatHasAnActor //another method

COMPARED TO C which would be like

movieName(char * movieName, char * actorName);