nslog

Why is this NULL?

…衆ロ難τιáo~ 提交于 2019-12-25 02:07:04
问题 Can anyone tell me why this is NULL ? So Array1 is NSMutable, and has an NSString object "UserName" at index 0; NSLog (@"Contents of array1 %@", [array1 objectAtIndex:0]); //prints UserName Now , I do this... array2 belongs to another class. I reference the class, import .h file, and add property and synthesize it. [object2.array2 addObject: array1]; //array2 is NSMutable properly initialized in it's respective class in the init method NSLog (@"Contents of array2 %@", [object2.array2

NSLog用法,打印日志

断了今生、忘了曾经 提交于 2019-12-25 01:31:41
要输出的格式化占位: %@ 对象 %d, %i 整数 %u 无符整形 %f 浮点/双字 %x, %X 二进制整数 %o 八进制整数 %zu size_t %p 指针 %e 浮点/双字 (科学计算) %g 浮点/双字 %s C 字符串 %.*s Pascal字符串 %c 字符 %C unichar %lld 64位长整数(long long) %llu 无符64位长整数 %Lf 64位双字 NSLog定义在NSObjCRuntime.h中,如下所示: void NSLog(NSString *format, …); NSLog (@”this is a test”); NSLog (@”string is :%@”, string); NSLog (@”x=%d, y=%d”, 10, 20); 但是下面的写法是不行的: int i = 12345; NSLog( @”%@”, i ); 原因是, %@需要显示对象,而int i明显不是一个对象,要想正确显示,要写成: int i = 12345; NSLog( @”%d”, i ); 来源: https://www.cnblogs.com/Free-Thinker/p/5238570.html

Is there an overview of all codes that can be used inside NSLog()?

早过忘川 提交于 2019-12-24 06:44:36
问题 i.e. %@ for strings, %f for doubles... I don't know the word for these placeholders but it would be great to have list for how to print booleans and other values. 回答1: Since NSLog takes a NSString as its argument, it uses the NSString format specifiers. This is virtually identical to the common printf specifiers. Also, the %@ specifier is not limited to NSString objects, but is for any Objective-C objects. The base NSObject class provides a generic description of the object consisting of its

How do I log russian text or non-latin?

落爺英雄遲暮 提交于 2019-12-23 03:50:28
问题 Everything works well in the previous version of XCode. But today in the XCode 4.3.2 I have a problem. How do I log russian text or non-latin? NSLog(@"russian text: русский текст"); NSString *text = @"russian text: русский текст"; const char *textC = [text UTF8String]; NSString *getText = [NSString stringWithCString:textC encoding:NSUTF8StringEncoding]; NSLog(@"___text: %@", getText); My logs russian text: —Ä—É—Å—Å–∫–∏–π —Ç–µ–∫—Å—Ç ___text: russian text: —Ä—É—Å—Å–∫–∏–π —Ç–µ–∫—Å—Ç UPDATE: The

Disallow NSLog to be used

孤人 提交于 2019-12-22 17:05:26
问题 Is it possible to disallow the use of NSLog , so that it will come up as an error if used at compile time? Ideally some sort of compiler flag with the name of the method that is disallowed? Thanks 回答1: If you re-declare NSLog (and perhaps also NSLogv ) as void NSLog(NSString *format, ...) UNAVAILABLE_ATTRIBUTE; void NSLogv(NSString *format, va_list args) UNAVAILABLE_ATTRIBUTE; in your precompiled header file, you get a nice error message: main.m:199:3: error: 'NSLog' is unavailable NSLog(@"%@

OutputDebugString() with Delphi for MacOS

守給你的承諾、 提交于 2019-12-21 17:24:25
问题 Is there an NSLog declaration in the Delphi OSX units. I failed to find a substitude for OutputDebugString in a Firemonkey application. The final solution looks like this: /// <remarks> /// Output debug string. Output debug string can be seen in Delphi /// View|Debug Windows|Event Log or with 3-rd party programs such as /// dbgview.exe from SysInternals (www.sysinternals.com) /// </remarks> procedure ODS(const Text: string); begin {$IFDEF MACOS} // http://stackoverflow.com/questions/12405447

KeyboardViewController NSLog IOS 8

爱⌒轻易说出口 提交于 2019-12-20 01:43:41
问题 We can log with NSlog in other view in iOS 8 (Xcode Beta Version). However, I can't NSLog in keyboard extension in KeyboardViewController. It didn't appear in log. NSLog(@"viewdidload in keyboard"); I would like to know how to detect/log in real time. 回答1: You just don't see what is being logged in the debug area of Xcode because the Xcode debugger isn't attached to your extension. Extensions are nearly completely independent from their containing app. Answered here: for physical device:

init] returning date an hour in the past?

落爺英雄遲暮 提交于 2019-12-19 11:31:41
问题 When I call NSDate *now = [[NSDate alloc] init]; in order to get the current date and time, I check it with: NSLog(@"Date now: %@", now); the date outputted is one hour in the past. 2010-10-08 12:04:38.227 MiniBf[1326:207] Now: 2010-10-08 11:04:38 GMT Is my time zone set incorrectly somewhere perhaps? Thanks! Michael 回答1: Use NSDateFormatter to localize the date: NSLog(@"%@",[NSDateFormatter localizedStringFromDate:[NSDate date] dateStyle:NSDateFormatterShortStyle timeStyle

init] returning date an hour in the past?

不想你离开。 提交于 2019-12-19 11:29:15
问题 When I call NSDate *now = [[NSDate alloc] init]; in order to get the current date and time, I check it with: NSLog(@"Date now: %@", now); the date outputted is one hour in the past. 2010-10-08 12:04:38.227 MiniBf[1326:207] Now: 2010-10-08 11:04:38 GMT Is my time zone set incorrectly somewhere perhaps? Thanks! Michael 回答1: Use NSDateFormatter to localize the date: NSLog(@"%@",[NSDateFormatter localizedStringFromDate:[NSDate date] dateStyle:NSDateFormatterShortStyle timeStyle

Can you send retain counts to NSLog to aid learning?

浪尽此生 提交于 2019-12-19 10:25:27
问题 Just curious if there is anyway to display an objects retain count using NSLog. I just want to print them out to console to help learn how retain/release is working in some simple code? cheers -gary- 回答1: Not only is it possible, it's very easy too: NSLog(@"retain count=%d",[obj retainCount]); 回答2: I think you might be hitting an issue with NSString where retain and release messages can be sent to a string constant, but they actually have no effect nor alter the objects retainCount. The code