Skip to main content
8 votes

"What To Do" App

The instance variables var userText : String = " " var randomNumber : Int = 0 are not needed: userText is only used within <...
Martin R's user avatar
  • 23.3k
3 votes

Better way to provide data to UIKit component from Combine pipeline

This looks fine. A bunch of minor observations: WebService.swift should import Foundation, not ...
Rob's user avatar
  • 2,552
2 votes
Accepted

A helper class for creating icons from a PNG image and colour in Swift

let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) can be simplified to ...
Martin R's user avatar
  • 23.3k
2 votes
Accepted

Adding dragging ability to a UIView using UIKitDynamics

Comparing an optional value with nil as in return getValue == nil ? false : getValue! is better done with the nil-coalescing ...
Martin R's user avatar
  • 23.3k
2 votes
Accepted

UITableView, auto locate back at indexPath when user drags it

A couple of observations: You are handling scrollViewDidEndDecelerating. But what if there was no deceleration? E.g. you’d generally want to call some common ...
Rob's user avatar
  • 2,552
2 votes
Accepted

Core Data Wrapper

Well, if it works for you, it's fine :) Here are the things that bother me: Because inserting new objects in Core Data is quite an important operation, and is independent of saving, and since two of ...
Jerry Krinock's user avatar
1 vote

Building a UITableView with fixed number of cells progammatically

Using a table view for this sort of thing is inappropriate IMO. A UITableView is designed for displaying an array of items, not bits and pieces of a single item. That's why having the constant in <...
Daniel T.'s user avatar
  • 831
1 vote
Accepted

Best way to do Input Validation on Swift/iOS/UIKit

One can make the error conform to LocalizedError: ...
Rob's user avatar
  • 2,552
1 vote
Accepted

iOS: prettify random color for debugging

I've had a look, and think it should be possible to trim down the ColorCluster-logic quite a bit, mostly by tightening up the get(: function a bit. Avoiding some if-...
T. Benjamin Larsen's user avatar
1 vote

Change level button's image

DRY - Don't Repeat Yourself: 1) change this block into an method: ...
muescha's user avatar
  • 278
1 vote

Draw grid programatically with borders

I solved it by drawing the borders 1px outside of the squares bounds. This way I was able to simplify my method enormously: ...
dehlen's user avatar
  • 143
1 vote
Accepted

UIViewController without interfacebuilder

Grouping all of the view components into a single view can make views easier to reuse, which can be useful in some circumstances. However, it is not necessary to create a separate view for each view ...
Luke Van In's user avatar
1 vote
Accepted

Proper cellForRowAtIndexPath cell return in Swift

First note that func dequeueReusableCellWithIdentifier(identifier: String, forIndexPath indexPath: NSIndexPath) -> UITableViewCell is preferred over ...
Martin R's user avatar
  • 23.3k

Only top scored, non community-wiki answers of a minimum length are eligible