-Xcode3.2.3과 SDK4로 업그레이드 후, 기존 앱 업그레이드 하는 법-
XCode3.2.3 과 SDK4로 버전업한 후, 기존 앱을 업그레이드 할 때 간단한 Tip 입니다.
1. XCode3.2.3과 SDK4로 업그레이드 한다. 별도로 기존 XCode 3.1 버전을 따로 보관할 필요가 없습니다.
2. 기존 앱을 새 XCode3.2.3에서 연다.
3.Group & Files를 right click -> Get Info 후
  3-1.General Tab 에서
Project Format 을 Xcode 3.2-compatible 로 바꾼다.
 3-2.Build Tab 에서
 Base SDK를 iPhone Device 4.0(배포시), 혹은 iPhone Simulator 4.0(테스트시) 로 바꾼다
 iPhone OS Deployment Target 을 iPhone OS 3.0 (즉 지원하고자 하는 하위버전으로) 로 바꾼다.


출처 : http://blog.naver.com/PostView.nhn?blogId=megaissue&logNo=140111719543
Posted by 오늘마감
XCODE2010.11.07 01:04
[아이폰 앱 개발] customcell사용시 메모리효율적이용, 즉 재사용시키려면 해야할 것.

The UITableView class is a wonder of efficient memory management, if you use it correctly.

Here’s the standard template code that Xcode generates when you create a subclass of UITableViewController:

  1. // Customize the appearance of table view cells.  
  2. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  
  3.   
  4.     static NSString *CellIdentifier = @"Cell";  
  5.   
  6.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];  
  7.     if (cell == nil) {  
  8.         cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];  
  9.     }  
  10.   
  11.     // Set up the cell...  
  12.   
  13.     return cell;  
  14. }  

The keys here are the CellIdentifier variable and the call to dequeueReusableCellWithIdentifier, which enable the iPhone OS to reuse existing instances of UITableViewCell whenever possible.

(Don’t create a unique reuse identifier for each row as I’ve seen some developers do. Yes, it’s much easier to deal with asynchronous download of images for each row if you know how to uniquely identify the cell, and you know that the cell is still in memory. But that totally defeats the efficient memory management that UITableView is capable of.)

Under normal circumstances a UITableView will create one instance of a UITableViewCell per row that is visible on the screen. As you scroll, the cell instance that just rolled off the screen will be reused for the cell that is about to appear.

To verify that this memory management is working as it should, add a log statement each time a new cell is created:

  1. if (cell == nil) {  
  2.     DLog(@"creating a new cell");  
  3.     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];  
  4. }  

When you run your app and start scrolling your table view, you should not see any creation of cells beyond the initial list (plus one). If you see “creating a new cell” log statements scrolling off the screen as you scroll the table view, you’ve got a problem.

If you just follow the standard Xcode template above, you should be fine. However if you’re loading a Nib for a custom table view cell layout using Apple’s recommended way, there’s an important detail you must not forget. (Tip of the hat to Jeff LaMarche for inspiring this blog post.)

Here’s the typical NIB loading code from Apple:

  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {  
  2.     static NSString *CellIdentifier = @"CheckedTableViewCell";  
  3.   
  4.     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];  
  5.     if (cell == nil) {  
  6.         DLog(@"creating a new cell");  
  7.   
  8.         // Load the table view cell from a Nib file.  
  9.         [[NSBundle mainBundle] loadNibNamed:@"CheckedTableViewCell" owner:self options:nil];  
  10.   
  11.         // The checkedTableViewCell property is just a temporary placeholder for loading the Nib.  
  12.         cell = checkedTableViewCell;  
  13.   
  14.         // We don't need this anymore, so set to nil.  
  15.         self.checkedTableViewCell = nil;  
  16.     }  
  17.   
  18.     return cell;  
  19. }  

The key here is that the CellIdentifier value must also be entered into Interface Builder, like this:

If you don’t do this, then UITableViewCells will not be reused. (A telltale sign of this is that you’ll see lots of “creating a new cell” log messages.) There is no compiler or runtime warning if you fail to enter this critical piece of information into Interface Builder. So that log statement can be a useful warning.

http://iphoneincubator.com/blog/
Posted by 오늘마감
XCODE2010.11.06 21:11
[아이폰 앱 개발] cancel alert

// Show an alert if "Appleseed" is not in Contacts

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" 

message:@"Could not find Appleseed in the Contacts application" 
  delegate:nil 
  cancelButtonTitle:@"Cancel" 
  otherButtonTitles:nil];

[alert show];

[alert release];

Posted by 오늘마감
XCODE2010.11.06 17:27
[아이폰 앱 개발] UIBarButtonItem을 viewDidLoad에서 만들고 숨기기

