Tag Archives: xcode

XCode Color Picker Plugin

XCode 에서 UIColor를 쉽게 생성해주는 플러그인이네요.. 보통 디자이너들이 컬러값을 지정해줘서 크게 쓸일은 없을듯 하지만.. 은근 필요할때가 또 있네요…ㅋ on GitHub here

NSThread 백그라운드 쓰레드 돌리기

프로그래밍을 하다 보면 느끼겠지만 쓰레드는 필수이다. iPhone에서 백그라운드쓰레드를 돌려보자.. Objective-c 에서는 NSThread 라는 클래스가 있다. 일단 쓰레드 처리할 함수를 만든다. -(void) myTestThread:(id)anObject { NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; //이곳에 처리할 코드를 넣는다. [autoreleasepool release]; [NSThread exit]; } 그리고 쓰레드를 호출한다. [NSThread detachNewThreadSelector:@selector(myTestThread:) toTarget:self withObject:nil]; 간단~

UI객체의 TAG 활용..

프로그램을 개발하다 보면 디자인 형태에서가 아닌 런타임 상태에서 객체를 생성해야 하는 경우가 생긴다. 즉 몇개의 객체를 생성해야할지가 실행중 결정될때 이다.. 예를들어 버튼을 200개를 생성해야 하거나 또는 등록된 사람수 를 가져와서 사람 수 만큼 버튼을 생성해야할 때 등.. 윈도우라면 뭐 다양한 방법이 있을것이다. findwindow 등… iPhone 에서는 tag 라는 꼬리표 같은 변수가 있다.. – (void)viewDidLoad {… Read More »

iPhone 스크린샷 찍기

UIGraphicsBeginImageContext(self.bounds.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

xcode iphone base64 encode/decode

첨부파일을 다운로드 받고 import 후 아래와 같이 사용 1136870320.h NSString *sourceString = @”username:password”; NSLog(@”Original string: %@”, sourceString); NSData *sourceData = [sourceString dataUsingEncoding:NSUTF8StringEncoding]; NSString *base64EncodedString = [sourceData base64Encoding]; NSLog([NSString stringWithFormat:@”Encoded form: %@”, base64EncodedString]); NSData *decodedData = [NSData dataWithBase64EncodedString:base64EncodedString]; NSString *decodedString = [[[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding] autorelease]; NSLog([NSString stringWithFormat:@”Decoded again: %@”,decodedString]);

Objective-C Http request response

NSURL *url = [NSURL URLWithString:@”https://www.google.com/accounts/ClientLogin”]; NSMutableURLRequest *loginRequest = [NSMutableURLRequest requestWithURL:url]; [loginRequest setHTTPMethod:@”POST”]; [loginRequest addValue:@”Content-Type” forHTTPHeaderField:@”application/x-www-form-urlencoded”]; [loginRequest addValue:@”application/x-www-form-urlencoded” forHTTPHeaderField:@”Content-Type”]; NSString *requestBody = [[NSString alloc] initWithFormat:@”Email=%@&Passwd=%@&service=finance&source=%@”, @”mars”, @”1234″, [NSString stringWithFormat:@”%@%d”, @”ashlux-igFinance-1.0″]]; [loginRequest setHTTPBody:[requestBody dataUsingEncoding:NSASCIIStringEncoding]]; NSHTTPURLResponse *response = NULL; NSData *responseData = [NSURLConnection sendSynchronousRequest:loginRequest returningResponse:&response error:nil]; NSString *responseDataString = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding]; NSLog(@”Response from Google: %@”, responseDataString);