顯示包含「iOS」標籤的文章。顯示所有文章
顯示包含「iOS」標籤的文章。顯示所有文章

2012年3月1日星期四

differiate iPhone and iPad programmatically

Used the old-skool method for more than a year to find out what the device is.

size_t size;
 // Set 'oldp' parameter to NULL to get the size of the data
 // returned so we can allocate appropriate amount of space
 sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
 
 // Allocate the space to store name
 char *name = malloc(size);
 
 // Get the platform name
 sysctlbyname("hw.machine", name, &size, NULL, 0);
 
 // Place name into a string
 NSString *machine = [NSString stringWithCString:name encoding:NSUnicodeStringEncoding];
 
 // Done with this
 free(name);
 
 return machine;

but iOS App Programming Guide in fact got a more decent way to do this.

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// The device is an iPad running iOS 3.2 or later.
}
else {
// The device is an iPhone or iPod touch.
}

2011年4月8日星期五

Error launching remote program

Sometimes I will meet the error when running the app on the real device, aftering building it successfully.
The app would terminated right after clicking on it.

The console show such a error message: "Error launching remote program: failed to get the task for process"

Found a solution: for target setting, choose the right provisioning profile. for project setting, set the provisioning to "Don't Code re-sign"