-(void)viewDidLoad{

UIBarButtonItem *temporaryBarButtonItem = [[UIBarButtonItem alloc] init];

temporaryBarButtonItem.title = @"Back";

self.navigationItem.backBarButtonItem = temporaryBarButtonItem;

[temporaryBarButtonItem release];

...

}

현재뷰에서 다음뷰갈때 위에서 만든 barButton숨기기



- (void)showDetails:(id)sender

{

    // the detail view does not want a toolbar so hide it

    [self.navigationController setToolbarHidden:YES animated:NO];

    

    [self.navigationController pushViewController:self.detailViewController animated:YES];

}

Posted by 오늘마감
XCODE2010.11.06 12:30
[아이폰 앱 개발] 뷰로딩시 이전페이지에서 넘어온 ToolBar숨기기

- (void)viewDidAppear:(BOOL)animated

{

    // bring back the toolbar

    [self.navigationController setToolbarHidden:NO animated:NO];

}

Posted by 오늘마감
XCODE2010.11.06 08:06
[아이폰 앱 개발] 객체의 클래스타입 일치여부 체크

Car myCar =[[Car alloc]init]; 


[활용법]  

if ([myCar isKindOfClass:[Car class]]){


}else{


    

       

Posted by 오늘마감
XCODE2010.11.06 04:21
[아이폰 앱 개발] 위치정보요청 CLLocationManager
헤더에 우선 CLLocationManagerDelegate를 추가해야하고, CoreLocation.frameWork추가

//위치정보얻는데 보통 바로 얻으나, 지역에 따라 느리면, 수초걸릴 수도있다.

CLLocationManager *locationManager=[[CLLocationManager alloc]init];
//정밀도지정 // 정밀도높일 수록 전력소모 증가
locationManager.delegate=self;
//return값 double, 10미터오차범위 현재위치결정
locationManger.desiredAccuracy=kCLLocationAccuracyBest;

//위치바뀔때마다 locationManager는 델리게이트에통보
//보통 필터세팅된 거리이탈시 통보// 1000미터범위 이탈시 통보세팅
locationManager.distanceFilter=1000.f

//필터해제시 locationManager.distanceFilte=KCLDistanceFilterNone;

//locationManager동작시키기
[locationManager startUpdatingLocation];
//stop
[locationManager stopUpdatingLocation];

//Error noti
//locationManager:didFailWithError:

-(void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error{
NSSString *errType=(error.code==KCLerrorDenied)?@"Access Denied":@"UnKnown Error";

UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Error getting Location"

message:errorType
delegate:nil
cancelButtonTitle:@"okay"
otherButtonTitles:nil];
[alert show];
[alert release];

}


//이동거리측정(최신버젼에서 depricated된듯한데 확인필요)

CLLocationDistance distance =[newLocation getdistanceFrom:startingPoint];
NSString *distancesString=[[NSString alloc]initWithFormat:@"%gm",distance];
distanceTraveledLabel.text=distancceString;
[distanceString release];


alert
Posted by 오늘마감
XCODE2010.11.06 01:04
[아이폰 앱 개발] NSString split하기
<form name="search" action="http://www.idev101.com/search.html" method="POST">

Split a String into an Array

</form>

Split a string into an array of strings by using NSString's componentsSeparatedByString:

NSString *myString = @"This is a test"; NSArray *myWords = [myString componentsSeparatedByString:@" "]; // myWords is now: [@"This", @"is", @"a", @"test"]

If you need to split on a set of several different characters, use NSString's componentsSeparatedByCharactersInSet:

NSString *myString = @"Foo-bar/blee"; NSArray *myWords = [myString componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"-/"] ]; // myWords is now: [@"Foo", @"bar", @"blee"]

The separator string can't be blank. If you need to separate a string into its individual characters, just loop through the length of the string and convert each char into a new string:

NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[myString length]]; for (int i=0; i < [myString length]; i++) { NSString *ichar = [NSString stringWithFormat:@"%c", [myString characterAtIndex:i]]; [characters addObject:ichar]; }

http://www.idev101.com/code/Objective-C/Strings/split.html
Posted by 오늘마감
[아이폰 앱 개발] NSString 스트링포맷 와일드카드써서 파일명바꾸기

int month;


for(month=1;month<13;month++){

NSString *imageName = [NSString stringWithFormat:@"2010_%d.png", month];

}


Posted by 오늘마감
[아이폰 앱 개발] Display Images

Display Images

Display an image anywhere on the screen, without using UI Builder. You can use this for other types of views as well.
CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f); UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; [myImage setImage:[UIImage imageNamed:@"myImage.png"]]; myImage.opaque = YES; // explicitly opaque for performance [self.view addSubview:myImage]; [myImage release];
Posted by 오늘마감

티스토리 툴바