Profile Photo
I have many models that, depending on the endpoint, or serialized differently. My first attempt had a init(from decoder: Decoder) riddled with nested try catch blocks. I thought a better solution would be to extend JSONDecoder so that when I initialize one, I can specify which endpoint i am pulling from. Then in my models init(from decoder:… (Show more)
in Swift
Profile Photo
According to the documentation ("Interface Behaviors" section), if we need to support different orientations for the controllers in a navigation view, we should use "navigationControllerSupportedInterfaceOrientations" via delegation. Thus, we would be able to return the preferred orientation of each of the controllers by overriding, for example,… (Show more)
in Swift
Profile Photo
I have a very confusing situation that I can't figure out. I'm not quite fluid in swift so please bear with me if this is a rookie mistake. So let's say I have a variable x let number = Int.random(in: 0 ... 5)… (Show more)
in Swift
Profile Photo
Hello! I've been trying to use URLComponents().url to get a URL object from some predefined URL pieces, but every time, URLComponents.url returns nil. I spent a bit figuring that I had gotten my URLComponent pieces wrong, but I eventually output the URLComponents.string value to my debugging console and got the URL string that I was looking for.… (Show more)
in Swift
Profile Photo
I returned to an old Cocoa project. Written in Swift 2… by someone very helpful and knowledgeable (he will recognize himself) So I found a Mac to load XCode 8 to convert first to Swit3.   I stumble on a few lines   1. Deprecation of DynamicType Swift2 code was: In a class declared as:   @objc(AAPLLoopLayout)… (Show more)
in Swift
Profile Photo
Hello:   I am working with a tutorial that will help me in designing my Mac Os app.   I have the following code that is generating and error "index out of ragne" crash: on line 35. The array is in a .plist file with 5 items in each array [0,1,2,3,4].   Lines 28 - 38 is supposed to do the following:   It removes all items in the pop-up button,… (Show more)
in Cocoa
Profile Photo
Hi! I am developing an app (in XCode Version 11.2 and Swift 4.2) in which I fill in a LinkedList and after working with it, removing the elements that compose it produces the Thread 1 error: EXC_BAD_ACCESS (code = 2, address = 0x16d0f3ff0). The error occurs even without working with the items in the list, simply by adding them and trying to… (Show more)
in Swift
Profile Photo
Hello:   I have this piece of code that seems very straightforward but three errors persist and I can't figure out why. lines 6, 7, 21 raise errors but I thought that the variable was declared on lines 6 and 7!     import Cocoa… (Show more)
in Cocoa
Profile Photo
I want to save the value from the "points" key from a dictionary called myInfo in myPoints variable so I can use it in another function. I have been trying to cast it as Int, but the value when printed out is always 0. Meanwhile, if I just print out temp, it prints the value out correctly. result with print(type(of: temp)) is Optional< Any >
in Swift
Profile Photo
Hi guys,   I want to replace colors of an image using color cube. The methods below work pretty well for any color besides black and white, which means, I can't replace black and white color. Can any one help me why this the case? func render() {… (Show more)
in Swift
Profile Photo
Hi All. Writing a swift iOS app (target iOS 13.1) and wanted to know if AVAudioPlayer or something else would fit these requirements:   - Stream from URL (with auto-reconnect if network hiccups) - Stop and Start button (obviously) - Ability to choose the stop/start button images - Volume slider - Ability to use the switch object to switch… (Show more)
in AVFoundation (Audio)
Load more items