found nil while unwrapping optional in UIImage

I am very new to swift and cant figure out how to programmatically change the picture in a UIImageView. i have tried this so far: if let image = UIImage(named: "mouse.jpg") { imageView.image = image print("image set") } but it causes the ...
more »

2017-04-18 22:04 (1) Answers

How to use Realm objects with Swift generic type?

I have generic class Child. At some point I want to check if Child object conforms to MyProtocol and I get the error EXC_BAD_ACCESS. At this point I dont know if this is related to Swift or to Realm library. protocol MyProtocol: class { } class Ch...
more »

2017-04-18 21:04 (0) Answers

Implementing search to map view controller

In my project i have a mapView with a lot of annotations & i would like to add a search functionality to the map so i can search those annotations and quickly find the annotation i want. I followed a tutorial i found on the web but it searches g...
more »

2017-04-18 19:04 (1) Answers

Initialize struct from Data in Swift 3

I have a Struct named MyContiguousStruct whose memory layout has no padding. struct MyContiguousStruct { let ivar1: UInt8 let ivar2: UInt8 let ivar3: UInt16 let ivar4: UInt16 } My initializer works (great) like this: init?(data: D...
more »

2017-04-18 18:04 (1) Answers

Avoid fetching image again when cell in view

I have managed to get some code working where Instagram pictures are fetched (via Alamofire) when a table row comes into view. However, once fetched, I don't want another call being made when the table row comes into view again. How can I avoid this ...
more »

2017-04-18 17:04 (2) Answers

Add comment on image file header

I want to add a comment(s) in image file header. As I able to add a comment on EXIF metadata under UserComment but I want to add multiple comments in image file header. Which framework do I use? For UserComment, I am using ImageIO framework. ...
more »

2017-04-18 08:04 (0) Answers

Unable to track memory issue

I am having problem on memory leak tracking, i did try profiling but the instrument shows firapb_decode_repeated_user_attribute as as responsible object. And while i try to track code it takes me to assembly code which is more painful. Do anybody ha...
more »

2017-04-18 07:04 (2) Answers

Multiple checkmark in Tableview in swift3

How to do the multiple checkmark in tableview. I need to select the multiple checkmark in tableview and what are the checkmarks I need to select to place the multiple values in label. Example player1,player2,player3 in label here is my code func t...
more »

2017-04-18 07:04 (2) Answers

Firebase persistence in swift 3

As per firebase official documentation for swift we should use following line to enable persistence in iOS. Firebase.defaultConfig().persistenceEnabled = true But if we use the above line in swift 3.0 it gives error. Any idea how to enable per...
more »

2017-04-18 07:04 (1) Answers

view swift interface for Objc file

I am working in a mixed ObjC Swift project. I am currently overriding functions that where written in ObjC in a swift subclass. I'm wondering if there is a quick way to view the auto generated Swift header files for the objC file so that I can check ...
more »

2017-04-18 05:04 (1) Answers

NSOpenPanel Hiding Xcode Debug

I am working on an app that uses NSOpenPanel. The problem is that during debugging with Xcode the panel does not fully hide itself. A white rectangle is left being displayed over everything else. I have tried using a completion handler to resolve thi...
more »

2017-04-17 23:04 (0) Answers

Dynamic typealias Swift 3

I'm trying to set a typealias with a conditional like this: typealias dataType = (x == y ? ButtonTableCell : InputTableCell) Where both ButtonTableCell and InputTableCell are classes, so later I can use dataType like this: let cell =
more »

2017-04-17 21:04 (1) Answers

CGAffineTransformScale in Swift 3.0

Swift 3.0 does not have a method called CGAffineTransformScale. func didPinchGesture(pinchRecognizer : UIPinchGestureRecognizer) { if let view = pinchRecognizer.view { view.transform = CGAffineTransformScale(view.transform, ...
more »

2017-04-17 20:04 (2) Answers

Swift not finding the correct type

I am trying to use SwiftHamcrest I have a function func equalToArray<T, S>(_ vector:Array<S>) -> Matcher<T> { let v: Matcher<T> = Hamcrest.hasCount(16) return v } This gives an error Error:(16, 31) 'hasCount' prod...
more »

2017-04-17 19:04 (1) Answers

Create IBAction for CollectionViewCell

I've got a collection view with multiple cells created programically. I want to update a variable to a different value when the user taps a specific cell. So eg: Cell 1 is tapped -> var test = "cell1" , cell2 is tapped var test = "cell2". Usually I'd...
more »

2017-04-17 18:04 (2) Answers

One of two collection views not showing up

I've been trying to diagnose the problem here but I really can't figure out what went wrong. I had a collection view (of messages) showing up fine, until I added an additional collection view in the navigation bar. This is the setup for the second c...
more »

2017-04-17 16:04 (0) Answers

Calculating Angle of Reach in Scenekit

I'm trying to calculate the Angle of reach to hit a target in a scenekit scene. My maths ability is about 3/Potato, but after a few hours on Khan Academy, I think I've managed to tease out the logic of this "Angle of Reach" formula from wikipedia, (W...
more »

2017-04-17 14:04 (1) Answers

Swift + Xcode: use osascript in Mac App

I want to ask if you can use osascript in swift/xcode when designing a Mac (Sierra) app. So I've basically just built an empty app using Xcode and swift. I would now like to use osascript to launch another app using osascript (preferred). So I've l...
more »

2017-04-17 11:04 (1) Answers