Skip to content

Instantly share code, notes, and snippets.

View ejknapp's full-sized avatar

Eric Knapp ejknapp

View GitHub Profile
//
// OutletActionDemoViewController.h
// OutletActionDemo
//
// Created by Eric Knapp on 6/15/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import <UIKit/UIKit.h>
//
// OutletActionDemoViewController.m
// OutletActionDemo
//
// Created by Eric Knapp on 6/15/10.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import "OutletActionDemoViewController.h"
Steps for making an Action (In Xcode 3!)
1. Open the .h file of the view controller.
2. After all properties, create a method declaration
with "IBAction" as return value.
-(IBAction)clickTheButton;
3. Copy the method declaration and switch to .m file.
4. Paste into .m file, remove semi-colon, add braces.
5. Code as needed.
6. Save .h and .m files.
Set the text of a UILabel from code.
1. Open the view controller .m file.
2. Uncomment the "viewDidLoad" method.
3. Set the text property of the label.
self.myLabel.text = @"Hello, world.";
Steps for making Outlets (in Xcode 3!)
1. Open the view controller .h file. (In Class group.)
2. Add a property
1. Make an instance variable of UILabel type.
UILabel *myLabel;
2. Make a property for the ivar.
3. Make property an IBOutlet
@property (nonatomic, retain) IBOutlet UILabel *myLabel;
//
// Dog.m
// FirstCL
//
// Created by Eric Knapp on 6/14/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "Dog.h"
//
// Dog.h
// FirstCL
//
// Created by Eric Knapp on 6/14/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
Steps to create an outlet with a class I wrote.
Example for SomeShinyClass
In the .h file:
1. @class SomeShinyClass;
2. Instance variable
• SomeShinyClass *someShiny;
// Remove words
-(void)removeWordAtIndex:(NSUInteger)index {
[self.wordList removeObjectAtIndex:index];
[self saveWordListToFileSystem];
}
// Deserialize json and add to Core Data
#import "CJSONDeserializer.h"
#import "CJSONSerializer.h"
/*
The JSON lib is found here: http://code.google.com/p/json-framework/
*/
- (void)processNewMessagesData:(NSString *)jsonMessages {