nslog

Logging the class name of all UIViewControllers in a project

假装没事ソ 提交于 2019-12-18 11:56:56
问题 We have received a HUGE project from outsourcing that we are trying to "repair". There are hundreds of view controllers within the project. Our goal is to easily determine which class we are currently looking at on the device. Our solution (which didn't work, hence the SO question) follows. Override the viewDidAppear method of UIViewController via a category with this: -(void)viewDidAppear:(BOOL)animated { NSLog(@"Current View Class: %@", NSStringFromClass(self.class)); [self viewDidAppear

how to create a breakpoint's log message action in xcode?

坚强是说给别人听的谎言 提交于 2019-12-18 11:09:42
问题 Been watching a WWDC video today about new features in xCode 4. They have mentioned that it a good idea to use log message actions on breakpoints along with "automatically continue after evaluation actions" enabled to output a variable's value for instance instead of using NSLogs all the time. lets say I have something like that: NSLog(@"URL is : %@", userDocumentsURL); How would I write a log message action to display userDocumentsURL's value? Is it really a good idea to use the above method

how to create a breakpoint's log message action in xcode?

我是研究僧i 提交于 2019-12-18 11:09:07
问题 Been watching a WWDC video today about new features in xCode 4. They have mentioned that it a good idea to use log message actions on breakpoints along with "automatically continue after evaluation actions" enabled to output a variable's value for instance instead of using NSLogs all the time. lets say I have something like that: NSLog(@"URL is : %@", userDocumentsURL); How would I write a log message action to display userDocumentsURL's value? Is it really a good idea to use the above method

How to print NSMutableURLRequest?

我们两清 提交于 2019-12-18 11:06:37
问题 How to print NSMutableURLRequest using NSLog ? 回答1: .allHTTPHeaderFields returns a dictionary with the header content: NSLog(@"%@", [request allHTTPHeaderFields]); // { // "Accept-Language" = "en;q=1"; // "Content-Length" = 190706; // "Content-Type" = "multipart/form-data; boundary=Boundary+D90A259975186725"; // "User-Agent" = "..."; // } Or for specific field: NSString *field = @"Content-Type"; NSLog(@"%@",[request valueForHTTPHeaderField:field]); // multipart/form-data; boundary=Boundary

How to disable NSLog all over the app?

心已入冬 提交于 2019-12-18 05:47:32
问题 I want to disable NSLog() across all instances in an app. I found some code that does that: #ifndef DEBUG #define NSLog // #endif But adding this code to each file isn't good idea. How can I make it easier? 回答1: Xcode has a precompiled header file ( {project-name}-Prefix.pch in the Supporting Files group by default) that is a great place to put code that will be used across every file in the project. For going a step further and improving the log message itself, see Is it true that one should

NSLog - Strange behavior

為{幸葍}努か 提交于 2019-12-18 04:21:55
问题 I found that last word showed with double quotes. But why? NSDictionary *guide2 = [NSDictionary dictionaryWithObjectsAndKeys:kArr, @"Kate", aArr, @"Ana-Lucia", kArr, @"John", nil]; NSArray *array = [guide2 allKeys]; NSLog(@"%@", [array description]); output: ( John, Kate, "Ana-Lucia" ) 回答1: It seems that because of the special character - in the key Ana-Lucia , it displays it within double-quotes. May be this is because to show that the key is a single word . If your key contains only

Using NSLog for debugging

不打扰是莪最后的温柔 提交于 2019-12-18 03:49:19
问题 I have the following code snippet in my Xcode: NSString *digit [[sender titlelabel] text]; NSLog([digit]); I tried to build the application and am getting the following warning message for the line NSLog([digit]); Warning: Format not a string literal and no format arguments Can you advise me how I can resolve this warning message? What does the message actually mean? 回答1: Try this piece of code: NSString *digit = [[sender titlelabel] text]; NSLog(@"%@", digit); The message means that you have

NSLog not printing to console

牧云@^-^@ 提交于 2019-12-17 22:35:51
问题 I have an Xcode project I've been working on for months. I've never had a problem with NSLog, but after upgrading to Xcode 4.2 nothing will log to the console. I even tried throwing this in viewDidLoad: - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Can anyone hear me?"); And nothing. Is anyone else having this problem or know a solution? 回答1: Well, this is embarrassing. The console got deactivated somehow and I was actually watching the variables window. Pressing Shift +  + C did the

How to disable logging?

吃可爱长大的小学妹 提交于 2019-12-17 20:38:03
问题 I have an app that is making use of UITextChecker class provided by Apple. This class has a following bug: If the iOS device is offline (expected to be often for my app) each time I call some of UITextChecker s methods it logs following to console: 2016-03-08 23:48:02.119 HereIsMyAppName [4524:469877] UITextChecker sent string:isExemptFromTextCheckerWithCompletionHandler: to com.apple.TextInput.rdt but received error Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named

NSLog without new line

情到浓时终转凉″ 提交于 2019-12-17 19:28:18
问题 Is there any function that does what NSLog does but without the new line at the end? 回答1: see this http://borkware.com/quickies/one?topic=NSString excerpted from that page: void LogIt (NSString *format, ...) { va_list args; va_start (args, format); NSString *string; string = [[NSString alloc] initWithFormat: format arguments: args]; va_end (args); printf ("%s\n", [string UTF8String]); [string release]; } // LogIt just customize the printf to suit your needs 回答2: You can use printf(), but the