tag:blogger.com,1999:blog-344424522024-03-13T04:20:08.554-07:00Cocoa SamuraiColin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.comBlogger86125tag:blogger.com,1999:blog-34442452.post-85840797033163041162018-08-18T14:39:00.000-07:002018-08-19T21:47:54.016-07:00A modest proposal for optional methods in Swift protocolsSwift contains protocols in which you can declare methods, which something claiming to adhere to the protocol must implement. One thing Swift protocols can’t do are optional methods... sort of. In Objective-C we’d specify an optional method in a protocol like so
@protocol MyProtcol<NSObject>
-(void)someRequiredMethod:(id)param;
@optional
-(void)someOptionalMethod:(id)param;
@end
In Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com0tag:blogger.com,1999:blog-34442452.post-64533444683491757052013-03-07T14:03:00.001-08:002014-05-21T21:40:27.093-07:00Basic MVVM with ReactiveCocoaUpdate: This article has been updated to reflect the changes in the latest stable ReactiveCocoa v2
MVC - One Pattern to Rule them all
The MVC design pattern has existed since the late 1970s and has been in use in the Foundation, AppKit & UIKit Frameworks for a long time now. At its heart is a very simple design and a good idea. The Design is this
As you can see we have 3 components
Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com18tag:blogger.com,1999:blog-34442452.post-28633708923416190672012-08-30T19:20:00.000-07:002012-08-31T08:39:38.252-07:00Cover up those ivarsIt all started with a tweet a couple mornings ago...
There is no longer a need to declare ivars in your Objective-C headers. Stop that bad habit now.
There is no longer a need to declare ivars in your Objective-C headers. Stop that bad habit now.— Paul Goracke (@pgor) August 28, 2012
I completely agree with this. Objective-C has evolved over time from where everything was public and had Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com14tag:blogger.com,1999:blog-34442452.post-72212503001292788302012-01-31T18:16:00.000-08:002012-01-31T18:25:38.502-08:00Clang Source AnnotationsRecently I was faced with a dilemma. I was writing code I needed, and then I triggered a Clang Static Analyzer issue. Here is the code a category on NSColor, see if you can figure out whats wrong with it from a Static Analyzer perspective...
-(CGColorRef)cw_cgColor { NSColor *nscolor = [self colorUsingColorSpaceName:NSCalibratedRGBColorSpace]; CGFloat components[4]; [nscolor getRed:&Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com5tag:blogger.com,1999:blog-34442452.post-12682571555736817692011-04-07T12:55:00.000-07:002011-04-07T14:23:48.395-07:00Singletons: You're doing them wrongThis post feels a bit odd, as generally I fully agree with Dave Dribin on how wrong singletons are and that you should avoid them if possible. However on Stack Overflow i've seen far too many people write bad code that is horrible for several reasons. Basic ExampleSingletons are fairly easy to create. Here is a basic example... +(MyClass *)singleton {
static MyClass *shared = nil;
if(shared Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com29tag:blogger.com,1999:blog-34442452.post-75110609723528819262011-03-09T16:55:00.001-08:002011-03-10T10:55:37.409-08:00Xcode 4 Keyboard Shortcuts now available!
The Xcode 4 Keyboard Shortcuts are now available. I've decided to make forking it and creating your own version easier by putting it up on Github. This will make it easier to browse forks and merge new formats in. Additionally it makes it easy to have a consistent go to place that doesn't change for updates to the shortcuts.
You can download the Xcode 4 keyboard shortcuts here:
Xcode Keyboard Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com26tag:blogger.com,1999:blog-34442452.post-28087317719293388822011-02-23T16:18:00.001-08:002011-03-02T15:05:50.289-08:00Practical Design Patterns with Blocks and Grand Central DispatchIntroductionWhen Mac OS X 10.6 was introduced, the Mac got a very powerful duo of developer tools that made development on a lot easier. With iOS 4.0 developers finally got access to these tools as well. These tools are known as Blocks & Grand Central Dispatch. This article is not an introduction to these technologies as i've already covered them before here http://Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com9tag:blogger.com,1999:blog-34442452.post-3575666786213878512010-12-28T18:35:00.002-08:002010-12-28T19:29:36.041-08:00Objective-C Memory Management & Garbage CollectionThis article started out as a presentation I did for the Des Moines Cocoaheads.
IntroductionObjective-C Memory Management is something i've seen new people to Cocoa & Objective-C mess up in ways I could just not conceive of on my own. In reality Objective-C memory management is not that hard. You simply need to be aware of some rules and follow a couple of good development practices. Good Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com12tag:blogger.com,1999:blog-34442452.post-31271434364374121032010-11-17T14:02:00.001-08:002010-11-27T16:31:34.131-08:00OmniWeb as a Cocoa Documentation Browser
The built in Xcode Documentation browser is okay, and the stuff Apple does to bring some bits of documentation lookup into the code in IDE is not bad. However, until the full documentation browser is it's own app, I don't think it'll ever reach its full potential. One day I saw Peter Hosey use OmniWeb and do a brief run through of what he did to browse documentation.
Since then, I've only made aColin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com8tag:blogger.com,1999:blog-34442452.post-59431903717758851242010-09-05T09:37:00.001-07:002010-09-05T09:37:31.069-07:00Cocoa UnboundMike Ash recently complained about the restrictions on the Cocoa-Dev Mailing list. There are also many things people would like to discuss that Apple just doesn't allow (as part of their policy) on their mailing lists.
So Brent Simmons created the Cocoa Unbound mailing list where developers can discuss items that Apple doesn't allow on their mailing lists. Go & join up and have happy sane un(Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com1tag:blogger.com,1999:blog-34442452.post-22141860520418749552010-08-11T10:26:00.001-07:002010-08-11T10:28:21.508-07:00Enumerating Lines Concurrently using a BlockRecently on twitter I asked about enumerating over the lines of a string concurrently using a block. I couldn't see an API to deal with this issue directly. If you look through the Mac OS X 10.6 SDK you'll see this
- (void)enumerateLinesUsingBlock:(void (^)(NSString *line, BOOL *stop))blockWhich is a synchronous operation processing each line ( the components separated by \n ) one by one until Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com2tag:blogger.com,1999:blog-34442452.post-33169498210539049052010-06-09T14:09:00.001-07:002010-11-27T16:50:16.314-08:00Good User Interface Design on Mac OS X and the iPhone OSGood user interface design can make or break your application, it's not just visual appearance but workflow & accessibility. An application that is visually appealing but not well designed will lose out to an application that isn't as visually appealing but has a well designed user interface.
I am not even going to be able to write as much as I'd like here on the topic of UI design, because Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com1tag:blogger.com,1999:blog-34442452.post-16486504717422373932010-04-04T11:37:00.001-07:002010-04-04T11:37:07.756-07:00DM CocoaHeads: Good User Interface Design in Cocoa & Cocoa Touchhttp://cocoaheads.org/us/DesMoinesIowa/index.html
Thursday, April 8 at 7 pm at the Impromptu Studio in Des Moines,IA (see link above for Map & directions)
I recently became the group leader of the Des Moines CocoaHeads, and to get the ball rolling I will be giving a presentation this week on Good User Interface Design in Cocoa & Touch. I thought this would be a good time to do this as several Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com0tag:blogger.com,1999:blog-34442452.post-41033461481335491132010-02-01T16:35:00.001-08:002010-02-02T08:21:13.050-08:00The PubSub Framework: Using RSS Feeds in your App
The Project Page for this articles project is on github at http://github.com/Machx/FeedViewer you can grab the source code with git by entering the following command in terminal....
git clone git://github.com/Machx/FeedViewer.git
The PubSub Framework is one of those lesser known Frameworks that Apple introduced in Leopard. It has the ability to parse RSS & ATOM feeds and automatically Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com1tag:blogger.com,1999:blog-34442452.post-54344552884923190662010-01-20T13:53:00.003-08:002010-12-01T09:26:17.881-08:00Understanding the Objective-C RuntimeThe Objective-C Runtime is one of the overlooked features of Objective-C initially when people are generally introduced to Cocoa/Objective-C. The reason for this is that while Objective-C (the language) is easy to pick up in only a couple hours, newcomers to Cocoa spend most of their time wrapping their heads around the Cocoa Framework and adjusting to how it works. However the runtime is Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com26tag:blogger.com,1999:blog-34442452.post-71070589049118390252010-01-10T14:12:00.001-08:002010-01-10T14:12:36.067-08:00Des Moines Cocoaheads 1/14: Understanding the Objective-C Runtimehttp://cocoaheads.org/us/DesMoinesIowa/index.html
Where: Impromptu Studios in Downtown Des Moines, IA 300 SW 5th St, Suite 220
When : Thursday, January 14 @ 7pm
I will be doing a talk this Thursday at the Des Moines Cocoaheads on Understanding the Objective-C Runtime. The talk is applicable to both Mac OS X & iPhone Developers and will cover a range of beginner to advanced materials. We'll go Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com4tag:blogger.com,1999:blog-34442452.post-42877593655360915852009-10-12T08:26:00.001-07:002010-11-27T16:53:28.227-08:00Book Review: Cocoa Design Patterns The Cocoa Design Patterns Book is one I've been anticipating for a while now and the first Cocoa book i've gotten in my hands that I've been really excited to read (i just finally got Bill Dudneys iPhone SDK book and Marcus Zarra's Core Data Book after I already started reading this.)
Mac & iPhone Developers face a unique challenge when learning Cocoa in that you are learning 2 things at once,Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com8tag:blogger.com,1999:blog-34442452.post-29602338589667913902009-09-30T18:29:00.001-07:002010-11-27T16:54:49.100-08:00New in Snow Leopard: New Mac OS X DTrace ProvidersIf you used Leopard and DTrace, then came to Snow Leopard there is a big treat for you (if you haven't used DTrace you can read my previous article Debugging Cocoa With DTrace Guide, go on read it and come back here... I'll wait), on Leopard on any given run I ran dtrace -l | wc -l I got about 23,000 probes on average. On Snow Leopard anytime I do the probe count I get about 66,000 (76,000 right Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com2tag:blogger.com,1999:blog-34442452.post-63587412542450447642009-09-21T06:54:00.001-07:002009-09-21T06:54:29.018-07:00Xcode Shortcut Documents available under CC
Today I am releasing the original pages documents for the Xcode Shortcuts under the Creative Commons 3.0 Attribution License. Basically you can do with it, whatever you want as long as I am attributed as being the original author somewhere, and that's it.
I've gotten many requests to alter the Xcode shortcuts to many desktop sizes and other various custom sizes and unfortunately I don't have Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com3tag:blogger.com,1999:blog-34442452.post-45786464982778345262009-09-17T07:18:00.001-07:002009-09-17T09:27:50.824-07:00Making NSOperation look like GCDFor my last article I posted, I realized that when coming up with code examples that I had been writing examples with NSOperation using it the same way I had been writing code with NSOperation before, namely creating a NSOperation object and adding it to the Queue. However, I overlooked that NSOperationQueue in 10.6 contains a -addOperationWithBlock: method. Using that you could indeed write codeColin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com1tag:blogger.com,1999:blog-34442452.post-48832264268755409512009-09-16T13:07:00.001-07:002009-09-16T13:25:57.224-07:00A Guide to Blocks & Grand Central Dispatch (and the Cocoa API's making use of them)Intro
As you may or may not know I recently did a talk at the Des Moines Cocoaheads in which I reviewed Blocks and Grand Central Dispatch. I have tried to capture the content of that talk and a lot more here in this article. The talk encompassedBlocks
Grand Central Dispatch
GCD Design Patterns
Cocoa API's using GCD and BlocksAll of the content of this article applies only to Mac OS X 10.6 Snow Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com9tag:blogger.com,1999:blog-34442452.post-14349851400733120172009-09-07T13:16:00.000-07:002009-09-09T06:29:13.252-07:00Des Moines CocoaHeads: Blocks & Grand Central Dispatch (Updated with Room#)This Thursday I will be doing a presentation at the Des Moines Cocoaheads (at Iowa State University Campus Howe Hall Room 20. It's on the lower level of Howe, just go down the main stairs by the front door and you'll see room 20 straight ahead.) on Blocks & Grand Central Dispatch and how you can use them with Cocoa, if your in or near central Iowa come by and say hello to the other Iowa Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com1tag:blogger.com,1999:blog-34442452.post-21723722520366670662009-08-28T07:39:00.000-07:002009-09-21T07:19:05.560-07:00Xcode Shortcuts Updated for Xcode 3.2 on Mac OS X 10.6 Snow LeopardXcode Shortcuts (PDF)
Xcode Shortcuts (Black & White) (PDF)
Update The original Pages Documents used to make this are now freely available under the Creative Commons License, see more info here
I've gone ahead and updated the Xcode Shortcuts list for Xcode 3.2 on Mac OS X 10.6 Snow Leopard. Although I go to great lengths to ensure accuracy and correctness it could have the rare error. If you Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com10tag:blogger.com,1999:blog-34442452.post-34704630666696715322009-06-06T09:32:00.001-07:002009-06-06T09:32:18.308-07:00See you at WWDC!
I am taking just a few minutes to write this in the middle of packing my things for WWDC. This will be my 3rd time going to WWDC and my last time officially as a student.
Already I have learned a great deal of things from the previous times i've gone. I've made an effort to get up earlier to get used to what will be a normal time to get up in a different time zone. Also I know Kevin Hoctor Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com1tag:blogger.com,1999:blog-34442452.post-79162807887975175502009-04-18T20:34:00.001-07:002009-04-18T20:34:45.382-07:00Distributed Version Control & Git [Part 2]
In Part I of Distributed Version Control & Git, I showed you why you should switch to Distributed Version Control and explained part of what makes Git a compelling Distributed Version Control System.
In Part 2 and the final part of this miniseries, I show you an overview of git and the basics and guide you through how you setup a git repository, doing commits, branches, merging, resolving Colin Wheelerhttp://www.blogger.com/profile/16010768305821496589noreply@blogger.com4