swift2.3

How to add GIF images to Assets folder and load them in UIImageView programmatically

可紊 提交于 2020-05-10 15:41:50
问题 I am trying to put my @2x and @3x GIF images into the Assets folder in Xcode. I have tried the following links but it didn't work for me. Link 1 and Link 2. I am currently loading the GIF files by adding them to my project bundle and accessing it using this let bundleURL = NSBundle.mainBundle() .URLForResource("phone_animation", withExtension: "gif") But I want to load them from my Assets folder. Is there a way I can do it? And how do I load them into my imageview after adding it to Assets?

How to add GIF images to Assets folder and load them in UIImageView programmatically

自作多情 提交于 2020-05-10 15:39:12
问题 I am trying to put my @2x and @3x GIF images into the Assets folder in Xcode. I have tried the following links but it didn't work for me. Link 1 and Link 2. I am currently loading the GIF files by adding them to my project bundle and accessing it using this let bundleURL = NSBundle.mainBundle() .URLForResource("phone_animation", withExtension: "gif") But I want to load them from my Assets folder. Is there a way I can do it? And how do I load them into my imageview after adding it to Assets?

Swift NSDate showing UTC when printing in debugger. How do I know if it's local time or utc when comparing date/times?

拈花ヽ惹草 提交于 2020-01-17 15:18:05
问题 I'm trying to write some code for a scheduling app and these schedules need to be based on the user's current time. Example, something is available between 5pm and 9pm on the current day. When I get the current time by using NSDate(), printing it results in utc: 2016-12-15 13:12:05 +0000. I know that it's in utc because if I add my local time zone offset in my head, it works out to be the actual time on my phone. The problem I'm having is when trying to create these time windows, sometimes

Cannot convert value of type String to specified type NSManagedObjectContext, While converting from Swift 2.3 -> 3.2

送分小仙女□ 提交于 2020-01-06 04:33:34
问题 I need Help. While conversion from Swift 2.3 -> 3.2 I received below error. I'm not able to resolve this error. Below is my coding stuff, where I'm facing some issues. Error1 : Cannot convert value of type String to specified type NSManagedObjectContext** Error2 : Cannot convert return expression of type URL to return type URL. class func persistentFileURL(_ name: String, enclosingDirectoryName: String) -> Foundation.URL { let directoryURL = self.directoryForPersistentStorage

UIKeyboardTaskQueue may only be called from the main thread

浪子不回头ぞ 提交于 2020-01-01 07:28:49
问题 I have a problem while trying to make a function that automatically create POST request, send them, get the response, and handle them then show UIAlertView to tell the user which problem it is. Here is my code : let task = session.dataTaskWithRequest(request, completionHandler:{ (data, response, error) -> Void in dispatch_async(dispatch_get_main_queue(),{ var alert = UIAlertController(title: "Chargement", message: "Envoi des informations...", preferredStyle: UIAlertControllerStyle.Alert)

Swift2.3 code for Beacon detection

故事扮演 提交于 2019-12-29 04:57:08
问题 We are in advanced stages of developing a Swift2.2 app and hence have decided to migrate to 2.3 in the interim and do the full Swift 3 migration later. However we are unable to get beacon detection working post conversion to Swift 2.3. The method "didRangeBeacons" keeps returning an empty array. The same code was working in Swift 2.2 so we know we have all the permissions etc in place. Also if we open the "Locate" app on the same ipad then our app also starts returning data in

Can't add UInt64 to dictionary of type: [String : AnyObject?]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-25 09:16:31
问题 I am trying to make a dictionary like this: func someFunc() -> [String : AnyObject?] { var dic = [ "Name": someString_Variable, "Sum": someUInt64_Variable ] Problem is when I add someUInt64_Variable I get error: Cannot convert value of type UInt64 to expected dictionary value type Optional<AnyObject> What to do here, I must use UInt64 I can't convert it to String . Why am I getting this error anyway? 回答1: This used to work in an earlier version of Swift when Swift types were automatically

Swift2.3: NSMutableDictionary store integer from sqlite

无人久伴 提交于 2019-12-25 08:29:15
问题 Actually, I have no idea what is NSMutableDictionary, but it seems I need it By the way, I use xcode 8 with swift 2.3. I am adding a integer to this arry from sqlite, but it's error The other are all the string, so they are not problem here. Then, the error is here http://imgur.com/a/Gbrp0 let recipeIsFavor = sqlite3_column_int(statement, 3) let recipe_isFavor = Int.fromCString(UnsafePointer<CInt>(recipeIsFavor)) //<--------I wnat to use int here, but I have no idea. What should I do to edit

How to check if a user is logged in and if not redirect to the login screen

老子叫甜甜 提交于 2019-12-24 06:47:10
问题 I have my login screen embedded in a UINavigationController and my home page screen embedded in a UITabBarController . My login page was done programmatically and TabBarController was created using storyboards . In AppDelegate.swift file I made the the login screen the rootViewController . But now I want to check if the user is logged in and make the TabBarController the rootViewController , and if the user isn't logged in, redirect to the login screen, then segue to the TabBarController and