swift2

Warning: Attempt to present View Controller on * which is already presenting <UISearchController: 0x142a1f7c0>

北城余情 提交于 2020-01-03 17:31:15
问题 I made a view controller with a UISearchController and a UITableView . There are two different kind of search you can select from the search scope buttons : groups and people. Both searches work and show results on the table. However, if you click on each cell they should direct you to different dynamic pages (a dynamic group page or a dynamic person profile page). The one for groups works, while the one for profiles doesn't. Meaning whenever I click on the a person cell from the results that

GameCenter framework image not found error for Xcode 7.0 Beta 4

久未见 提交于 2020-01-03 17:15:27
问题 Does anyone face this issue when trying to run their application on an actual iPhone (iOS version 8.4) using Xcode 7 Beta 4? dyld: Library not loaded: /System/Library/Frameworks/GameCenter.framework/GameCenter Referenced from: /private/var/mobile/Containers/Bundle/Application/CC713E5A-7839-43F1-9AEB-932AE2A3DF8A/.... Reason: image not found For your information, it has been working with no errors before I switch to Xcode 7... 回答1: Looks like the issue is gone in XCode Beta 5. Somebody to

How is it possible to dynamically cast to a Type that is named in a string with Swift 2.0?

若如初见. 提交于 2020-01-03 17:03:37
问题 I need to cast a return value to a specific type that I need to keep dynamic, like let cellType = "CellTypeToBeResolved" cell = (tableView.dequeueReusableCellWithIdentifier("myID") as? CellTypeToBeResolved)! How is this possible in Swift 2.0? Thnx! 回答1: You can't do it, because Swift is (deliberately) missing not one but two pieces of the puzzle: You can't turn a string into a class. More important, you can't cast down to a class expressed as a variable. The class to cast down to must be a

Does swift allow code blocks without conditions/loops to reduce local variable scope? [duplicate]

妖精的绣舞 提交于 2020-01-03 16:47:13
问题 This question already has answers here : How to create local scopes in Swift? (5 answers) Closed 3 years ago . In languages with block level scope, I sometimes create arbitrary blocks just so I can encapsulate local variables and not have them pollute their parents' scope: func myFunc() { // if statements get block level scope if self.someCondition { var thisVarShouldntExistElsewhere = true self.doSomethingElse(thisVarShouldntExistElsewhere) } // many languages allow blocks without conditions

Cannot invoke initializer for type nsdictionary with an argument list of type(objects:String?for key [] string)

眉间皱痕 提交于 2020-01-03 06:32:10
问题 I want to add my data in dictionary in form of key value pair. But They give me error mentioned above. Here is my Code let dictionary = NSDictionary(objects: [getStringAt(selectStmt, column: 0), getStringAt(selectStmt, column: 1)], forKeys: ["username", "image"]) 回答1: The error message says that you're going to create an dictionary with optional String values. Since all values in a dictionary must be non-optional you have to unwrap them. let dictionary = NSDictionary(objects: [getStringAt

How to synchronize coredata with webservices in swift?

亡梦爱人 提交于 2020-01-03 05:46:08
问题 I am making an app (in Swift) which needs to run in offline and online mode. When its in offline mode, data will be stored locally on CoreData. Once it detects network (online) it should sync with server and update the backend database. please help me anyone. 回答1: Recently, I have worked on Offline and Online mode application. First, you have to identify the which record is added, updated and removed from each entity in Offline mode. So to identify this, I have added one extra attribute

Adding values to coredata in swift share extension

自作多情 提交于 2020-01-03 02:45:07
问题 I need to insert and fetch data from coredata in swift share extension. How can I do this class ShareViewController: SLComposeServiceViewController,NetworkSelectionViewControllerDelegate, PublishSelectionViewControllerDelegate,ApproverSelectionViewControllerDelegate{ var selectedNetworkName = "Default" var selectedPublishName = "Select" var selectedApproverName = "Select" override func isContentValid() -> Bool { // Do validation of contentText and/or NSExtensionContext attachments here return

Weird issue during migration from Swift 2 to Swift 3: Initializer has different argument names from those required by protocol

自作多情 提交于 2020-01-03 01:42:13
问题 I'm trying to migrate this (https://github.com/emilwojtaszek/leveldb-swift) project from Swift 2 to Swift 3. I've cleared all 100+ errors during migration except this following one: Initializer 'init(bytes:count:)' has different argument names from those required by protocol 'KeyType' ('init(bytes:length:)') I was struggling to figure out the reason for it past couple of hours and getting no clue of what the problem is, any thoughts? P.S. Here is the link to project with current state of

Printing NSError by NSLog always raises EXE_BAD_ACCESS

你。 提交于 2020-01-02 18:05:51
问题 I have a code for retriving remote json file. I tried to print the error when the network is not available (turing on airplane mode on purpose to produce the error). But every time, it raised a EXE_BAD_ACCESS on the logging line My code is like this: NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()){ (response: NSURLResponse?, data: NSData?, error: NSError?) -> Void in if(error != nil){ let errorDesc = error!.description ?? "" NSLog("HTTP request error = \

ScrollView Not Scrolling to The End of The View

人走茶凉 提交于 2020-01-02 13:51:57
问题 In my ViewController i added a ScrollView and a view inside the ScrollView using StoryBoard (set constraints on ScrollView and the View). now in my code i am using the View to add other views dynamically. the views are being added but my question is related to scrolling. i am able to scroll but it is not scrolling to the last view... i tried doing the following override func viewDidLayoutSubviews() { ScrollView.contentSize.height = contentView.frame.height } but this did not work, also i