swift2

Workaround to submit app to app store with Xcode 7

五迷三道 提交于 2019-12-23 18:05:33
问题 When trying to submit an app compiled with Xcode 7 to iTunes Connect for review, I get an error message Apps and app updates submitted to the App Store must be built with Xcode 5.1.1 or later, and iOS 7 SDK. Is there any workaround to this? I've already updated all of my code to Swift 2.0, and I would like to not have to convert it all back to Swift 1.2 to upload it. Setting the Deployment Target to iOS 8.0 doesn't work, either Are there any ways that I can compile the Swift 2.0 code in a way

No back button in Swift 2

自闭症网瘾萝莉.ら 提交于 2019-12-23 17:26:05
问题 I updated my project to Swift 2.0. When I move from the UITableViewController to the UIViewController , Navigation Item doesn't show back button. Each controller has UINavigationController and I use the show segue. This code when I move to other controller override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { tableView.selectRowAtIndexPath(indexPath, animated: true, scrollPosition: UITableViewScrollPosition.None) if searchPredicate == nil {

How to refer to a global type from within a class that has a nested type with the same name?

对着背影说爱祢 提交于 2019-12-23 17:17:59
问题 I have a class declared at the global scope and another class with the same name that is nested within some class. class Address { var someProperty: String? } class ThirdPartyAPI { class Address { var someOtherProperty: String? init(fromAddress address: Address) { self.someOtherProperty = address.someProperty } } } The question is: how can I refer to a global class instead of the inner one from its initialiser? In the example given I've got an error Value of type 'ThirdPartyAPI.Address' has

Using Object Initializers in Swift to replace AllocWithZone

爱⌒轻易说出口 提交于 2019-12-23 16:23:28
问题 I recently updated my Xcode from Xcode 7 beta 4 to Xcode 7 beta 5 and began to have an error that wasn't present before. That being: "AllocWithZone is unavailable in Swift: use Object Initializers instead." Here is the code where the error is found: public func copyWithZone(zone: NSZone) -> AnyObject { let copy = self.dynamicType.allocWithZone(zone) as ChartDataSet copy.colors = colors copy.label = self.label return copy } What do I substitute in place of ".allocWithZone" so that it utilizes

fatal error: init(coder:) has not been implemented Xcode 7 iOS 9

安稳与你 提交于 2019-12-23 16:21:14
问题 I updated an Xcode 6 / iOS 8 project last night and seem to have ran into a few issues. One of them being is it's throwing a fatal error message and crashing the app. When a button is pressed I'm trying to set up the next. let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("gameViewController") self.presentViewController(viewController, animated: true, completion: nil) Then inside the gameViewController I have this: required

OBD2Kit Swift example can't typecast, keep getting nil

蹲街弑〆低调 提交于 2019-12-23 16:03:37
问题 Since there was no example code for using OBD2Kit and Swift I forked it into https://github.com/YannisDC/OBD2Kit and used it as a pod. I translated some OBJ-C example code but can't seem to downcast the FLWiFiScanTool into the ELM327 type. Why do I keep getting nil? import UIKit import OBD2Kit class ViewController: UIViewController, FLScanToolDelegate { @IBOutlet weak var hostIpAddress: UITextField! var scanTool: ELM327! @IBOutlet weak var statusLabel: UILabel! @IBOutlet weak var

parse json object in swift 2

為{幸葍}努か 提交于 2019-12-23 14:53:26
问题 I am new in iOS and Swift programming, I am trying to make a method to parse json object My json is as following { status : true; data :[ "url" : "", "startDate" : "", "endDate" : "", ... ] } my code in swift is like that import Foundation class SplashResponse { let STATUS = "status"; let DATA = "data"; let URL = "Url" let CONTACT_NO = "ContactNo"; let SPLASH_IMAGE = "SplashImage"; let SPLASH_ID = "SplashId"; let TITLE = "Title"; let NO_VIEW = "NoView"; let IS_ACTIVE = "isActive"; let START

How to fix C-style for statement?

十年热恋 提交于 2019-12-23 14:23:15
问题 What is right way to fix C-style for statement for the code which is posted below? Currently I am getting this warring: C-style for statement is deprecated and will be removed in a future version of Swift var ifaddr : UnsafeMutablePointer<ifaddrs> = nil if getifaddrs(&ifaddr) == 0 { // Warning for (var ptr = ifaddr; ptr != nil; ptr = ptr.memory.ifa_next) { // Do some stuff... } } 回答1: You could convert the for loop into a while loop: var ptr = ifaddr while ptr != nil { // Do stuff ptr = ptr

DIfferent Scroll direction for multiple sections of Collectionview in swift 2

风流意气都作罢 提交于 2019-12-23 14:01:48
问题 I have an app with UICollectionView with 2 sections.My requirement is to have the first section should scroll in horizontal direction with one row only, while the second should scroll in vertical direction.I am working with Swift 2.1. Please advice some solutions. 回答1: Your UICollectionView with 2 sections Section 1: have only one UICollectionViewCell will contain a UICollectionView (horizontal direction) defined by its datasource. Section 2: your current datasource. You can check this one:

NSFileManager.defaultManager().createFileAtPath() returning false

百般思念 提交于 2019-12-23 12:37:21
问题 After like a thousand print() statements, I have finally pinpointed the problem! However, I'm not sure how to fix it. The problem lies in the line: NSFileManager.defaultManager().createFileAtPath(savePath, contents: data, attributes: nil) According to the Apple Developer's guide, this line of code returns true if the operation was successful or if the item already exists, otherwise false. This line is returning a false and I'm not exactly sure why because the code preceding the line seems to