昨天我更新到El Capitan beta 2和Xcode 7 - beta是强制性的.所以我将我的应用程序更新为Swift 2,并且新的错误出现在json字符串中.这是我的代码:
let jsonData:NSDictionary = NSJSONSerialization.JSONObjectWithData(urlData!, options:NSJSONReadingOptions.MutableContainers ) as! NSDictionary
这是错误: Call can throw , but it is not marked with 'try' and the error is not handled
在解释我的问题之前,重要的是要说我已经实现了这个问题中提出的建议,我认为我对这种animateWithDuration方法的怀疑是完全不同的,尽管两个问题的标题非常相似.
所以,我是一个Swift新手,我正在Swift做一些小项目,基于我以前做过的之前的Objective C演示.
这是我的Objective C代码:
- (void)moveSideBarToXposition: (int) iXposition{
[UIView animateWithDuration:0.5f
delay:0.1
options: UIViewAnimationOptionTransitionNone
animations:^{ self.mainView.frame = CGRectMake(iXposition, 20, self.mainView.frame.size.width, self.mainView.frame.size.height); }
completion:^(BOOL finished){
if (self.isSidebarHidden==YES) {
self.isSidebarHidden = NO;
}
else{
self.isSidebarHidden = YES;
}
}];
}
Run Code Online (Sandbox Code Playgroud)
这是我的Swift版本:
func moveSideBarToXposition(iXposition: Float) {
UIView.animateWithDuration(0.5, delay: 1.0, options: UIViewAnimationTransition.None, animations: { () -> Void in
self.contentView.frame = CGRectMake(iXposition, 20, self.contentView.frame.size.width, self.contentView.frame.size.height)
}, completion: { (finished: Bool) -> Void in
if isMenuHidden == true {
isMenuHidden = false …Run Code Online (Sandbox Code Playgroud) 我正在使用Xcode 7 XCTest中引入的UI测试API.在我的屏幕上,我有一个从网络加载的文本.
如果我只是用exists属性检查它,测试就会失败.
XCTAssert(app.staticTexts["Text from the network"].exists) // fails
Run Code Online (Sandbox Code Playgroud)
如果我首先将tap或任何其他事件发送到文本,它确实有效:
app.staticTexts["Text from the network"].tap()
XCTAssert(app.staticTexts["Text from the network"].exists) // works
Run Code Online (Sandbox Code Playgroud)
看起来如果我只是调用exists它立即评估它并失败,因为尚未从网络下载文本.但我认为当我调用该tap()方法时,它会等待文本出现.
有没有更好的方法来检查是否存在从网络传送的文本?
像(这段代码不起作用):
XCTAssert(app.staticTexts["Text from the network"].eventuallyExists)
Run Code Online (Sandbox Code Playgroud) 我发现Xcode 7(版本7.0(7A220))改变了+load在单元测试期间调用类和类别的方法的顺序.
如果属于测试目标的类别实现了一个+load方法,那么现在可以在最后调用它,此时类的实例可能已经被创建和使用.
我有一个AppDelegate实现+load方法.该AppDelegate.m文件还包含AppDelegate (MainModule)类别.此外,还有一个单元测试文件LoadMethodTestTests.m,其中包含另一个类别 - AppDelegate (UnitTest).
这两个类别也实现了+load方法.第一类属于主要目标,第二类属于测试目标.
我做了一个小测试项目来证明这个问题.它是一个空的默认Xcode一个视图项目,只更改了两个文件.
AppDelegate.m:
#import "AppDelegate.h"
@implementation AppDelegate
+(void)load {
NSLog(@"Class load");
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"didFinishLaunchingWithOptions");
return YES;
}
@end
@interface AppDelegate (MainModule)
@end
@implementation AppDelegate (MainModule)
+(void)load {
NSLog(@"Main Module +load");
}
@end
Run Code Online (Sandbox Code Playgroud)
和一个单元测试文件(LoadMethodTestTests.m):
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "AppDelegate.h"
@interface LoadMethodTestTests : XCTestCase
@end
@interface AppDelegate (UnitTest) …Run Code Online (Sandbox Code Playgroud) 我刚刚将xcode更新为7.0并修复了大部分错误,但我不断收到此错误消息:启动图像集"LaunchImage"有2个未分配的子项.我已经删除了两个未分配的子节点,但仍然收到此错误消息.
不可否认,自从我在项目中运行pod更新以来,已经有一段时间了.今天我试图做到这一点,并遇到了问题.
运行'pod update'后,项目将无法编译.这是我注意到的.更新本身似乎运行正常,就像正常一样.我注意到'Pods/Target Support Files`中的所有文件都已被删除.
当我尝试构建时,我的大多数pod都会出现类似这样的错误:
lang: error: no such file or directory: '/Users/logan/development/ProjectNameRemoved/src/Pods/Target Support Files/Pods-AJNotificationView/Pods-AJNotificationView-dummy.m'
Run Code Online (Sandbox Code Playgroud)
clang: error: no input files
当我使用此错误转到pod的Build Phases时,我可以看到虚拟.m文件仍在那里,即使它不存在:

删除所有这些似乎没有帮助,因为我开始得到以下错误:
深入到目标的设置我可以看到GCC前缀头仍然设置为使用不存在的pch文件:
我不确定从哪里开始.似乎pod更新正在删除某些文件,但我的pbxproj没有更新以关联这些更改.我是否需要弄清楚如何手动执行此操作?
我目前正在运行XCode7和CocoaPods 0.38.2
在升级到最新的Xcode 7 Beta后运行我的应用程序时,我在控制台中收到以下消息:
objc[51750]: Class STGenericIntentDateRange is implemented in both /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/SiriTasks.framework/SiriTasks and /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/PhotosUI.framework/PhotosUI. One of the two will be used. Which one is undefined.
Run Code Online (Sandbox Code Playgroud)
我在Apple的文档或网上任何地方都找不到任何关于STGenericIntentDateRange的内容.它似乎没有影响我的应用程序,并且在构建时没有相关的警告 - 只是记录消息.
我猜这只是一个beta冲突问题,处理一些很少使用的日期功能,但我想知道是否有其他人看过这个或知道修复?
我的~/Library/Developer/Xcode文件夹大小超过17演出.当我在虚拟机(Parallels 12)中工作时,虚拟磁盘总大小为64 gig,我需要恢复一些磁盘空间.
在诸如"Archives","DerivedDate","Installs","iOS Device Logs","iOS DeviceSupport","Snapshots"和"UserData"等文件夹中,我可以在不破坏项目的情况下删除哪些内容?