我需要URL文件path是一个NSURL。 我有这个: let paths = NSSearchPathForDirectoriesInDomains( .DocumentDirectory, .UserDomainMask, true) // NSString *documentsDirectory = [paths objectAtIndex:0]; let documentsDirectory = paths[0] as String var filePath:String? = nil var fileNamePostfix = 0 do { filePath = "\(documentsDirectory)/\(dateTimePrefix)-\(fileNamePostfix++).mp4" } while (NSFileManager.defaultManager().fileExistsAtPath(filePath)) 我需要将其转换为NSURL以用于self.fileOutput.startRecordingToOutputFileURL(<#outputFileURL:NSURL?#>,recordingDelegate:<#AVCaptureFileOutputRecordingDelegate?#>)方法。 我试过filePath as? NSURL() filePath as? NSURL()但不正确 谢谢!
我有arrays中的“UserDetails”结构对象..我想过滤arrays中的对象。 但是在Swift数组中没有“filteredArrayUsingPredicate”选项。 我的数组创build var arrayOfUsers:UserDetails[] = UserDetails[]() 我的用户代码是 struct UserDetails{ var userName:String var userID:String var userAge:String func userDescription()->String{ return "name " + userName + "age " + userID } } 我的代码来创build对象 for a in 1…1000{ var user:UserDetails = UserDetails(userName: "name", userID: String(a), userAge: "22") arrayOfUsers.append(user) } 现在我想过滤arrayOfUsers哪一个有userID“1”。
我编程方式有一个iOS Swift项目中的多个视图控制器。 我没有故事板,并希望尽可能避免它们。 有没有办法切换到另一个viewcontroller.swift文件(我们将其称为view2.swift ),并将其作为一个button调用的函数的一部分? 我已经尝试了以下内容: let storyboard: UIStoryboard = UIStoryboard(name: "myTabBarName", bundle: nil) let vc: UIViewController = storyboard.instantiateViewControllerWithIdentifier("myVCID") as UIViewController self.presentViewController(vc, animated: true, completion: nil) 上面的故事板的作品,但我想另一个view2.swift被调用。 可以这样做吗?
我知道IBInspectable-properties的默认值可以设置为: 在Swift中@IBInspectable var propertyName:propertyType = defaultValue 。 但是如何在Objective-C中实现类似的效果,以便我可以将某些属性的默认值设置为Interface Builder中的某些属性?
我创build了一个符合NSCoding的Swift类。 (Xcode 6 GM,Swift 1.0) import Foundation private var nextNonce = 1000 class Command: NSCoding { let nonce: Int let string: String! init(string: String) { self.nonce = nextNonce++ self.string = string } required init(coder aDecoder: NSCoder) { nonce = aDecoder.decodeIntegerForKey("nonce") string = aDecoder.decodeObjectForKey("string") as String } func encodeWithCoder(aCoder: NSCoder) { aCoder.encodeInteger(nonce, forKey: "nonce") aCoder.encodeObject(string, forKey: […]
我的iOS应用程序在注册过程中使用Facebook的graphicsAPI请求获取用户信息,在升级到Facebook最新的SDK之前,这些信息运行良好。 升级之后,我得到一个运行时错误,指出:“FBSDKLog:从Graph API v2.4开始,对/ us的GET请求应该包含显式的”fields“参数。 这里是代码: func requestFacebook() { let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: nil) graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in if ((error) != nil) { // Process error println("Error: \(error)") } else if error == nil { let birthday : NSString = (result.valueForKey("birthday") as? NSString)! var currentDate = NSDate() var […]
当我在Xcode 9 (或以前的版本)中打开项目并检查文件检查器时,有一个名为Project Document的部分,其中有一个名为Project Format的combobox。 可用的选项(在Xcode 9中 )是Xcode 3.1-compatible , Xcode 3.2-compatible , Xcode 6.3-compatible和Xcode 8.0-compatible : 这些格式有什么区别? – 更新历史(截至2017年10月8日) – 当Xcode 6.4出现的时候,我最初问这个问题。 Xcode 6.4的列表包括Xcode 3.1-compatible , Xcode 3.2-compatible和Xcode 6.3-compatible ,默认为Xcode 3.2-compatible 。 Xcode 7没有引入任何改变。 Xcode 8添加了与Xcode 8.0-compatible项目。 Xcode 9将新项目的默认值更改为Xcode 8.0-compatible 。
简单地说,我有一个存储应用程序常量的结构如下: struct Constant { static let ParseApplicationId = "xxx" static let ParseClientKey = "xxx" static var AppGreenColor: UIColor { return UIColor(hexString: "67B632") } } 例如,通过调用Constant.ParseClientKey ,可以在Swift代码中使用这些常量。 但在我的代码中,它也包含一些Objective C类。 所以我的问题是如何在Objective C代码中使用这些常量? 如果这种声明常量的方法不好,那么创build在Swift和Objective C代码中使用全局常量的最好方法是什么?
任何人都可以告诉我怎样才能模仿在iOS 10的新地图应用程序的底部工作表? 在android中,你可以使用“BottomSheet”来模拟这种行为,但是我找不到像iOS那样的东西。 这是一个简单的滚动视图与内容embedded? 所以search栏在底部? 我对iOS编程相当新,所以如果有人能帮我创build这个布局,将不胜感激。 这是我的意思是“底部表”:
我收到的错误是这个 找不到选项'-F / Applications / Xcode-beta.app / Contents / Developer / Platforms / iPhoneSimulator.platform / Developer / SDKs / iPhoneSimulator9.0.sdk / Developer / Library / Frameworks' 我不知道为什么这将是与框架有关?