Skip to content

Instantly share code, notes, and snippets.

View atomkirk's full-sized avatar

Adam Kirk atomkirk

View GitHub Profile
@atomkirk
atomkirk / Open With Duplicates.md
Last active December 22, 2015 20:08
Fixing your "Open With..." on Mac OS X so there are no duplicates.

Run this command in Terminal.app to remove duplicate items in your "Open With…" menu on OS X.

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead.")))
// Sample usage:
- (id)initWithObject:(id)object;
- (id)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete.
// Now calling init on this class would throw a warning.
@atomkirk
atomkirk / Status Codes And Their Implied Meanings.md
Created June 5, 2013 22:33
What HTTPS status codes mean in english

My co-worker Parker Wightman:

I see it like this:

2XX = All's well

4XX = You screwed up

5XX = We screwed up >

@atomkirk
atomkirk / Copy if Copyable.md
Last active December 17, 2015 23:39
Copying + mutable = @Property (copy)

I've been told about this, but it's never bitten me, until today. So, get in the habit:

http://stackoverflow.com/questions/387959/nsstring-property-copy-or-retain

He says immutable and I'm not sure I understand why, but it's clear why you would do this with mutable. UPDATE: he says immutable, implying mutable too, because it's entirely possible to assign an immutable version of an object to a property specified as mutable, so it's not safe to assume that just because the property is NSArray doesn't mean it isn't a mutable array and some statement somewhere isn't changing it's content's behind your back.

One interesting thing to note: if you assign an immutable NSArray to a @property (copy, nonatomic) NSArray *array it will actually retain it, not copy it. So it's is smart enough to just retain rather than copy it when it really is immutable, saving an allocation.

@atomkirk
atomkirk / Force Using Designated Initializer.md
Last active December 17, 2015 23:19
force use of designated initializer
@atomkirk
atomkirk / Target Conditionals.md
Last active December 17, 2015 22:19
target conditionals
@atomkirk
atomkirk / custom_fonts_mac.md
Created May 29, 2013 01:50
Custom Fonts on Mac

On iOS, to use custom fonts, you add them to your plist:

<key>UIAppFonts</key>
	<array>
		<string>GoodDog_New.otf</string>
		<string>ProximaNova-Bold.otf</string>
		<string>ProximaNova-Reg.otf</string>
	</array>

on Mac, you just add:

@atomkirk
atomkirk / sparkle_gatekeeper.md
Created May 29, 2013 01:44
Sparkle Mac Updater

I forgot that I had turned on this:

![http://d.pr/i/GF8z/3KaIrTfS]

And so the Sparkle.framework for auto updating mac apps was offering to update, downloading, offering to install and relaunch and then would just quit and not update. It said finish_installation' failed: 22 which was because gatekeeper was keeping the app from updating itself.

Turned off entitlements and it works great.

@atomkirk
atomkirk / cocoapod_dep_trees.md
Created May 27, 2013 20:53
Cocoapod dependency trees

After wresting the traditional git submodule + static library dependency chain, it became a giant headache. I tried to get it all to work for a long time. You must:

  1. Create a workspace and drag your child projects in.
  2. Add their targets as binary linked libraries.
  3. Manually add header search paths.
  4. And all your dependency projects must be set up a certain way for this to work too. So that's a lot of work.

A much better way is to use submodules to include the child projects into the parent project and then use cocoapods to include those child projects (instead of linking them in statically and dealing with the millions of headaches that brings).

For example, I've added my dependency tree as a series of git submodules and then I have a Podfile that looks like this:

@atomkirk
atomkirk / cg_as.md
Created May 27, 2013 18:20
core graphics & application services

You can't mix CoreGraphics and ApplicationServices on mac. If you have two targets, and you want to use things like CGFloat, etc. link to CoreGraphics on iOS and ApplicationServices on OSX. On 10.8, it's fine, it'll work, but you're still suppose to use ApplicaitonServices. On 10.7, it'll build, launch and crash with an error about mismatched ApplicationServices versions because CoreGraphics is calling 10.8's ApplicationServices version. (or some such...)