2009年4月21日 星期二

setHTTPBodyStream

remember to set "Content-Length"

2009年4月8日 星期三

life cycle of iphone app

1.
main.m:
main() --> call UIApplicationMain


2.
application delegate
applicationDidFinishLaunching is called

3.
loading app's main nib file
In info.plist, key NSMainNibFile defines main nib file name
main nib file usually contains a window object, app delegate object, etc





2009年4月4日 星期六

create view controller

1. In xcode, create view controller MyViewController.m

2. For IB, create MyView.xib

3. In IB, set file's owner as MyViewController
connect file owner's view outlet to view window

2009年4月3日 星期五

add view method

method 1: with interface builder
1. create a subclass of UIView: newView

2. create a view xib: newView.xib

3. In IB, set view's class as newView

4. In xCode, add new view
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"newView" owner: self
options:nil];
UIView *view = [nib objectAtIndex: 1];
[self.view addSubview:view];
note: use the index for array of nib to get specific object, such as view

method 2: all within xCode:
CGRect newViewFrame = CGRectMake(0, 0, 50, 50);
UIView *newView = [[UIView alloc] initWithFrame:newViewFrame];
newView.backgroundColor = [UIColor blueColor];
[self.view addSubview:newView];

2009年4月2日 星期四

find memory leak with clang

  • Make sure the project default settings are “debug” and “simulator”
  • Close Xcode
  • open a terminal window and “cd” to the project directory
  • run rm -rf /tmp/scan-build*
  • run rm -rf build/;scan-build --view xcodebuild
  • Open Xcode and fix errors