Archive for the 'iOS Dev' Category

Swift, missing idea #1?

Tuesday, June 3rd, 2014

Going through “properties”, I’m not finding anything about private and public properties, or protected. I’m also not seeing anything about header files and class files, so at first blush it seems we can’t hide properties from other classes. How do we stop people from using the wrong properties? That can’t be good. I must be […]

Swift, good idea #1

Tuesday, June 3rd, 2014

There’s a lot of good stuff in Swift, of course, but adopting Ruby’s block syntax seems a really nice idea. It’s called “trailing closures” in Swift, but it’s the same thing, as far as I can see. An example from the text: let strings = numbers.map { (var number) -> String in var output = […]

Swift, bad idea #3

Tuesday, June 3rd, 2014

Function types are declared like: var mathFunction: (Int, Int) -> Int In this example: mathFunction is a variable that can hold any function that takes two Int as parameters and returns one Int. Fine, so far. Functions can take such functions as parameters and also return them. For instance, a function taking a function like […]

Swift, bad idea #2

Tuesday, June 3rd, 2014

Function parameters now have distinct “internal” and “external” parameter names. The simplest form does away with named parameters when calling functions, that is, we can now do: mysteriousFunction(15.2, “yeah, right”, “only on a sunday”, -1) …just like in the good(?) old days of plain C/C++. Yes, you can force naming of parameters on the caller’s […]

Swift, bad idea #1

Tuesday, June 3rd, 2014

Looking over the “Swift” language Apple presented during the WWDC keynote. First off, declarations using “var” and “let” made me think of Basic, and had to stifle a gag reflex. I’m reading the iBooks book on Swift. When I got to closed and halfopen ranges on page 100, I thought this was a big mistake. […]

Another creator pattern for clusters

Thursday, September 15th, 2011

This is about Cocoa, and in particular about class clusters. The problem I wanted to solve was having a class cluster with easily extendable hierarchy without too much interdependency. In my case, I want to create a number of different UITableViewCell descendants, depending on the particular data element the cell should handle. If the data […]

Don’t do parts.parts

Wednesday, November 17th, 2010

I just found another weirdness in Apple’s Objective C. If you have the same name for several components of an object path, the runtime starts stuttering and behaving very badly. Intermittently, you can’t scroll, or only extremely slowly, everything turns into molasses. No errors, mind, just mindbogglingly slow. This stuttering and slowness seems to affect […]

Is it nil or isn’t it?

Monday, October 4th, 2010

A bit of Objective-C weirdness I don’t quite get. The weirdness occurs if “view” in the code below is nil, that is if [idr getAsView:newFrame] returns nil. You’d expect the verticalOffset not to be incremented, but it is. Even though view is nil, view.frame.size.height still evaluates to “21” (in this case) and verticalOffset gets incremented. […]

Method forwarding in Objective-C

Friday, August 13th, 2010

I scraped together the following from a number of sources and got it to work fine and without compiler warnings. Interesting links are, among others: http://cocoawithlove.com/2008/03/construct-nsinvocation-for-any-message.html http://macdevelopertips.com/objective-c/objective-c-categories.html But, I get ahead of myself. The idea here is to have one object forward method invocations to another. Typically, you have a class responding to method A, […]