目标:
我想象征着"输出" [NSThread callStackSymbols].
附注:
我知道如何使用崩溃日志来做到这一点.但是,我需要调查一些我想查看调用堆栈的问题.不幸的是,这些天框架的地址都是<redacted>.导致在正确的点崩溃(或结尾-看到我的问题的结束)是不是真的可以接受的,但如果我不能找到另一种解决方案,这将是要走的路.
我必须在设备上运行我的测试,所以我不能使用模拟器.
目前的做法:
当我这样称呼:
NSLog(@"call stack:\n%@", [NSThread callStackSymbols]);
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
2015-12-08 15:04:03.888 Conversion[76776:4410388] call stack:
(
0 Conversion 0x000694b5 -[ViewController viewDidLoad] + 128
1 UIKit 0x27259f55 <redacted> + 1028
...
9 UIKit 0x274f67a7 <redacted> + 134
10 FrontBoardServices 0x2b358ca5 <redacted> + 232
11 FrontBoardServices 0x2b358f91 <redacted> + 44
12 CoreFoundation 0x230e87c7 <redacted> + 14
...
16 CoreFoundation 0x23038ecd CFRunLoopRunInMode + 108
17 UIKit 0x272c7607 <redacted> + 526
18 UIKit 0x272c22dd UIApplicationMain + 144 …Run Code Online (Sandbox Code Playgroud) 我愿意在这个问题上给予赏金.我已经添加了一个,但它已经过期而没有给予奖励的答案.所以,如果你知道一个答案,请给我一个提示,我会另外给你一个赏金.
如果我理解正确,就会在NSLog电话后面使用asl .所以我阅读了手册页并使用谷歌并最终得到了印象,我可以添加一个额外的文件来收集日志输出asl_add_log_file(手册页).与使用谷歌发现的其他问题一样,我的输出文件为空,并且没有显示日志消息.
通常的解决方案,到目前为止似乎是freopen在stderr一个文件中.我运行了一些测试,并希望实现一个简单的日志轮换.当对另一个freopen文件执行另一个操作时,NSLog会丢失一些消息.所以我正在寻找另一种解决方案.
为了在Mac OS X上测试它,我在Xcode中创建了一个控制台应用程序,并将此代码添加到main:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(@"docdir = %@", documentsDirectory);
NSString *fileName =[NSString stringWithFormat:@"asl-created-%@.log",[NSDate date]];
NSString *logFilePath = [documentsDirectory stringByAppendingPathComponent:fileName];
NSLog(@"logFilePath = %@", logFilePath);
int asl_fd = open([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], O_CREAT | O_APPEND);
if (asl_fd==-1) {
NSLog(@"could not open output file");
}
asl_object_t asl;
asl = asl_open(NULL, NULL, 0);
asl_add_log_file(asl, asl_fd);
NSLog(@"test output");
/* EDIT: …Run Code Online (Sandbox Code Playgroud) 我在Instruments Automation中保存了一个屏幕截图,但该屏幕截图中缺少一些控件.看起来编程添加的控件被"忽略".
我该如何解决这个问题?
模拟器中的手动屏幕截图:(注意黄色框)
仪器自动化中的截图:
自动化脚本:
var target = UIATarget.localTarget();
target.delay(0.5)
target.captureScreenWithName( "screenshot1.png" );
Run Code Online (Sandbox Code Playgroud)
我在Xcode中创建了一个新的单一视图应用程序(universal,objective-c).我添加了一个按钮和一个标签,其中包含故事板中自动布局的一些约束.
我添加了此代码以编程方式添加黄色按钮:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIButton *b = [[UIButton alloc] init];
b.backgroundColor = [UIColor yellowColor];
[b setTitle:@"Extra" forState:UIControlStateNormal];
[b setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:b];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:b attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTopMargin multiplier:1.0 constant:0.0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:b attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailingMargin multiplier:1.0 constant:0.0]];
[self.view setNeedsUpdateConstraints];
// Correction: - initially I used the line below, …Run Code Online (Sandbox Code Playgroud) 我无法让GameCenter邀请朋友上班.匹配器制造商视图控制器很快显示被邀请的玩家以及其下的一个小文本"失败".也许我选择了错误的时间来学习GameCenter,因为很多人都报告了iOS9的困难.但也许某处有解决方案.
基本:
viewDidLoad播放器中,通过分配块来启动认证[GKLocalPlayer localPlayer].authenticateHandler.在块中,显示传入的视图控制器(如果有的话).这有效.GKGameCenterControllerDelegate并且它工作,接收到"didFinish"调用并且我在那里关闭GameCenter视图控制器.[[GKLocalPlayer localPlayer] registerListener:...];.所有GKLocalPlayerListener方法的方法存根都通过日志调用实现.GKMatchRequest和GKMatchmakerViewController,将我的视图控制器设置为匹配器委托并显示匹配器视图控制器.同样,所有委托方法都使用日志调用实现.问题:
其他资源:
GameKit日志:
我打开iPhone上的设置中的GameCenter日志记录并导出日志.引起我注意的第一件事是"没有注册同行(...)":
<NSHTTPURLResponse: 0x167a2cc0> { URL: https://service.gc.apple.com/WebObjects/GKInvitationService.woa/wa/initiate } { status code: 200, headers { ... }
...
status: (200) no error
header: <CFBasicHash 0x165e6480 [0x3b6633e8]>{type = immutable dict, count = 10,
entries =>
...
body: <CFBasicHash 0x17811ad0 [0x3b6633e8]>{type …Run Code Online (Sandbox Code Playgroud) 是否有针对可访问性标识符的既定命名约定(与 Xcode UI 测试记录相关)?
我正在研究可访问性和 UI 测试。我使用了 Xcode 7 中的新记录功能。在记录 UI 操作时,我注意到:
当我有一个标有“a”的按钮并记录点击两次时,我得到以下代码:
XCUIElement *aButton = [[XCUIApplication alloc] init].buttons[@"a"];
[aButton tap];
[aButton tap];
Run Code Online (Sandbox Code Playgroud)
当我将其accessibilityIdentifier 设置为“a”并重复录制时,我得到相同的代码。
本地化标签会干扰辅助功能标识符吗?(如果在某些语言中,按钮 X 突然将“a”作为标签,而按钮 Y 将“a”作为可访问性标识符 - 这是否会产生歧义/冲突?)
我的第一个想法是为可访问性标识符设置一个唯一的前缀 - 比如“@”。所以我尝试了“@a”、“@1”等。
然而,使用“@1”记录会导致以下代码:
XCUIElement *1Button = [[XCUIApplication alloc] init].buttons[@"@1"];
[1Button tap];
[1Button tap];
Run Code Online (Sandbox Code Playgroud)
这会产生编译器错误,因为1Button不是有效的标识符。显然,可访问性标识符被添加到按钮的变量名称前面,并删除了一些字符。
使用“1”记录会导致以下代码:
XCUIElement *button = [[XCUIApplication alloc] init].buttons[@"1"];
[button tap];
[button tap];
Run Code Online (Sandbox Code Playgroud)
这引出了另一个问题:
我可以影响 Xcode 在记录期间派生变量名称的方式吗?
我知道,我可以手动进行记录和清理变量名。然而,如果可以在某个地方轻松配置它,那就太愚蠢了。
我为 UIButtons 以及选项卡栏中设置了系统图像。这适用于 iOS 14,但在 iOS 13 上图像丢失。
iOS 13 上系统映像丢失的原因可能是什么?
细节:
我在故事板中有一个按钮,其图像属性设置为“square.and.arrow.up”。(参见下面的屏幕截图)该图像出现在 iOS 14 上,但不在 iOS 13 上(参见下面的屏幕截图。模拟器重叠)
选项卡栏项目也会发生类似的行为。(见下面的其他截图)
Xcode 为 12.5、MacOS 11.2.3、iOS 模拟器 13.6 和 14.5。这种情况也发生在设备上,而不仅仅是模拟器中。
SF Symbols App 声称该图标自 iOS 13+ 起可用。
如有任何帮助,我们将不胜感激:-)
@interface我可以在参数类型中声明一个方法NSString*:
- (id) initWithString:(NSString*)str;
Run Code Online (Sandbox Code Playgroud)
在实施过程中是NSNumber*:
- (id) initWithString:(NSNumber*)str
Run Code Online (Sandbox Code Playgroud)
有关完整示例,请参阅下面的代码。当调用[Work test]输出时a.x = Hi,因此传入的内容NSString*通过了,可以看到initWithString调用了“正确”的方法。
为什么编译器会接受这段代码?
当参数类型不同时,我可以让编译器抱怨吗?
引用 Apple 的文档定义类:
唯一的要求是签名匹配,这意味着您必须保持方法名称以及参数和返回类型完全相同。
我的测试代码:
@interface ClassA : NSObject
@property (strong, nonatomic) NSNumber *x;
- (id) initWithString:(NSString*)str;
- (void) feed:(NSString*)str;
@end
@implementation ClassA
- (id) initWithString:(NSNumber*)str
{
self = [super init];
if (self) {
self.x = str;
}
return self;
}
- (void) feed:(NSNumber*)str
{
self.x = str;
}
@end
@implementation …Run Code Online (Sandbox Code Playgroud) 我正在使用xcode 7 beta和swift 2.0.我正在关注教程(youtube.com/watch?v=PKOswUE731c).
总之,我有一个有3个视图的故事板; 受保护的vc,登录vc和RegisterViewController.我设置了2个segues
使用loginView标识的protected_vc < - > login_vc的segue模式
login_vc中的按钮上的segue模式< - >使用registerView标识的RegisterViewController
我在登录vc上使用注册按钮时遇到问题.如果我单击注册按钮它会崩溃应用程序,我收到消息'Receiver (<registerLogin.RegisterViewController: 0x7f97235f6140>) has no segue with identifier 'loginView''
现在我注意到在教程中选择一个segue给出另一个下拉列表,在我的情况下我只看到push - modal -popover - replace和custom.这可能是原因吗?
或者这部分ViewController
override func viewDidAppear(animated: Bool) {
self.performSegueWithIdentifier("loginView", sender: self);
}
Run Code Online (Sandbox Code Playgroud)
RegisterViewController的完整代码是
import UIKit
class RegisterViewController: ViewController {
@IBOutlet weak var userEmailTextField: UITextField!
@IBOutlet weak var userPasswordTextField: UITextField!
@IBOutlet weak var repeatPasswordTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() …Run Code Online (Sandbox Code Playgroud) ios ×8
xcode ×3
objective-c ×2
automation ×1
game-center ×1
instruments ×1
ios13 ×1
ios14 ×1
ios9 ×1
segue ×1
symbolicate ×1