Questions tagged [nslog]

Logs an error message to the Apple System Log facility.

The message consists of a timestamp and the process ID prefixed to the string you pass in. You compose this string with a format string and one or more arguments to be inserted into the string. The format specification allowed by this function is that which is understood by NSString’s formatting capabilities.

Displaying log messages in the system console while running your application is one of the oldest debugging mechanisms available. Using logging, you can generate a transcript describing the operations being performed by your application that you can review long after your application has finished running. Also, while your application is running, you can observe log messages being generated and written to the console as the events in your app they describe are taking place. As a developer, you are in complete control of the text and information displayed in the console by NSLog. Logging can reveal even the toughest to find problems in an app.

Here is an example of what a call to NSLog looks like:

NSString *message = @"test message";

NSLog( @"Here is a test message: '%@'", message );

Console:

Here is a test message: 'test message'

Reference:

Basic debugging with the NSLog function and the DEBUG preprocessor macro

667 questions
-1
votes
1 answer

How do I NSLog a string from an NSDictionary object?

Working with Json, how can I "NSlog" only the title in this code: NSDictionary *item = [tableData objectAtIndex:[indexPath row]]; // Set text on textLabel [[cell textLabel] setText:[item objectForKey:@"title"]]; // Set text on…
Frenck
  • 6,514
  • 5
  • 22
  • 25
-1
votes
1 answer

BOOL prints as -65

I am trying to NSLog a BOOL in Objective-C. When I do, it prints either as 0, 7, or -65. This is my code: BOOL testBool; NSLog(@"testBool = %i", testBool); I've also tried %d and casting it as an int, but I get the same result every time. Can…
serverpunk
  • 10,665
  • 15
  • 61
  • 95
-1
votes
2 answers

How to get Device Logs in a text file from NSlog using Objective c?

I'm getting json data in my NSlog in Xcode using following code NSString *jsonStr = [[NSString alloc] initWithData:activityData encoding:NSUTF8StringEncoding]; NSLog(@"Sync Json:%@",jsonStr); So if I have to get the same json data in my device log…
user3452
  • 349
  • 5
  • 20
-1
votes
3 answers

How to NSLog NSData JSON response in JSON format?

Is there a way I can NSLog JSON response of NSData in JSONformat? NSLog(@"JSON NSString: %@" ,jsonData); In this post they are printing NSDictionary,I can convert it to NSDictionary. and this solution returns (null). How can I NSLog in JSON…
Shuvo Joseph
  • 894
  • 1
  • 12
  • 21
-1
votes
1 answer

Understanding NSLog

NSLog documentation says: Logs an error message to the Apple System Log facility. Does this mean that if I want to test what my app does when killed, I can use XCode->Devices and look at the logs? I am testing BLE state restoration, which…
mm24
  • 9,280
  • 12
  • 75
  • 170
-1
votes
2 answers

Use of undeclared identifier " sum"

I have repeated error 3rd time, but I could not found that what is mean of use of undeclared identifier .. I wrote that program on function in objective-C #import @interface Add:NSObject /* method declaration */ -…
venky ios
  • 1
  • 2
-1
votes
1 answer

Objective-C How to use tokens for NSArrays?

So, I'm in a OS, Xcode application, in Objective-C code. Here's what I have so far: #import int main(int argc, const char * argv[]) { @autoreleasepool { /// IN THIS CHALLENGE, I HAVE TO MAKE MY OWN PLIST …
Christian Kreiter
  • 610
  • 1
  • 5
  • 16
-1
votes
1 answer

Log of NSDictionary returns null and zero elements

I'd like to print number of elements and one of element in NSLog. I create new dictionary variable and add it to the NSMutableArray. Then in NSLog I'd like to see content of an element but it returns null and zero elements. My code is below: while…
DKM
  • 270
  • 3
  • 13
-1
votes
2 answers

Interesting output using variables with NSLog() in objective-c

The following code: int N = 100; double total_time = 100; double dt = total_time/N; NSLog(@"Answer: %d", dt); gives an interesting output: 5766 instead of 1. Only in the case of adding NSLog(@"Answer: %f", dt); outputs the right answer. However,…
-1
votes
2 answers

Custom NSLog without precompiled header

Since Xcode 6 and the introduction of modules, there is no need for precompiled headers anymore. I have always been using a custom logging method which also logs the file, method and line number it was on. This method was defined in the precompiled…
yoeriboven
  • 3,541
  • 3
  • 25
  • 40
-1
votes
1 answer

How To Print Value From NSUserDefault

HI in below code i store Data in nsuserdefault but i want to see my data what i entered so how i print my data in user default userRegistrationClass *userData = [[userRegistrationClass alloc] init]; userData.strName = [dicUserData…
Sumit singh
  • 2,398
  • 1
  • 15
  • 30
-1
votes
1 answer

Value transfer issue

Is there any explanation why the NSLog always displays null when running this code? ExtratoDeNotasSideMenuViewController *extratoDeNotasSideMenuViewController = [[ExtratoDeNotasSideMenuViewController alloc]…
Douglas Pfeifer
  • 147
  • 1
  • 8
-1
votes
2 answers

NSDictionary show null after converted

NSString *profilestring = [self.userDefaults objectForKey:@"profilestrings"]; NSDictionary *dicProfile = [profilestring propertyListFromStringsFileFormat]; NSLog(@"--->>%@",profilestring); NSLog(@">>%@",dicProfile); self.userDefaults is…
Bin
  • 484
  • 1
  • 6
  • 18
-1
votes
3 answers

NSString concatinate NSInteger Frozen

My IOS app needs to put a number behind a string. The number is received by the index of the cell that is being pushed. however if i run the app and push a cell. My screen goes to xCode showing that there is a variable called tempstring. the…
brian
  • 156
  • 1
  • 1
  • 11
-1
votes
2 answers

if-query: if (Nslog isEqualtoString @"...") - How can I make this?

I want my app to do something when the last NSLog has a certain string. I thought I could realize this with an if-query and isEqualtoString, but how can I make this? Sorry for my bad English ;)
Flocked
  • 1,898
  • 2
  • 36
  • 57