swift3

NSCache Doesn't work with all images when loading for the first time

▼魔方 西西 提交于 2019-12-29 05:34:08
问题 I'm woking on a project in swift 3.0 where I cache the response from the server by using NSCache as to populate them in a UITableView. However for some reason I'm only seeing few images loading when the app loads for the first time, but if If i scroll and come back I see everything (end of retrieving the response from the server I reload my tableview too, but seems that not the case). I'm not sure what I''m exactly missing here, the code as bellow as to show how I cache the images. let

'++' is deprecated: it will be removed in Swift 3 [duplicate]

那年仲夏 提交于 2019-12-29 04:33:16
问题 This question already has answers here : The “++” and “--” operators have been deprecated Xcode 7.3 (10 answers) Closed 3 years ago . After update to Xcode 7.3 , there are bunch of warnings showing in my project. '++' is deprecated: it will be removed in Swift 3 Any idea to fix this warning ? Any reasons why the ++ and -- will be deprecated in the future ? 回答1: Since Swift 2.2, you should use += 1 or -= 1 instead. And after looking up Swift's evolution, there are some reasons for removing

Drag UIButton without it shifting to center [Swift 3]

♀尐吖头ヾ 提交于 2019-12-28 18:50:10
问题 So I found out how to make a button draggable using the UIPanGestureRecognizer. But the only way I know how to do it is by storing and dragging the button by the center. The problem with this is if you try and drag the button from a corner, the button instantly shifts from the corner to the center. What I'm looking for is a solution that would keep my finger on a selected place while moving without instantly locking onto the center. The code I'm currently using: func buttonDrag(pan:

private vs. fileprivate on declaring global variables/consts in Swift3?

醉酒当歌 提交于 2019-12-28 18:43:20
问题 Should I use private or fileprivate to declare global variables/consts in Swift 3? e.g. fileprivate let a = 1 fileprivate class SomeClass { fileprivate b = 0 } Or private let a = 1 private class someClass { fileprivate b = 0 } 回答1: It really makes no difference at file level, whether you use private of fileprivate , access control will be the same, for example constants defined this way will be only usable in that file. Same can be said for other modifiers, in certain cases, internal and

OAuth2, Swift 3, Instagram

元气小坏坏 提交于 2019-12-28 12:15:10
问题 There seem to be lots of changes at IG. Many OAuth2 repos, all seem to have bugs, or really not easily converted to Swift3. Wondering if anyone has a solution for moving to Swift3 and working with the latest changes at Instagram? Solutions most welcome. OAuth2 implementation seems to one of the more complicated things out there. Surprised that IG has not offered their own example docs on how to do this with iOS. They only have docs for web based solutions. Maybe something brewing there?

invalid redeclaration in auto code generate NSManagedObject Subclass Swift 3

半城伤御伤魂 提交于 2019-12-28 11:48:16
问题 Using Version 8.1 of Xcode. Create an entity named "MapRegionObject" in .xcdatamodeld file. Using auto code generator, click Editor on the navigation bar -> create NSManagedOject Subclass... Got two files : MapRegionObject+CoreDataClass.swift and MapRegionObject+CoreDataProperties Errors in two files showing in the screenshot: MapRegionObject+CoreDataClass.swift MapRegionObject+CoreDataProperties Please help me fix this bugs, thank you so much! 回答1: In Xcode 8.1, before using the auto code

Different Launch Screen Image or Background Image Sizes for iOS devices

不想你离开。 提交于 2019-12-28 07:09:53
问题 I read some of those website links that explain about exporting different image sizes for iOS device. But I don't really understand of those explaining. (May be I am not good at in English language.) I found these dimension for launch screen. Please let me clarify my understanding to you guys. So, when I create an image, I must create a larger size(@3x) firstly and should export that image into smaller sizes (@2x, @1x). Am I right? For example, I create 1242x2208px (3x) image and scale to 2x

How to change color of text strings inside UITextView in Swift3

浪尽此生 提交于 2019-12-28 06:53:11
问题 I have looked at some existing questions posts here and I tried to implement all code but ended up not being able to successfully implement any code. Actually, I think I comprehended how to change colors of some texts inside UITextView if a text is initially set, but what I do not understand is that when my UITextView began entering editing, it does not seem to be working properly at all. In the following, it is my attempted code that closely full fills my desired behaviour. func

Swift 3 - Alamofilre 4.0 multipart image upload with progress

随声附和 提交于 2019-12-28 06:15:06
问题 I've done with image upload and its successfully uploaded on server using below method. Now I want to upload image with its progress so can any one tell me how to do? I found on everywhere but didn't got the correct solution. Code for image upload without it's progress : @IBAction func uploadClick(_ sender: AnyObject) { // define parameters let parameters = [ "file_name": "swift_file.jpeg" ] Alamofire.upload(multipartFormData: { (multipartFormData) in multipartFormData.append

Popover in swift 3 on iphone ios

回眸只為那壹抹淺笑 提交于 2019-12-28 01:59:50
问题 I am trying to make a popover menu with the following code: import UIKit class BeobachtungViewController: UIViewController, UIPopoverPresentationControllerDelegate { @IBAction func addClicked(_ sender: AnyObject) { // get a reference to the view controller for the popover let popController = UIStoryboard(name: "Personenakte", bundle: nil).instantiateViewController(withIdentifier: "popoverId") // set the presentation style popController.modalPresentationStyle = UIModalPresentationStyle.popover