我正在玩Xcode 6的第一个测试版的Playground功能 - 我注意到Playground没有更新的一半时间(根本不显示结果计算或发生了多少循环迭代)简单的代码/循环/函数在那里.甚至是Swift Tour https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html
有几行代码没有显示在Playground中.如果你搞乱代码,它有时会显示,通过移动代码或将其放在其他地方.还有谁?任何修复?这只是一个测试版问题吗?
我正在尝试按如下方式创建泛型类的类型
class Cars<T> {
...
}
typealias SportCars = Cars
Run Code Online (Sandbox Code Playgroud)
但我得到一个编译错误如下 Reference to generic type 'Cars' requires argument in <...>
Swift的协议实现现在让我疯狂.我有observers一个定制协议定义的数组Observing,我试图从给定元素的数组中删除一个元素,但Swift抱怨Observing没有实现Identifiable(我认为这实际上是我自己的另一个协议,除非还有一个系统协议称为).我想要做的就是参考比较并删除实际对象.我不关心对对象进行任何比较.
var observers = [Observing]()
func removeObserver( observer: Observing ) {
for i in 0 ..< self.observers.count {
if self.observers[i] == observer { // <='Observing' is not convertible to 'Identifiable'...?
self.observers.removeAtIndex(i)
break
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有https://github.com/fulldecent/FDChessBoardView工作得很好,我现在再次从头开始创建项目pod lib create,以便制作Podspec.
有一个{'.h','.m'}文件和一些图像.图像位于提供的Pod/Assets文件夹中的文件系统中.podspec文件中记录了资源:
s.resource_bundles = {
'FDChessboardView' => ['Pod/Assets/*']
}
Run Code Online (Sandbox Code Playgroud)
(我也试过将这些文件直接添加到Development Pods/FDChessboardView/ResourcesXCode中的组中.)
在库实现文件中,我需要参考这些图像.我试过了:
NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"FDChessboardView" ofType:@"bundle"];
NSBundle *bundle = [NSBundle bundleWithPath:bundlePath];
NSString *imagePath = [bundle pathForResource:@"aa" ofType:@"png"];
UIImage* image = [UIImage imageWithContentsOfFile:imagePath];
Run Code Online (Sandbox Code Playgroud)
这里正确设置了imagePath.此文件存在并file确认它是PNG:
[...] aa.png:PNG图像数据,182 x 164,8位/彩色RGBA,非隔行扫描
但是UIImage是NULL.
我也试过这些:
image = [UIImage imageNamed:@"aa"];
UIImage *image = [UIImage imageNamed:@"FDChessboardView.bundle/aa.png"];
image = [UIImage imageNamed:@"aa" inBundle:bundle compatibleWithTraitCollection:nil];
Run Code Online (Sandbox Code Playgroud)
所有这些都产生NULL.
任何人都可以帮我指出如何加载主题图像资产的正确方向?
谢谢!
将
我将Xcode更新到6.1版本,现在我不明白为什么我不能像在上一版本中那样在我想运行我的应用程序时选择左上角的模拟器.出现的唯一选择是一般的"iOS设备".
我不熟悉Xcode.
谢谢.
Swift Playground中无法读取文件.
如何使文件可读?
相同的代码在Xcode终端应用程序上运行良好,但在Swift Playground上失败.
下面的演示代码.
import Foundation
println("Hello, World!")
var fname:String = "/Users/holyfield/Desktop/com.apple.IconComposer.plist"
var fm:NSFileManager = NSFileManager.defaultManager()
if(fm.fileExistsAtPath(fname)){
println("File Exists")
if(fm.isReadableFileAtPath(fname)){
println("File is readable")
var fd:NSData? = NSData(contentsOfFile: fname)
println(fd?.length)
let pl = NSDictionary(contentsOfFile: fname)
println(pl?.count)
println(pl?.allKeys)
}else{
println("File is not readable")
}
}
else{
println("File does not exists")
}
Run Code Online (Sandbox Code Playgroud)
示例图片:

我最近更新到OSx 10.10.2和Xcode 6.2.
我有一个我正在研究的Unity项目,我已经为iOS制作并通过iTunes连接发布了几十次.现在,在Xcode 6.2上,一旦我的项目进入Xcode,我就无法完成第一步.
即,Project-> Archive.我需要归档我的构建版本才能将其转换为iTunes Connect.但是,"存档"选项被禁用,显示为灰色.
如何归档我的构建?有没有新的工作流程来获取iTunes Connect?
谢谢!
我想将我的cell accessoryType的颜色从蓝色更改为白色.textColor已设置为白色.你们有人知道怎么做吗?
我的代码:
cell!.accessoryType = UITableViewCellAccessoryType.Checkmark
我正在尝试在我的iSO应用中添加Google Analytics,并且我正在使用Google Analytics最新的SDK https://developers.google.com/analytics/devguides/collection/ios/v3/.
成功添加了所有必需的标题和框架到我的项目.但在运行我的应用程序时,我遇到了错误
(null):"_ OBJC_CLASS _ $ _ GGLContext",引自:AppDelegate.o中的objc-class-ref
(null):链接器命令失败,退出代码为1(使用-v查看调用)
下面是我在AppDelegate.m文件中写的代码
// Configure tracker from GoogleService-Info.plist.
NSError *configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);
// Optional: configure GAI options.
GAI *gai = [GAI sharedInstance];
gai.trackUncaughtExceptions = YES; // report uncaught exceptions
gai.logger.logLevel = kGAILogLevelVerbose; // remove before app release
Run Code Online (Sandbox Code Playgroud)
还包括(_OBJC_CLASS _ $ _ GIDSignInButton和_OBJC_CLASS _ $ _ GIDSignIn)请告诉我缺少什么.提前致谢.
我需要建议如何继续.
如何稍微调暗主视图并显示一些忙碌指示,在某些动作的持续时间内,然后删除调光?
用Swift语言.
谢谢!
UPD:在Objective-C中,我之前使用过这样的东西:
UIView *dimView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
dimView.backgroundColor = [UIColor blackColor];
dimView.alpha = 0.5f;
dimView.tag = 1111;
dimView.userInteractionEnabled = NO;
[self.view addSubview:dimView];
Run Code Online (Sandbox Code Playgroud)
我们如何在Swift中执行此代码?
xcode6 ×10
swift ×6
ios ×4
cocoapods ×2
ios8 ×2
arrays ×1
cocoa ×1
cocoa-touch ×1
foundation ×1
itunes ×1
protocols ×1
uitableview ×1
uiview ×1
xcode ×1