2011-10-24 2 views

답변

2

사용 UIDevice currentDevice 목적 :

모델 :

[UIDevice currentDevice].model; 

버전 : 서버에 데이터를 전송하는

[UIDevice currentDevice].version; 

사용 ASIHTTPRequest POST. 당신이 아이폰 응용 프로그램에서 서버와의 연결을 위해 ASIHTTPRequest 1.6.x 이상인 라이브러리를 사용하는 경우

-(void)sendDataToServer{ 

     NSURL *url = [NSURL URLWithString:@"http://URL_TO_YOUR_SERVER"]; 

     ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; 


     [request addPostValue:[UIDevice currentDevice].model; forKey:@"model"]; 
     [request addPostValue:[UIDevice currentDevice].version; forKey:@"version"]; 

     [request startSynchronous]; 

     NSError *error = [request error]; 
     if (!error) { 
      //NO error 
     }else{ 
      //Deal with error 
     } 
} 
2

당신은 다음과 같이 ASIHTTPRequest.m 파일에이 정보를 얻을 수 있습니다

#if TARGET_OS_IPHONE 
    UIDevice *device = [UIDevice currentDevice]; 
    deviceName = [device model]; 
    OSName = [device systemName]; 
    OSVersion = [device systemVersion];  
#else 
    deviceName = @"Macintosh"; 
    OSName = @"Mac OS X"; 
#endif 
관련 문제