IPhone开发调试中的一个较好用的宏

#define showAlert(format, ...) myShowAlert(__LINE__, (char *)__FUNCTION__,format, ##__VA_ARGS__)
// Simple Alert Utility
void myShowAlert(int line, char *functname, id formatstring,...)
{
 va_list arglist;
 if (!formatstring) return;
 va_start(arglist, formatstring);
 id outstring = [[[NSString alloc] initWithFormat:formatstring arguments:arglist] autorelease];
 va_end(arglist);
 NSString *filename = [[NSString stringWithCString:__FILE__] lastPathComponent];
 NSString *debugInfo = [NSString stringWithFormat:@"%@:%d\n%s", filename, line, functname];
 UIAlertView *av = [[[UIAlertView alloc] initWithTitle:outstring message:debugInfo delegate:nil cancelButtonTitle:@"OK"otherButtonTitles:nil] autorelease];
 [av show];
}

你可能感兴趣的:(iPhone开发)