swift generic parameter issue

What is wrong with the code below?: // Returns a list of news sources for the given category func loadNewsSources() -> [NewsSource] { return fetchEntity<NewsSource>(name: "NewsSource") } // Returns the list of categories func loadC...
more »

2017-05-20 22:05 (0) Answers

How to implement model in two apps?

I am working on a Mac app written in Swift. In order to execute some code on login, I created a helper app. The helper app needs to access data from the main app. Thus, I enabled "App Groups" for both main and helper app, to share data via UserDefaul...
more »

2017-05-20 21:05 (1) Answers

Value of type NSSet has no member image

I have a core data app using xcode 8.3.2 can't figure out what I am missing hopefully I am providing enough context to explain here in my tableview custom cell class class CustomerCell: UITableViewCell { @IBOutlet weak var thumb: UIImageView! @I...
more »

2017-05-20 18:05 (2) Answers

ScanPeripherals with specific service uuid

I want to make my app can running in background. I've search about that and many references said that I must specified service UUID. when i do : centralManager.scanForPeripherals(withServices: nil, options: [CBCentralManagerScanOptionAllowDuplica...
more »

2017-05-20 18:05 (1) Answers

Path to bundle of iOS framework

I am working on a framework for iOS, which comes with some datafiles. To load them into a Dictionary I do something like this: public func loadPListFromBundle(filename: String, type: String) -> [String : AnyObject]? { guard let bundle ...
more »

2017-05-20 14:05 (2) Answers

Shared instances and global variables

I am using the Spotify SDK and have followed the instructions from this tutorial: https://medium.com/@elonrubin/ios-spotify-sdk-swift-3-0-tutorial-b629af4b889d The guide uses this function to initialize the SpotifyPlayer: func initializeSpotifyPlaye...
more »

2017-05-20 08:05 (1) Answers

selector with argument gestureRecognizer

Argument of '#selector' does not refer to an '@objc' method, property, or initializer Problem : Above Error when i try to pass argument with selector code snippet: let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selecto...
more »

2017-05-20 06:05 (3) Answers

Border has background color seeping through it

I'm setting the background color to a white border and the border is seeping through the background.I'm looking to have the blue line gone. Can you please suggest a solution to this problem? Here is my code below. And there is an image of what I'm ...
more »

2017-05-20 01:05 (1) Answers

Swift Draw a route for an array of value

Hi I have an array like this route = [[latitude,longitude],[latitude,longitude]...]. I should draw a line that follows the arrays coordinates. I tried with this function: func addPolylineToMap(locations: [CLLocation]){ var coordinates = locati...
more »

2017-05-20 00:05 (1) Answers

Adding UIView That Will Contain Input

So basically I have this page control view that I created that someone would segue into upon hitting the login or register button. So when it segues to that page view I attempted to setup a UIView on that page so a user can type in required info. Co...
more »

2017-05-19 19:05 (1) Answers

String to enum mapping in Swift

I have an enum defined in Swift as follows: public enum Command:String { case first = "FirstCommand" case second = "SecondCommand" ... ... case last = "lastCommand" } Now I receive a command dictionary from server and I extract t...
more »

2017-05-19 18:05 (4) Answers

iOS swift Cache Policy

I am working with Afnetworking API, when I have bad internet connection API takes lots of time to load. So I have decided to use Cache policy Singleton.sharedInstance.requestSerializer.cachePolicy = .returnCacheDataElseLoad It works fine but when I ...
more »

2017-05-19 17:05 (0) Answers

xcode view doesn't show url image

I'm studying the iOS development course of Stanford, and I copied the sample code that worked perfectly fine in the course to my Xcode. The view just doesn't show the url image and I have already set the Allow Arbitrary Loads in info to "yes". There ...
more »

2017-05-19 16:05 (0) Answers

Creating generic Swift createOrUpdate method

I'm currently trying to create a generic createOrUpdate function. Ideally I want to be able to, on any subclass of NSManagedObject, call: Type.createOrUpdate(withID: id) { type in // Code goes here assigning variable on the object } Where Type is...
more »

2017-05-19 16:05 (0) Answers

How to store \"> in a Swift string?

I'm trying to store \"> in a string. Theoretically, "\\" should print \ and "\"" does print ". However, when I try to print \ in a string using \ the output is a double forward slash: var str = "\">" // "> var str2 = "\\" // \\ var str3 = "\...
more »

2017-05-19 16:05 (3) Answers

Label is not updated, why?

func getLastPriceForFromBtceForPair()->(ethLast:String,btcLast:String){ var btcUSDLast = "" var ethUSDLast = "" let APIURL = "https://btc-e.com/api/3/ticker/btc_usd)" let APIURL2 = "https://btc-e.com/api/3/ticker/eth_usd)" A...
more »

2017-05-19 13:05 (2) Answers

swift convenience init and generic class

I have a problem creating a convenience init method that then calls a designated init on a class with generic type parameters. Here is the swift 3.1 XCode Version 8.3.2 (8E2002) playground protocol A { var items: [String] { get set } func d...
more »

2017-05-19 11:05 (1) Answers