Archive for May, 2015

Various bits and bobs

front-red-mail-box-1360564-m

Clearing out my mailbox, this morning.

Fabio Virgi of Paddle.com sent over a PR kit for their new Mac app analytics package. With just a few lines of code, the embedded tools enable you to track how the app is being used, IAP conversions, etc.   Fabio writes, “It’s totally free to use, and probably worth mentioning that it can be used for Mac App Store apps and those being independently distributed.” Not really anything I’d use but may be of interest to some of you out there.

Read On…

Swift: Alternative Lintage

broom-2-1209091-m

Today’s post on SwiftLint over at Natasha (The Robot) Murashev’s This Week in Swift inspired me to stop complaining abut lint issues and start building. While I love the idea behind SwiftLint, I didn’t entirely love the implementation or the rules.

I wanted something good enough to be used today with real code, even in imperfect form. It had to run from the command line and work with playgrounds. It had to be able to scan files added to Xcode projects by reference as well as those physically stored in the $SRCROOT.

Read On…

Swift thingies

A discussion today about what the bits you create in Swift are called. Here’s a very rough and untested first go at things:

According to the Swift Programming Language, structures, enumerations, classes are constructs. (As are closures.) You use these to construct instances, according to this blog post at the Apple Swift blog, which means you probably can also instantiate as well as construct them, although that sounds a little iffy.

Instances of structures are structs. Instances of classes are either objects or instances. Instances of enumerations appear to be enums, although I did not find authoritative cites on this. Closure instances are closures, of course, just like functions are functions — unless they are methods by being defined within a class.

While you can assign values to variables of any type, only enumeration and structure instances (and tuples) are value types. Class instances are reference types.

Hopefully the next iteration of Swift, likely to debut in a few weeks, will offer some more concrete names for things. Until then, I’d be interested in hearing what you have to say about these terms.

Corrections? Expansion? Better verbage and nounage? Let me know. Thanks!

Reindexing a Folder

This is yet another one of those “hopefully someone will google across this and save themselves frustration” write-ups. Today’s topic is Spotlight.

When you search Apple Support for help on re-indexing folders or volumes, the help page (currently this one, but these things change often over time) instructs you to open System Preferences, click Spotlight > Privacy, and to drag folders or volumes into the the list and then remove them.

This support post was the first thing I stumbled across when trying to figure out why a new app I had added to /Applications wasn’t indexed and couldn’t be launched via spotlight.

Don’t do that.

After I followed the instruction, this morning I discovered that none of my Applications were now indexed or launchable by Spotlight.

Once more, I googled into the breech until I found this write-up over at OS X Daily. It mentioned using mdimport to re-index  files and directories instead.

I ran the following from the command line:

% mdimport /Applications

My Applications were re-indexed and ready to launch in just a minute or two

Swift: Playground Hack of the day

Today’s hack creates a random Bezier Path.  You pass a size, it builds a shape, using all three path types (line, quad curve, cubic curve). I wrote this for testing path routines and image rendering, but it’s fun to simply sit there and re-run the playground over and over.

func RandomShape(size : CGSize) -> UIBezierPath {
    func RandomFloat() -> CGFloat {return CGFloat(arc4random()) / CGFloat(UINT32_MAX)}
    func RandomPoint() -> CGPoint {return CGPointMake(size.width * RandomFloat(), size.height * RandomFloat())}
    let path = UIBezierPath(); path.moveToPoint(RandomPoint())
    for _ in 0..<(3 + Int(arc4random_uniform(numericCast(10)))) {
        switch (random() % 3) {
        case 0: path.addLineToPoint(RandomPoint())
        case 1: path.addQuadCurveToPoint(RandomPoint(), controlPoint: RandomPoint())
        case 2: path.addCurveToPoint(RandomPoint(), controlPoint1: RandomPoint(), controlPoint2: RandomPoint())
        default: break;
        }
    }
    path.closePath()
    return path
}

Like the hack? Read the book.