当我构建我的iPhone项目时,我收到来自xcode的关于我的一些xib的警告说:
Specifying a title shadow offset in Interface Builder is not supported by the iPhone SDK for iPhone OS versions prior to 3.0.
事实是,我正在构建3.0,基本SDK设置为3.0.我已经做了一些探索,找不到任何看起来会解决问题的东西.
我做了一些谷歌搜索并搜索了Apple的开发论坛,但没有找到任何东西.这里有没有人有任何想法?
我试图利用AVPlayer年代addBoundaryTimeObserverForTimes从快捷方法和遇到一个问题转换CMTimes到NSValues,这是addBoundaryTimeObserverForTimes作为输入.最后我使用了一个C函数包装[NSString valueWithCMTime:]并从swift调用它,但有没有办法在纯swift中执行它?
我正在尝试使用具有相同格式的另一个NSDateFormatter来解析由NSDateFormatter生成的字符串.
这里有一些代码,而不是试图使之前的句子有意义:
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"MMM dd, YYYY HH:mm"];
NSDate *now = [[NSDate alloc] init];
NSString *dateString = [format stringFromDate:now];
NSDateFormatter *inFormat = [[NSDateFormatter alloc] init];
[inFormat setDateFormat:@"MMM dd, YYYY HH:mm"];
NSDate *parsed = [inFormat dateFromString:dateString];
NSLog(@"\n"
"now: |%@| \n"
"dateString: |%@| \n"
"parsed: |%@|", now, dateString, parsed);
Run Code Online (Sandbox Code Playgroud)
当我运行此代码时,我希望解析后的日期与现在相同,但我得到以下输出:
now: |2009-05-04 18:23:35 -0400| dateString: |May 04, 2009 18:23| parsed: |2008-12-21 18:23:00 -0500|
任何人都有任何想法为什么会这样?
我正在尝试对通过NSNotification接收的值和枚举值进行简单比较.我有一些有用的东西,但我无法相信这是做这件事的正确方法.基本上我最终得到的解决方案是将NSNumber转换为Int,并获取枚举值的rawValue,将其包装在NSNumber中,然后获取该值的integerValue.
我尝试的其他所有内容导致编译器错误,无法在Uint 8和Int或类似的东西之间进行转换.
observer = NSNotificationCenter.defaultCenter().addObserverForName(AVAudioSessionRouteChangeNotification, object: nil, queue: mainQueue) { notification in
println(AVAudioSessionRouteChangeReason.NewDeviceAvailable.toRaw())
if let reason = notification.userInfo[AVAudioSessionRouteChangeReasonKey!] as? NSNumber {
if (reason.integerValue == NSNumber(unsignedLong:AVAudioSessionRouteChangeReason.NewDeviceAvailable.toRaw()).integerValue) {
self.headphoneJackedIn = true;
} else if (reason.integerValue == NSNumber(unsignedLong:AVAudioSessionRouteChangeReason.OldDeviceUnavailable.toRaw()).integerValue) {
self.headphoneJackedIn = false;
}
self.updateHeadphoneJackLabel()
}
}
Run Code Online (Sandbox Code Playgroud)