Resultados da pesquisa a pedido "swift"
Passando listas de uma função para outra no Swift
Não consigo entender por que não consigo colar um Int [] de uma função para outra: func sumOf(numbers: Int...) -> Int { var sum = 0 for number in numbers { sum += number } return sum } func average(numbers:Int...) -> Double { var sum ...
Obter valor inteiro da string em swift
Então eu posso fazer isso: var stringNumb: NSString = "1357" var someNumb: CInt = stringNumb.intValueMas não consigo encontrar o caminho para fazê-lo com umString. Eu gostaria de fazer algo como: var stringNumb: String = "1357" var someNumb: ...
Os playgrounds do Swift podem ver outros arquivos de origem no mesmo projeto?
Criei a classe personalizada mais simples em um arquivo Swift separado no meu projeto: class Foo { init() { println("I made a foo.") } }Então, em um playground dentro do mesmo projeto, tentei var x = Foo()O Xcode não parecia gostar disso e me ...
Idioma rápido NSClassFromString
Como alcançarreflexão [http://en.wikipedia.org/wiki/Reflection_%28computer_programming%29#Objective-C] em linguagem rápida? Como instanciar uma classe [[NSClassFromString(@"Foo") alloc] init];
NSIndexPath? não possui um erro de 'linha' no nome do membro no Swift
Estou criando um UITableViewController com linguagem Swift e em um método override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?Estou recebendo este erro NSIndexPath? não possui um ...
Como definir a enumeração da máscara de bits da categoria para o SpriteKit no Swift?
Para definir uma enum de máscara de bits de categoria no Objective-C, digitei: typedef NS_OPTIONS(NSUInteger, CollisionCategory) { CollisionCategoryPlayerSpaceship = 0, CollisionCategoryEnemySpaceship = 1 << 0, CollisionCategoryChickenSpaceship ...
Suprimindo devoluções implícitas no Swift
Considere o seguinte conjunto de funções: func testFunc(someFunc: (Int[]) -> ()) { someFunc([1, 2, 3]) } func someFunc<T>(arr : T[]) -> T[] { return arr } func someOtherFunc<T>(arr : T[]) { println(arr) } // case 1 - ERROR testFunc() { ...
Como posso usar o NSTimer no Swift?
eu tentei var timer = NSTimer() timer(timeInterval: 0.01, target: self, selector: update, userInfo: nil, repeats: false)Mas, recebi um erro dizendo '(timeInterval: $T1, target: ViewController, selector: () -> (), userInfo: NilType, repeats: ...
O que significa um ponto de exclamação no idioma Swift?
O guia da linguagem de programação Swift [https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/AutomaticReferenceCounting.html] tem o seguinte exemplo: class Person { let name: String init(name: ...
Usando isKindOfClass com Swift
Estou tentando pegar um pouco da linguagem Swift e estou pensando em como converter o seguinte Objective-C em Swift: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; UITouch *touch ...