是否可以同时使用多个测试设备调试/运行Xcode iPhone/iPad应用程序项目并查看所有这些设备的控制台输出?我正在开发蓝牙应用程序,我想在完整的活动模式下测试它,能够在控制台中看到至少2个连接设备的NSLog等.
我可以看到Xcode 4提供了一次运行多个调试会话的可能性,但控制台只输出其中一个调试会话的日志.有没有办法设置Xcode(方案中的一些构建/运行设置),以便能够查看连接和调试的多个测试设备的日志?
NSDate *date = [NSDate dateWithTimeIntervalSince1970:timestamp];
NSDateFormatter *_dateFormatter = [[NSDateFormatter alloc] init];
[_dateFormatter setTimeZone:[NSTimeZone defaultTimeZone]];
[_dateFormatter setDateFormat:@"dd-MM-yy HH:mm"];
NSString *dateString = [_dateFormatter stringFromDate:date];
NSLog(@"Date: %@ formatted: %@", date, dateString);
[_dateFormatter release];
Run Code Online (Sandbox Code Playgroud)
给我错误的日期格式:
日期:2013-01-31 18:00:00 +0000格式:31-01-13 19:00(来自时间戳:1359655200.000000)
在线转换工具:http://www.onlineconversion.com/unix_time.htm表示第一个日期是正确的:2013-01-31 18:00:00 +0000.
为什么NSDateFormatter会生成与NSLog不同的日期?[NSDate description]打印到控制台时不应该使用defaultTimeZone?我得到同样的错误[_dateFormatter setTimeZone:[NSTimeZone localTimeZone]]; 和[_dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
我在我的应用程序中分析关键循环,我在时间分析器设置中看到有趣的选项:
"视为价值观"
当我选择它时,我会看到带有'x'后缀而不是标准百分比值的数字.
作为示例,请参阅附加的屏幕截图(汇编代码视图):
and指令具有442x价值.对于这样简单的汇编指令而言,这个btw似乎很重,并且与循环中的其他指令相比.
这些数字是什么意思?这些是否以某种方式指代给定代码行的CPU周期?
我可以在新的Xcode 4.2 Inteface Builder中看到名为Storyboard的全新功能.我在哪里可以找到有助于深入理解此功能的优秀指南?
我使用内置的"Clang"工具集在NetBeans中创建了一个简单的C++应用程序项目.Clang设置似乎没问题(所有指向LLVM):
C编译器:/ usr/bin/clang
C++编译器:/ usr/bin/clang ++ ...
调试器命令:/ usr/bin/lldb
我的项目设置将"工具集"设置为:"CLang(默认)".
当我尝试调试项目时,GDB调试器被解雇(当然由于最新Mac系统上已知的gdb问题而失败,这是我切换到LLVM的原因之一)我得到:
启动调试器...
启动gdb
...
GDB意外停止,返回0
我试图强制Debug命令在Debug项目设置中使用lldb,但无济于事.使用"Attach debugger ..."时也很奇怪,我只能看到我安装的所有GDB调试器但没有lldb(见下面的截图).
我错过了什么设置?
截图:

我正在使用Swift 3.1并有一些通用的结构:
struct Section<InfoT: Equatable, ItemsT: Equatable> {
let info: InfoT?
let items: [ItemsT]
}
Run Code Online (Sandbox Code Playgroud)
并希望使用自定义方法对此泛型类型的元素进行数组扩展:
extension Array where Element == Section<Equatable, Equatable> {
// Just dummy example function:
func debugDummy() {
for section in self {
let info = section.info
print("section info: \(info).")
for item in section.items {
print("item: \(item).")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这给了我编译错误:
error: using 'Equatable' as a concrete type conforming to protocol 'Equatable' is not supported
extension Array where Element == Section<Equatable, Equatable> {
^
error: …Run Code Online (Sandbox Code Playgroud) I am porting legacy Objective-C library to the Swift Package, which has Unit Tests written in Swift. Previously, this library was written using standard approach: Framework target / Xcode project, so the test target could import internal headers (using bridging header). It seems as Swift Package manager does not offer anything like this, therefore testing internals looks problematic (without exposing them to the public).
BTW: @testable import ... does not work for Objective-C code.
I also tried to cheat …
这个问题让我很烦恼.不知何故,在安装了wysiwig编辑器后,我的评论体形变成了丰富的... bla bla area.我不想要这个,但我找不到将注释输入格式转回纯文本(或过滤格式)的地方.我知道如何更改不同内容类型的过滤器选项,但将注释转回简单格式只会让我发疯!请帮忙 - 这个配置位置在哪里评论?
在一个非常大的项目中我到处使用自动合成属性:
//MyClass.h file:
@interface MyClass : NSObject
@property (nonatomic, retain) NSString *deviceName;
@property (nonatomic, retain) NSString *deviceID;
@end
//MyClass.m file:
#import "MyClass.h"
@implementation ApplicationStatus
// no @synthesize used at all.
-(void)dealloc{
[_deviceName release]; // gives errors only while converting to ARC with LLVM 5.0
[_deviceID release];
[super dealloc];
}
@end
Run Code Online (Sandbox Code Playgroud)
上面的代码在非ARC模式下以及在ARC转换过程中的旧Xcode版本中编译得很好.当尝试使用最新的LLVM 5.0编译器(最新的Xcode)进行转换时,它给了我数以百万计的错误:

这是什么原因?我是否必须手动创建数百个实例变量并立即手动@synthesize它们?苹果公司在所有WWDC上宣传的"少写代码"理念是否会退后一步呢?
compiler-construction xcode compilation properties automatic-ref-counting
假设我们有一个带有初始化器的 Swift 类,它可以抛出错误。此类必须在Objective-C代码库(NSObject子类)中使用:
import Foundation
enum EvenError : ErrorType {
case NonEvenNumber
}
class FooEven : NSObject {
var evenNumber : UInt
init(evenNumber: UInt) throws {
guard evenNumber % 2 == 0 else {
throw EvenError.NonEvenNumber
}
self.evenNumber = evenNumber
}
}
Run Code Online (Sandbox Code Playgroud)
产生编译警告:
<unknown>:0: warning: no calls to throwing functions occur within 'try' expression
Run Code Online (Sandbox Code Playgroud)
我可以通过两种方式解决此警告:
init... -> throws失败的初始化器 ( )替换可抛出的初始化器( init?)NSObject然而这样我会:
if let fooEven = FooEven.init() …xcode ×4
iphone ×3
swift ×3
debugging ×2
ios ×2
objective-c ×2
arrays ×1
bridge ×1
c++ ×1
compilation ×1
date ×1
device ×1
drupal ×1
formatting ×1
generics ×1
instruments ×1
macos ×1
netbeans ×1
nsdate ×1
profiling ×1
properties ×1
storyboard ×1
swift3 ×1
testing ×1
xcode4 ×1
xcode4.2 ×1