Questions tagged [swift-class]

25 questions
0
votes
0 answers

Why does Xcode not see my Cocoa Touch Framework in my project?

I created an Xcode project and then added a Cocoa Touch Framework target. I then drag and dropped files from another instance of Xcode with a different Cocoa Touch Framework project open. Why doesn't Xcode see the declared identifiers in my…
daniel
  • 1,446
  • 3
  • 29
  • 65
0
votes
1 answer

I have a confusion if any methods are declared in class extension are static or not

class Test: UIViewController{ func abc() { print("This is ABC") } } extension Test { func def(){ print("This is DEF") } } My question here is that what is the difference between both the methods declared? Is…
0
votes
2 answers

Swift addChild from Custom Class

i have a problem. I made swift custom class test.swift and want to add a sprite from this Class to the the GameScene.swift This is my custom Class import SpriteKit import GameplayKit var scene = GameScene() class test: SKSpriteNode{ func…
Devil089
  • 67
  • 2
  • 9
0
votes
1 answer

How can I use a class extension to override a protocol extension?

Let's say I have a color model: protocol Color { var value: String? { get } } class UnknownColor: Color { let value: String? = nil } class KnownColor: Color { let value: String? init(value: String? = nil) { self.value =…
G-P
  • 111
  • 4
0
votes
1 answer

Controllers in my code base in swift is defined as struct not classes

I am from Objc background & new to swift. What does this comment means "/// Used in a static manner" /// Used in a static manner struct RecentItemsController { fileprivate init() { } } DO I really need this init()? In the whole code base I…
user804417
  • 155
  • 2
  • 13
0
votes
3 answers

Accessing class instance in swift

I've got a Graph class which is an UIView and I'm initializing it inside mainVC.swift: class MainVC : UIViewController{ let graph : Graph! override func viewDidLoad(){ super.viewDidLoad() let data_x : [Double] = [...] let…
mikro098
  • 2,173
  • 2
  • 32
  • 48
0
votes
1 answer

Invalid type in JSON write error trying to send custom class via JSON to .NET web service

I am trying to send data to a .NET web service that accepts three parameters whose types are (String, String, QBUser Class). In Javascript, I would send the parameters in JSON like so: {sKey: "key", sUpdatetype: "edit", oQbUser: QBUser} I have…
Erik Grosskurth
  • 3,762
  • 5
  • 29
  • 44
0
votes
1 answer

How to use multiple subclasses for function parameter

Say I have 2 subclasses of a class but would like to pass either of those subclasses to a function and determine its type within the function how would that be done? class ParentClass { ... } class subClass1: ParentClass { ... } class…
Sean Cook
  • 435
  • 7
  • 21
-2
votes
1 answer

Swift 4: How to initialise a class with values in one line?

I have a simple class in Swift 4 like this: class Message { var messageBody : String = "" var sender : String = "" } And I want to (in one line) populate a variable with an instance of this object. I tried to do it like this: func…
J. Hesters
  • 13,117
  • 31
  • 133
  • 249
-3
votes
1 answer

How to perform class nil checks

I have a class in Swift: class myClass { var theBool : Bool init(theBool: Bool) { self.theBool = theBool } init() { self.theBool = false } } Elsewhere in my code, I have this check: classist = myClass() if…
Blue
  • 1,408
  • 4
  • 17
  • 36
1
2