为什么NSLog不输出aString参数?

时间:2015-04-09 18:51:38

标签: ios objective-c jailbreak theos

我在Tweak.xm中有以下代码:

%hook NSString
- (BOOL)isEqualToString:(NSString *) aString {
    NSLog(@"%@", [NSString stringWithFormat:@"isEqualToString for : %@ with: %@", aString, self]);

    return %orig;
}
%end

然而,syslog输出显示self但不是aString(应该是for :),例如:

Apr 9 20:46:32 remini CitrixReceiver-iPad[7972] <Warning>: isEqualToString for : with: /var/mobile/Containers/Data/Application/42123BED-A507-4CE0-97B0-20DFFD9BB78C Apr 9 20:46:32 remini CitrixReceiver-iPad[7972] <Warning>: isEqualToString for : with: /Applications/Cydia.app Apr 9 20:46:32 remini CitrixReceiver-iPad[7972] <Warning>: isEqualToString for : with: /private/var/lib/apt/ Apr 9 20:46:32 remini CitrixReceiver-iPad[7972] <Warning>: isEqualToString for : with: /var/mobile/Containers/Data/Application/42123BED-A507-4CE0-97B0-20DFFD9BB78C

为什么不输出aString?

1 个答案:

答案 0 :(得分:1)

我会猜测字符串是nil还是空的。在方法的开头检查。即。

if (aString == nil || [aString length] == 0) 
{
    ...
}