//img에 현재 화면이 캡쳐 된다.

UIImage *img;

UIGraphicsBeginImageContext(self.view.frame.size);

GContextRef context = UIGraphicsGetCurrentContext();

[self.view.layer renderInContext:context];

img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

'컴퓨터 > 아이폰' 카테고리의 다른 글

페이지 넘기는 효과  (0) 2011.12.15
Gesture 인식 샘플  (0) 2011.12.15
String -> MD5(암호) 변환 샘플  (0) 2011.12.15
아이폰에서 주소록 가져오기.  (0) 2011.12.15
SMS보내기  (0) 2011.12.15
      
Posted by k_ben


-(NSString*) md5:(NSString*)srcStr

{

const char *cStr = [srcStr UTF8String];

unsigned char result[CC_MD5_DIGEST_LENGTH];

CC_MD5(cStr, strlen(cStr), result);

return [NSString stringWithFormat:

@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",

result[0],result[1],result[2],result[3],result[4],result[5],result[6],result[7],

result[8],result[9],result[10],result[11],result[12],result[13],result[14],result[15]];

}

 

      
Posted by k_ben


ABAddressBookRef addressBook = ABAddressBookCreate();

CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);

CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);


friend_info = [[NSMutableArray alloc]init]; 

//===================================================//

// 저장된 구조체를 돌면서 해당 데이터를 추출해 옵니다.

//===================================================//


for (int i = 0; i < nPeople ; i++) {

ABRecordRef ref = CFArrayGetValueAtIndex(allPeople, i);

CFStringRef firstName = ABRecordCopyValue(ref, kABPersonFirstNameProperty);

CFStringRef lastName = ABRecordCopyValue(ref, kABPersonLastNameProperty);


NSString *name = [NSString stringWithFormat:@"%@ %@", (lastName != nil) ? (NSString *)lastName : @"" ,(firstName != nil) ? (NSString *)firstName : @""];

if (name == nil) {

return;

}

// 이메일 리트를 구한다.

ABMultiValueRef emails = ABRecordCopyValue(ref, kABPersonEmailProperty);

// 이메일 리스트가 존재하지 않으면

if(ABMultiValueGetCount(emails) <= 0) { // the selected contact has no attached email address

[self dismissModalViewControllerAnimated:YES];

}

else//if(ABMultiValueGetCount(emails) == 1) { // the selected contact has exactly one email address

for(int i=0; i<ABMultiValueGetCount(emails); i++){

CFStringRef email = ABMultiValueCopyValueAtIndex(emails, i);

NSString *emailString = (NSString *) email;

//self.emailList.text = [self.emailList.text stringByAppendingString:[NSString stringWithFormat:@"%@ ", emailString]];

//NSLog(@"email = %@", emailString);

//이메일이 있는 사람들만 저장하도록 합니다.

if(emailString == nil){

}else {

NSDictionary *info = [[NSDictionary allocinitWithObjectsAndKeys:

  name, @"NAME", emailString, @"EMAIL"kNotSelectTableCell@"CHECK"nil];

email_person_cnt++;

[friend_info addObject:info];

[info release];

}

[emailString release];

[self dismissModalViewControllerAnimated:YES];

}

}

ABMultiValueRef phones = ABRecordCopyValue(ref, kABPersonPhoneProperty);

if(ABMultiValueGetCount(phones) <= 0) { // the selected contact has no attached email address

[self dismissModalViewControllerAnimated:YES];

}

else//if(ABMultiValueGetCount(emails) == 1) { // the selected contact has exactly one email address

for(int i=0; i<ABMultiValueGetCount(phones); i++){

CFStringRef phone = ABMultiValueCopyValueAtIndex(phones, i);

NSString *phoneString = (NSString *) phone;

if(phoneString == nil){

}else {

NSDictionary *info = [[NSDictionary allocinitWithObjectsAndKeys:

  name, @"NAME", phoneString, @"EMAIL"kNotSelectTableCell@"CHECK"nil];

email_person_cnt++;

[friend_info addObject:info];

[info release];

}

[phoneString release];

[self dismissModalViewControllerAnimated:YES];

}

}

}

CFRelease(allPeople);


더 자세히 알고싶으시면 댓글이나 방명록에 써주세요.

      
Posted by k_ben