Professional Documents
Culture Documents
Introduction
About Me
Author/Co Author of 13 books on .NET programming Work on Architecture & Research Team (this means I get to play with all the cool new stuff) Presented at Apples WWDC on Cocoa and iPhone Programming
Objective-C
Objective-C isnt like C, it IS C Object-Oriented Smalltalk-inspired Dynamic (runtime dispatching vs. compile-time)
Message Passing
[(receiver) (message)];
[myView setTransform:CGAffineTransformMakeRotation(angle)];
Delegate Pattern
@interface MyViewController : UIViewController <UIAccelerometerDelegate> { } @end [[UIAccelerometer sharedAccelerometer] setDelegate:self];
UIKit
AppDelegate
Main entry point to application Analagous to a graphical void main(...) Holds reference to and initializes rst View Controller Many samples use AppDelegate for global variables Dont do this! Its bad! (Seriously...)
UIKit
View Hierarchy
Views are composited First subview added is in back Subsequent subviews added are closer to user (higher layer number/Z index) Using multiple layers of views and various transparency effects, you can create stunning UIs easily.
UIKit
MVC
iPhone and Mac development using Xcode strongly encourages (requires, actually) MVC pattern Model: state objects Caution: some samples use db-aware state objects (bad habit!) OS X desktop: Model objects can be Core Data View - UIView and subclasses Controller - View Controllers and subclasses Views render, Controllers act and respond, Models store and expose data.
UIKit
Built-in Controllers and Views
UIViewController UINavigationController UITableViewController UITabBarController UIImagePickerController
UIKit
Animation (manual)
// create the path for the keyframe animation CGMutablePathRef thePath = CGPathCreateMutable(); CGPathMoveToPoint(thePath,NULL,15.0f,15.f); CGPathAddCurveToPoint(thePath,NULL, 15.f,250.0f, 295.0f,250.0f, 295.0f,15.0f); CAKeyframeAnimation *theAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"]; theAnimation.path=thePath; // create an animation group and add the keyframe animation CAAnimationGroup *theGroup = [CAAnimationGroup animation]; theGroup.animations=[NSArray arrayWithObject:theAnimation]; // set the timing function for the group and the animation duration theGroup.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; theGroup.duration=15.0; // release the path CFRelease(thePath); // adding the animation to the target layer causes it // to begin animating [theLayer addAnimation:theGroup forKey:@"animatePosition"];
UIKit
Animation (automatic)
myView.frame = CGRectMake(10,10,150,100);
Resources
Apple http://developer.apple.com/iphone https://devforums.apple.com/community/iphone (need SDK account) http://developer.apple.com/iphone/library/documentation/Xcode/Conceptual/xcode_quick_tour_iphoneos/000-Introduction/ chapter_1_section_1.html Books iPhone Developers Cookbook Objective-C 2.0 WWDC Videos (either need to have attended, or can buy for $200) Me Email: alothien@gmail.com Blog: http://dotnetaddict.dotnetdevelopersjournal.com
Code Demo
Hello World, but this one doesnt suck.