swift2

Type variable in protocol - Swift 2

a 夏天 提交于 2019-12-13 02:52:14
问题 So I have a protocol, and in it I want a variable that is a class type. That way I can init that class from the variable. Keep in mind that there will be many different classes. I made a quick example. I get the error "type 'CashRegister' does not conform to protocol 'RegisterProtocol'" This example isn't exactly what I'm doing, but it gets the point across. Thanks for the help. protocol RegisterProtocol { var currentBill: DollarBillProtocol {get set} func makeNewBill()->DollarBillProtocol }

Add UIView to back of scene in SpriteKit game

大城市里の小女人 提交于 2019-12-13 02:39:15
问题 I am trying to make a advent calendar with a snow affect in swift2. I am using the game template while using SpiteKit. Here is my code so far: GameScene.swift import SpriteKit class GameScene: SKScene { /*override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { if let touch = touches.first { let location = touch.locationInNode(self) print(location) } }*/ func test() { //Generate Doors //Initilization var adventDoors = [AdventDoor]() let offset = CGVector(dx: 10,dy: 10)

Swift. SIGABRT: cast value of type '__NSCFDictionary' to 'NSMutableArray'

微笑、不失礼 提交于 2019-12-13 02:37:16
问题 I'm making a converter app. I want to save the conversion historic. I saw this tutorial and it works fine but when I tried to use it on my app I'm getting a SIGABRT. Could not cast value of type '__NSCFDictionary' (0x57945c) to 'NSMutableArray' (0x5791c8) I'm getting this at notesArray = try NSPropertyListSerialization.propertyListWithData(data, options: NSPropertyListMutabilityOptions.MutableContainersAndLeaves, format: nil) as! NSMutableArray EDIT: AppDelegate: import UIKit

Add username, profile picture, etc to sign up with Firebase (Swift 2)

给你一囗甜甜゛ 提交于 2019-12-13 02:34:10
问题 Hey guys I've been watching some courses of making social apps and all of them were made with Parse, so now that I can't use it for the future because is shutting down I'm using Firebase. The thing is Firebase has some information about authenticate user with email and password and I don't know how to send the username, profile picture, bio, etc's user information to Firebase. Any help? Thank you. 回答1: You can authenticate the user https://firebase.google.com/docs/auth/ios/password-auth, then

convert a String to NSAttributedString in a specific manner

不羁的心 提交于 2019-12-13 02:18:38
问题 so i have a String which looks like this : Swift , VisualBasic , Ruby i wanna convert this string to something like this : basically i wanna create a background behind a single word , yeah i can use the NSTokenField libraries for getting this behaviour but my text is not manually entered by user its pre structured (from an array) and i dont want the whole behaviour of NSTokeField i just want the appearance like this and selection (by selection i mean to clear a word at one single tap on

Change Tick Labels for Coreplot Graph

…衆ロ難τιáo~ 提交于 2019-12-13 02:18:14
问题 I am using coreplot for graphs in my mac application & its working fine. I have a requirement to show custom labels along the axis for ticks like : I have a graph for power values against time : Power values -> Y-Axis & Time -> X-Axis . I want to draw graph for Time seconds values but show fixed intervals ticks of minutes along x-axis for which i figured that i should use custom labels but its not happening for me. Code for custom labels is : let graph = CPTXYGraph() plots[0].identifier =

Swift 2.0 exception handling

蹲街弑〆低调 提交于 2019-12-13 02:12:17
问题 We want to know error handling mechanism in SWIFT for whole block of code. As, in swift, there are some techniques used for error handling, some of them are like using guard or if let . Also we can achieve it using do - catch statement. But we are getting stuck while handling error for whole bunch of code using single try-catch block as we were doing in Objective-C . In Objective-C this block was easily handling errors within any line of code in it. So we want to know this type of mechanism

AGPushNote alternative for Swift? [closed]

南笙酒味 提交于 2019-12-13 02:07:16
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . Just as the title says, do you know any alternative of AGPushNote for Swift ? In order to better understand what I was searching for when I found out on SO about this, I would like to .. "detect" when push notifications are incoming and app is active so I can prevent the notifications from showing up and do some

Cannot convert value of type 'NSMutableArray' to expected argument type '[SKAction]'

佐手、 提交于 2019-12-13 01:37:57
问题 I checked my old game (made in SpriteKit) and I want to update it in Swift 2.0. When I tried to fix it, Xcode found an errors. Error is: Cannot convert value of type 'NSMutableArray' to expected argument type '[SKAction]' In code: torpedo.runAction(SKAction.sequence(actionArray)) Function: override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) { self.runAction(SKAction.playSoundFileNamed("torpedo.mp3", waitForCompletion: false)) var touch:UITouch = touches.anyObject() as

sknode can't see added children

徘徊边缘 提交于 2019-12-13 01:26:24
问题 Here i created a menu class which contains a few items. I want to display these sprites in the main class. I experimented with this by creating an object associating with the sknode class in the touches began method, but when i added the menu object in the main class using the addChild thing, nothing showed up. class menu:SKNode { let background = SKSpriteNode(imageNamed:"background") required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } override init