<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cocoa Is My Girlfriend &#187; System Programming</title>
	<atom:link href="http://www.cimgf.com/category/system-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cimgf.com</link>
	<description>Taglines are for Windows programmers</description>
	<lastBuildDate>Thu, 15 Jul 2010 21:20:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Cocoa Tutorial: Custom Folder Icons</title>
		<link>http://www.cimgf.com/2008/06/16/cocoa-tutorial-custom-folder-icons/</link>
		<comments>http://www.cimgf.com/2008/06/16/cocoa-tutorial-custom-folder-icons/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 20:15:02 +0000</pubDate>
		<dc:creator>Matt Long</dc:creator>
				<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[System Programming]]></category>

		<guid isPermaLink="false">http://www.cimgf.com/?p=132</guid>
		<description><![CDATA[This is just another one of those things that seems like it ought to be a simple little code snippet and you&#8217;re there, but in actuality it&#8217;s just not the case. I am building an exporter for my application that will export a movie project in iMovie HD format. I want to mimic the file [...]]]></description>
			<content:encoded><![CDATA[<p>This is just another one of those things that seems like it ought to be a simple little code snippet and you&#8217;re there, but in actuality it&#8217;s just not the case. I am building an exporter for my application that will export a movie project in <em>iMovie HD</em> format. I want to mimic the file format exactly and one of the things I noticed about the directories that are stored inside <em>iMovie HD</em>&#8216;s custom format (select &#8216;Show Package Contents&#8217; from the context menu in the <em>Finder</em>) is that they have custom icons assigned to them. So the problem to solve was how to do that programatically. Here is what I&#8217;ve found.
<span id="more-132"></span>
<strong style="color: red;">Stop The Presses</strong> After I published this yesterday, one of our kind readers pointed out in the comments that this problem has been solved much more elegantly using <em>NSWorkspace</em> starting in OS X Tiger (10.4). Yes. You read that right. Tiger! Heck if I could find this solution using Google, though. Oh well.. All you really need is <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWorkspace_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWorkspace/setIcon:forFile:options:">- (BOOL)setIcon:(NSImage *)image forFile:(NSString *)fullPath options:(NSWorkspaceIconCreationOptions)options</a>  in <em>NSWorkspace</em> to do the same thing.</p>

<p>Feel free to read on as this will provide good legacy information. Just note that setting a custom icon for a folder is not as hard as this post would make it seem.</p>

<h2>Poking A Stick At It</h2>

<p>If you haven&#8217;t yet realized in your programming career that often the best and sometimes only way to figure something out is to &#8216;poke a stick at it&#8217; then it&#8217;s probably time you started. I&#8217;m not sure where this reference comes from, but it seems apropo. Maybe it&#8217;s a cave man thing? You&#8217;re not sure what something is, so you poke a stick at it and see what happens.</p>

<p>Different from cave men, though, my proverbial/virtual stick is <em>Terminal.app</em>. If you look inside an <em>iMovie HD</em> project file, which contains folders with custom icons, using <em>Terminal.app</em> you&#8217;ll see a listing that looks something like this.</p>

<p><pre>
drwxr-xr-x@  6 mlong  staff   204 Mar 17 18:00 Cache
-rw-r--r--@  1 mlong  staff  1677 Mar  7 17:22 Makin Guacamole.iMovieProj
-rw-r--r--@  1 mlong  staff   895 Mar  7 17:19 Makin Guacamole~.iMovieProj
drwxr-xr-x@  4 mlong  staff   136 Mar 17 18:00 Media
drwxr-xr-x@  5 mlong  staff   170 Mar  7 17:22 Shared Movies
</pre></p>

<p>This is a list from a time lapse movie I made of myself making guacamole. You can <a href="http://www.youtube.com/watch?v=51jomaA7S4Q">watch it here if you&#8217;re so inclined</a>. Notice that there are special attributes on each of the files and folders as indicated by the at (@) symbol. You can see what&#8217;s going on with a particular directory by using the <em>mdls</em> command. Try it on one of the folders, say <em>Media</em> for example. and you&#8217;ll get a listing like this.</p>

<p><pre>
bash: mlong$ mdls Media
kMDItemFSContentChangeDate = 2008-03-17 18:00:49 -0600
kMDItemFSCreationDate      = 2008-03-07 17:19:34 -0700
kMDItemFSCreatorCode       = ""
kMDItemFSFinderFlags       = 1024
kMDItemFSHasCustomIcon     = 1
kMDItemFSInvisible         = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery      = 0
kMDItemFSLabel             = 0
kMDItemFSName              = "Media"
kMDItemFSNodeCount         = 2
kMDItemFSOwnerGroupID      = 20
kMDItemFSOwnerUserID       = 501
kMDItemFSSize              = (null)
kMDItemFSTypeCode          = ""
</pre></p>

<p>Notice that the attribute called <em> kMDItemFSHasCustomIcon</em> is set to 1. If you now <em>cd</em> into the <em>Media</em> directory and run <em>ls -al</em>. You&#8217;ll see something like the following.</p>

<p><pre>
bash: mlong$ ls -al
total 31480
drwxr-xr-x@ 4 mlong  staff       136 Mar 17 18:00 .
drwxr-xr-x@ 7 mlong  staff       238 Mar  7 17:22 ..
-rw-r--r--@ 1 mlong  staff         0 Mar 17 18:00 Icon?
-rw-r--r--@ 1 mlong  staff  16056849 Mar  7 17:20 Makin Guacamole 01.mov
</pre></p>

<p>See that little 0 byte file called <em>Icon?</em>. This is what is telling the Finder about the custom icon being used.</p>

<p>The next step now that I knew that there was actually a way to specify a custom icon was to do a Google search to see if anyone had provided code to use. It was pretty sparse, but I was able to find something useful which is what this post is really about. A company called Shiny Frog based in Italy posted some open-source code that demonstrates how to set custom folder icons among other things. <a href="http://www.shinyfrog.net/en/openSource/">You can download their entire open-source code base here</a>. I&#8217;ve leveraged only the folder icon setting code for this blog post.</p>

<h2>Coding It Up</h2>

<p>Here are the two projects for this post:
<a href='http://www.cimgf.com/wp-content/uploads/2008/06/setcustomiconprocedural.zip'>Set Custom Icon Project (Procedural Code)</a>
<a href='http://www.cimgf.com/wp-content/uploads/2008/06/setcustomicon.zip'>Set Custom Icon Project (OO Code)</a></p>

<p>In the end, this post is not so much a tutorial as it is a showcase of the code. The code that it takes to change a folder icon is fairly lengthy. I have broken it out into two projects here. In the first, I broke out the code from the class that it was in when I downloaded it from Shiny Frog and put it into a procedural format. The second uses the classes as they&#8217;re found in the Shiny Frog code. Here is the code for the procedural way in its entirety. I&#8217;ve left all of the original comments from Shiny Frog in the code.</p>

<blockquote><strong>Note:</strong> If you want to simply use the code as classes, stick around for the next section in this post as I explain how you can just use what Shiny Frog provided.</blockquote>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setIcon<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>iconFilepath forDirectory<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>directoryPath;
<span style="color: #002200;">&#123;</span>
&nbsp;
    FSRef ref;
    OSStatus result;
    IconFamilyHandle hIconFamily;
&nbsp;
    CFURLRef urlRef;
    Boolean gotFSRef;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Create a CFURL with the specified POSIX path.</span>
    urlRef <span style="color: #002200;">=</span> CFURLCreateWithFileSystemPath<span style="color: #002200;">&#40;</span> kCFAllocatorDefault,
                                           <span style="color: #002200;">&#40;</span>CFStringRef<span style="color: #002200;">&#41;</span> iconFilepath,
                                           kCFURLPOSIXPathStyle,
                                           FALSE <span style="color: #11740a; font-style: italic;">/* isDirectory */</span> <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>urlRef <span style="color: #002200;">==</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;** Couldn't make a CFURLRef for the file.&quot;</span> <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Try to create an FSRef from the URL.  (If the specified file doesn't exist, this</span>
    <span style="color: #11740a; font-style: italic;">// function will return false, but if we've reached this code we've already insured</span>
    <span style="color: #11740a; font-style: italic;">// that the file exists.)</span>
    gotFSRef <span style="color: #002200;">=</span> CFURLGetFSRef<span style="color: #002200;">&#40;</span> urlRef, <span style="color: #002200;">&amp;</span>ref <span style="color: #002200;">&#41;</span>;
    CFRelease<span style="color: #002200;">&#40;</span> urlRef <span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>gotFSRef<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;** Couldn't get an FSRef for the file.<span style="color: #2400d9;">\n</span>&quot;</span> <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span>;
    <span style="color: #002200;">&#125;</span>
    result <span style="color: #002200;">=</span> ReadIconFromFSRef<span style="color: #002200;">&#40;</span> <span style="color: #002200;">&amp;</span>ref, <span style="color: #002200;">&amp;</span>hIconFamily <span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #002200;">&#91;</span>self setAsCustomIconForDirectory<span style="color: #002200;">:</span>directoryPath familyHandle<span style="color: #002200;">:</span>hIconFamily<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">BOOL</span><span style="color: #002200;">&#41;</span> setAsCustomIconForDirectory<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span><span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>path familyHandle<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span>IconFamilyHandle<span style="color: #002200;">&#41;</span>hIconFam;
<span style="color: #002200;">&#123;</span>
    <span style="color: #400080;">NSFileManager</span> <span style="color: #002200;">*</span>fm <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSFileManager</span> defaultManager<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">BOOL</span> isDir;
    <span style="color: #a61390;">BOOL</span> exists;
    <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>iconrPath;
    FSRef targetFolderFSRef, iconrFSRef;
    SInt16 file;
    OSErr result;
    <span style="color: #a61390;">struct</span> HFSUniStr255 filename;
    <span style="color: #a61390;">struct</span> FSCatalogInfo catInfo;
    Handle hExistingCustomIcon;
    IconFamilyHandle hIconFamily;
    Handle hIconFamilyCopy;
&nbsp;
    hIconFamily <span style="color: #002200;">=</span> hIconFam;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Confirm that &quot;path&quot; exists and specifies a directory.</span>
    exists <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>fm fileExistsAtPath<span style="color: #002200;">:</span>path isDirectory<span style="color: #002200;">:&amp;</span>isDir<span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> <span style="color: #002200;">!</span>isDir || <span style="color: #002200;">!</span>exists <span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Get an FSRef for the folder.</span>
&nbsp;
    CFURLRef urlRef;
    Boolean gotFSRef;
&nbsp;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Create a CFURL with the specified POSIX path.</span>
    urlRef <span style="color: #002200;">=</span> CFURLCreateWithFileSystemPath<span style="color: #002200;">&#40;</span> kCFAllocatorDefault,
                                           <span style="color: #002200;">&#40;</span>CFStringRef<span style="color: #002200;">&#41;</span> path,
                                           kCFURLPOSIXPathStyle,
                                           FALSE <span style="color: #11740a; font-style: italic;">/* isDirectory */</span> <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>urlRef <span style="color: #002200;">==</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;** Couldn't make a CFURLRef for the file.&quot;</span> <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Try to create an FSRef from the URL.  (If the specified file doesn't exist, this</span>
    <span style="color: #11740a; font-style: italic;">// function will return false, but if we've reached this code we've already insured</span>
    <span style="color: #11740a; font-style: italic;">// that the file exists.)</span>
    gotFSRef <span style="color: #002200;">=</span> CFURLGetFSRef<span style="color: #002200;">&#40;</span> urlRef, <span style="color: #002200;">&amp;</span>targetFolderFSRef <span style="color: #002200;">&#41;</span>;
    CFRelease<span style="color: #002200;">&#40;</span> urlRef <span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>gotFSRef<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;** Couldn't get an FSRef for the file.&quot;</span> <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Remove and re-create any existing &quot;Icon\r&quot; file in the directory, and get an FSRef for it.</span>
    iconrPath <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>path stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Icon<span style="color: #2400d9;">\r</span>&quot;</span><span style="color: #002200;">&#93;</span>;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#91;</span>fm fileExistsAtPath<span style="color: #002200;">:</span>iconrPath<span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> <span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span>fm removeFileAtPath<span style="color: #002200;">:</span>iconrPath handler<span style="color: #002200;">:</span><span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span> <span style="color: #002200;">&#41;</span>
            <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#91;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;&quot;</span> writeToFile<span style="color: #002200;">:</span>iconrPath atomically<span style="color: #002200;">:</span><span style="color: #a61390;">YES</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Create a CFURL with the specified POSIX path.</span>
    urlRef <span style="color: #002200;">=</span> CFURLCreateWithFileSystemPath<span style="color: #002200;">&#40;</span> kCFAllocatorDefault,
                                           <span style="color: #002200;">&#40;</span>CFStringRef<span style="color: #002200;">&#41;</span> iconrPath,
                                           kCFURLPOSIXPathStyle,
                                           FALSE <span style="color: #11740a; font-style: italic;">/* isDirectory */</span> <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>urlRef <span style="color: #002200;">==</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;** Couldn't make a CFURLRef for the file.&quot;</span> <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Try to create an FSRef from the URL.  (If the specified file doesn't exist, this</span>
    <span style="color: #11740a; font-style: italic;">// function will return false, but if we've reached this code we've already insured</span>
    <span style="color: #11740a; font-style: italic;">// that the file exists.)</span>
    gotFSRef <span style="color: #002200;">=</span> CFURLGetFSRef<span style="color: #002200;">&#40;</span> urlRef, <span style="color: #002200;">&amp;</span>iconrFSRef <span style="color: #002200;">&#41;</span>;
    CFRelease<span style="color: #002200;">&#40;</span> urlRef <span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span>gotFSRef<span style="color: #002200;">&#41;</span>
    <span style="color: #002200;">&#123;</span>
        NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;** Couldn't get an FSRef for the file.<span style="color: #2400d9;">\n</span>&quot;</span> <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Get type and creator information for the Icon file.</span>
    result <span style="color: #002200;">=</span> FSGetCatalogInfo<span style="color: #002200;">&#40;</span>
                              <span style="color: #002200;">&amp;</span>iconrFSRef,
                              kFSCatInfoFinderInfo,
                              <span style="color: #002200;">&amp;</span>catInfo,
                              <span style="color: #11740a; font-style: italic;">/*outName*/</span> <span style="color: #a61390;">NULL</span>,
                              <span style="color: #11740a; font-style: italic;">/*fsSpec*/</span> <span style="color: #a61390;">NULL</span>,
                              <span style="color: #11740a; font-style: italic;">/*parentRef*/</span> <span style="color: #a61390;">NULL</span> <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> result <span style="color: #002200;">==</span> fnfErr <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        <span style="color: #11740a; font-style: italic;">// The file doesn't exist. Prepare to create it.</span>
&nbsp;
        <span style="color: #a61390;">struct</span> FileInfo <span style="color: #002200;">*</span>finderInfo <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">struct</span> FileInfo <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>catInfo.finderInfo;
&nbsp;
        <span style="color: #11740a; font-style: italic;">// These are the file type and creator given to Icon files created by</span>
        <span style="color: #11740a; font-style: italic;">// the Finder.</span>
        finderInfo<span style="color: #002200;">-</span>&gt;fileType <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">'icon'</span>;
        finderInfo<span style="color: #002200;">-</span>&gt;fileCreator <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">'MACS'</span>;
&nbsp;
        <span style="color: #11740a; font-style: italic;">// Icon files should be invisible.</span>
        finderInfo<span style="color: #002200;">-</span>&gt;finderFlags <span style="color: #002200;">=</span> kIsInvisible;
&nbsp;
        <span style="color: #11740a; font-style: italic;">// Because the inited flag is not set in finderFlags above, the Finder</span>
        <span style="color: #11740a; font-style: italic;">// will ignore the location, unless it's in the 'magic rectangle' of</span>
        <span style="color: #11740a; font-style: italic;">// { -24,000, -24,000, -16,000, -16,000 } (technote TB42).</span>
        <span style="color: #11740a; font-style: italic;">// So we need to make sure to set this to zero anyway, so that the</span>
        <span style="color: #11740a; font-style: italic;">// Finder will position it automatically. If the user makes the Icon</span>
        <span style="color: #11740a; font-style: italic;">// file visible for any reason, we don't want it to be positioned in an</span>
        <span style="color: #11740a; font-style: italic;">// exotic corner of the window.</span>
        finderInfo<span style="color: #002200;">-</span>&gt;location.h <span style="color: #002200;">=</span> finderInfo<span style="color: #002200;">-</span>&gt;location.v <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
        <span style="color: #11740a; font-style: italic;">// Standard reserved-field practice.</span>
        finderInfo<span style="color: #002200;">-</span>&gt;reservedField <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
        <span style="color: #11740a; font-style: italic;">// Modified by Matteo Rattotti on: Wed Dec  5 14:56:52 2007</span>
        <span style="color: #11740a; font-style: italic;">// the catalog must be set</span>
        FSSetCatalogInfo <span style="color: #002200;">&#40;</span><span style="color: #002200;">&amp;</span>iconrFSRef, kFSCatInfoFinderInfo, <span style="color: #002200;">&amp;</span>catInfo<span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> result <span style="color: #002200;">!=</span> noErr <span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
			<span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
		<span style="color: #002200;">&#125;</span>
		<span style="color: #a61390;">else</span><span style="color: #002200;">&#123;</span> <span style="color: #11740a; font-style: italic;">// Modified by Matteo Rattotti on: Wed Dec  5 14:56:52 2007</span>
			<span style="color: #11740a; font-style: italic;">// File already exist, so we only need to set the flag we want (invisib, etc...)</span>
			<span style="color: #a61390;">struct</span> FileInfo <span style="color: #002200;">*</span>finderInfo <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">struct</span> FileInfo <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>catInfo.finderInfo;
&nbsp;
			<span style="color: #11740a; font-style: italic;">// File type</span>
			finderInfo<span style="color: #002200;">-</span>&gt;fileType <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">'icon'</span>;
			finderInfo<span style="color: #002200;">-</span>&gt;fileCreator <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">'MACS'</span>;
&nbsp;
			<span style="color: #11740a; font-style: italic;">// Icon files should be invisible.</span>
			finderInfo<span style="color: #002200;">-</span>&gt;finderFlags <span style="color: #002200;">=</span> kIsInvisible;
			finderInfo<span style="color: #002200;">-</span>&gt;location.h <span style="color: #002200;">=</span> finderInfo<span style="color: #002200;">-</span>&gt;location.v <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
			<span style="color: #11740a; font-style: italic;">// Standard reserved-field practice.</span>
			finderInfo<span style="color: #002200;">-</span>&gt;reservedField <span style="color: #002200;">=</span> <span style="color: #2400d9;">0</span>;
&nbsp;
			FSSetCatalogInfo <span style="color: #002200;">&#40;</span><span style="color: #002200;">&amp;</span>iconrFSRef, kFSCatInfoFinderInfo, <span style="color: #002200;">&amp;</span>catInfo<span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Get the filename, to be applied to the Icon file.</span>
    filename.length <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Icon<span style="color: #2400d9;">\r</span>&quot;</span> length<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Icon<span style="color: #2400d9;">\r</span>&quot;</span> getCharacters<span style="color: #002200;">:</span>filename.unicode<span style="color: #002200;">&#93;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Make sure the file has a resource fork that we can open.  (Although</span>
    <span style="color: #11740a; font-style: italic;">// this sounds like it would clobber an existing resource fork, the Carbon</span>
    <span style="color: #11740a; font-style: italic;">// Resource Manager docs for this function say that's not the case.)</span>
    FSCreateResFile<span style="color: #002200;">&#40;</span>
                    <span style="color: #002200;">&amp;</span>targetFolderFSRef,
                    filename.length,
                    filename.unicode,
                    kFSCatInfoFinderInfo,
                    <span style="color: #002200;">&amp;</span>catInfo,
                    <span style="color: #002200;">&amp;</span>iconrFSRef,
                    <span style="color: #11740a; font-style: italic;">/*newSpec*/</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span>;
    result <span style="color: #002200;">=</span> ResError<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">!</span><span style="color: #002200;">&#40;</span>result <span style="color: #002200;">==</span> noErr || result <span style="color: #002200;">==</span> dupFNErr<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Open the file's resource fork.</span>
    file <span style="color: #002200;">=</span> FSOpenResFile<span style="color: #002200;">&#40;</span> <span style="color: #002200;">&amp;</span>iconrFSRef, fsRdWrPerm <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>file <span style="color: #002200;">==</span> <span style="color: #002200;">-</span><span style="color: #2400d9;">1</span><span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Make a copy of the icon family data to pass to AddResource().</span>
    <span style="color: #11740a; font-style: italic;">// (AddResource() takes ownership of the handle we pass in; after the</span>
    <span style="color: #11740a; font-style: italic;">// CloseResFile() call its master pointer will be set to 0xffffffff.</span>
    <span style="color: #11740a; font-style: italic;">// We want to keep the icon family data, so we make a copy.)</span>
    <span style="color: #11740a; font-style: italic;">// HandToHand() returns the handle of the copy in hIconFamily.</span>
    hIconFamilyCopy <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span>Handle<span style="color: #002200;">&#41;</span> hIconFamily;
    result <span style="color: #002200;">=</span> HandToHand<span style="color: #002200;">&#40;</span> <span style="color: #002200;">&amp;</span>hIconFamilyCopy <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>result <span style="color: #002200;">!=</span> noErr<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        CloseResFile<span style="color: #002200;">&#40;</span> file <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Remove the file's existing kCustomIconResource of type kIconFamilyType</span>
    <span style="color: #11740a; font-style: italic;">// (if any).</span>
    hExistingCustomIcon <span style="color: #002200;">=</span> GetResource<span style="color: #002200;">&#40;</span> kIconFamilyType, kCustomIconResource <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> hExistingCustomIcon <span style="color: #002200;">&#41;</span>
        RemoveResource<span style="color: #002200;">&#40;</span> hExistingCustomIcon <span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Now add our icon family as the file's new custom icon.</span>
    AddResource<span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#40;</span>Handle<span style="color: #002200;">&#41;</span>hIconFamilyCopy, kIconFamilyType,
                kCustomIconResource, <span style="color: #bf1d1a;">&quot;<span style="color: #2400d9;">\p</span>&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>ResError<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">!=</span> noErr<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
        CloseResFile<span style="color: #002200;">&#40;</span> file <span style="color: #002200;">&#41;</span>;
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
    <span style="color: #002200;">&#125;</span>
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Close the file's resource fork, flushing the resource map and new icon</span>
    <span style="color: #11740a; font-style: italic;">// data out to disk.</span>
    CloseResFile<span style="color: #002200;">&#40;</span> file <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>ResError<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">!=</span> noErr<span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    result <span style="color: #002200;">=</span> FSGetCatalogInfo<span style="color: #002200;">&#40;</span> <span style="color: #002200;">&amp;</span>targetFolderFSRef,
                              kFSCatInfoFinderInfo,
                              <span style="color: #002200;">&amp;</span>catInfo,
                              <span style="color: #11740a; font-style: italic;">/*outName*/</span> <span style="color: #a61390;">NULL</span>,
                              <span style="color: #11740a; font-style: italic;">/*fsSpec*/</span> <span style="color: #a61390;">NULL</span>,
                              <span style="color: #11740a; font-style: italic;">/*parentRef*/</span> <span style="color: #a61390;">NULL</span><span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> result <span style="color: #002200;">!=</span> noErr <span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Tell the Finder that the folder now has a custom icon.</span>
    <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">struct</span> FolderInfo <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>catInfo.finderInfo<span style="color: #002200;">&#41;</span><span style="color: #002200;">-</span>&gt;finderFlags <span style="color: #002200;">=</span> <span style="color: #002200;">&#40;</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">struct</span> FolderInfo <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>catInfo.finderInfo<span style="color: #002200;">&#41;</span><span style="color: #002200;">-</span>&gt;finderFlags | kHasCustomIcon <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&amp;</span> ~kHasBeenInited;
&nbsp;
    result <span style="color: #002200;">=</span> FSSetCatalogInfo<span style="color: #002200;">&#40;</span> <span style="color: #002200;">&amp;</span>targetFolderFSRef,
                              kFSCatInfoFinderInfo,
                              <span style="color: #002200;">&amp;</span>catInfo<span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span> result <span style="color: #002200;">!=</span> noErr <span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Notify the system that the target directory has changed, to give Finder</span>
    <span style="color: #11740a; font-style: italic;">// the chance to find out about its new custom icon.</span>
    result <span style="color: #002200;">=</span> FNNotify<span style="color: #002200;">&#40;</span> <span style="color: #002200;">&amp;</span>targetFolderFSRef, kFNDirectoryModifiedMessage, kNilOptions <span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>result <span style="color: #002200;">!=</span> noErr<span style="color: #002200;">&#41;</span>
        <span style="color: #a61390;">return</span> <span style="color: #a61390;">NO</span>;
&nbsp;
    <span style="color: #a61390;">return</span> <span style="color: #a61390;">YES</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>


<p>Nearly 280 Lines of code later and here we are. I&#8217;m sure there is a group of people out there who don&#8217;t care about the internals of how this works and would like to just use the code. In fact I would wager that that&#8217;s probably the majority. Here&#8217;s all you need if that&#8217;s you. Just drop in the files <em>NSString+CarbonFSRefCreation.m, NSString+CarbonFSRefCreation.h, IconFamily.m</em> and <em>IconFamily.h</em> from the Shiny Frog project into your project and you can then change a folder icon with these few lines of code:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;">IconFamily <span style="color: #002200;">*</span>fam <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>IconFamily iconFamilyWithContentsOfFile<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>icnsFilepath stringValue<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>fam setAsCustomIconForDirectory<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>dirPath stringValue<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></td></tr></table></div>


<p>That&#8217;s a lot easier to read and use obviously. I recommend the object oriented approach as it keeps things much cleaner. And as Shiny Frog has released this code under a standard MIT license which allows you to do pretty much whatever you like as long as you maintain the copyright information, you could take the two classes here and create your own framework that you can then just link in whenever you need it.</p>

<h2>Conclusion</h2>

<p>When I searched for code online to figure out how to achieve setting a custom icon for folders it looked pretty slim. Had I needed to track down all of the steps myself it would have, obviously, taken much longer to figure out, but thanks the Shiny Frog, I was able to find the code to do exactly what I wanted. I&#8217;m hopeful that this blog post will hit the search engines and make it easier for folks to find as this seems like a fairly important thing to know how to do. Until next time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cimgf.com/2008/06/16/cocoa-tutorial-custom-folder-icons/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cocoa Tutorial: Introduction To Identity Services</title>
		<link>http://www.cimgf.com/2008/04/09/cocoa-tutorial-introduction-to-identity-services/</link>
		<comments>http://www.cimgf.com/2008/04/09/cocoa-tutorial-introduction-to-identity-services/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 17:56:11 +0000</pubDate>
		<dc:creator>Matt Long</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[System Programming]]></category>

		<guid isPermaLink="false">http://www.cimgf.com/?p=90</guid>
		<description><![CDATA[System programming is one of the more interesting topics to me because it seems like it&#8217;s the hackers domain. When I first got into programming I always wanted to see if I could make the computer do something that nobody else anticipated it could do. I think it was probably just from watching too many [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.cimgf.com/wp-content/uploads/2008/04/morpheus.gif" alt="Morpheus, Badass!" title="morpheus" width="191" height="300" align="left" />System programming is one of the more interesting topics to me because it seems like it&#8217;s the hackers domain. When I first got into programming I always wanted to see if I could make the computer do something that nobody else anticipated it could do. I think it was probably just from watching too many hacker movies. Even the Matrix (the first one, not those other two contorted kill joys) had this affect on me that somehow I could beat the system because as Morpheus put it,</p>

<blockquote>I&#8217;ve seen an agent punch through a concrete wall. Men have emptied entire clips at them and hit nothing but air, yet their strength and their speed are still based in a world that is built on rules. Because of that, <strong>they will never be as strong or as fast as you can be</strong>.</blockquote>

<p>Man! I loved that movie the first time I watched it. A world without rules? Or more specifically a world where you set the rules by your most awesome hacker powers. Sweet!</p>

<p>But alas, as I&#8217;ve proceeded and matured (I hope) in my programming abilities, this whole area has become much less glamorous as I realize that hacking is really about finding vulnerabilities in other people&#8217;s code. That&#8217;s really not that exciting to me, but system level programming remains interesting and a good place to start is to look into who the users are on my system. Time to use Identity Services. And in this intro I&#8217;ve written a very basic password cracking system.
<span id="more-90"></span></p>

<p>I&#8217;m about to yell in red, so you might want to cover your ears.</p>

<p><strong style='color:red'>YOU CAN MESS UP YOUR USER ACCOUNT ON YOUR SYSTEM IF YOU ARE NOT CAREFUL WITH HOW YOU USE IDENTITY SERVICES. DO NOT BLAME ME IF YOU DO SO. CREATE A DEMO USER NOW BEFORE YOU PROCEED AND USE IT FOR YOUR TESTS. YOU HAVE BEEN WARNED!</strong></p>

<p>Yelling is over. You can uncover your ears now.</p>

<p>You can download the demo application here: <a href='http://www.cimgf.com/wp-content/uploads/2008/04/identify.zip'>Identity Services Demo Application</a></p>

<h2>Simple Password Cracking</h2>

<p>If you need information about a user in your code, you can get most of what you need through the user account information provided through identity services. And while you won&#8217;t be able to retrieve passwords since they are stored as hashes, you can check passwords against a list of dictionary words. This type of attack is known as a brute force dictionary attack. It is considered brute force as it will just keep running through a loop checking the hash against every word in the dictionary. It&#8217;s one for one so there&#8217;s no efficiency. It will only quit should it find a hash that matches. This could take a very very long time.</p>

<p>Keep in mind that this method will only work on simple dictionary based password. Once a password has alpha <strong>and</strong> numeric characters, the likelihood of a simple dictionary attack actually finding the password in any reasonable amount of time diminishes rapidly.</p>

<p>If you want to test this out, I recommend that instead of changing your own password, you create a new test user in your <em>System Preferences | Accounts</em> control panel. Give it one of these passwords that are in our dictionary:</p>

<ul>
<li>flower</li>
<li>onion</li>
<li>password</li>
<li>candy</li>
<li>snoopy</li>
<li>broncos</li>
<li>love</li>
<li>guacamole</li>
<li>leopard</li>
</ul>

<p><a href='http://www.cimgf.com/wp-content/uploads/2008/04/identify.png' rel='lightbox'><img src="http://www.cimgf.com/wp-content/uploads/2008/04/identify-150x150.png" alt="Indentify Screenshot" title="identify" width="150" height="150" align="center" class="aligncenter size-thumbnail wp-image-93" /></a></p>

<h2>A Potential Bug?</h2>

<p>I&#8217;ve never filed a bug with Apple before, but I realized that when I was trying to use the wrapper class called <strong>CBIdentity</strong> to retrieve the user&#8217;s email address with <strong>-[CBIdentity emailAddress]</strong>, it kept on returning me their Posix Name  (Unix username) instead of the email address. I verified this with the API call <strong>CSIdentityGetEmailAddress()</strong> which does properly return the email address.</p>

<p>I&#8217;m not absolutely sure that it&#8217;s a bug, but since it works properly with the API call, it seemed logical that it would be. Plus, in this <a href="http://developer.apple.com/samplecode/IdentitySample/">demo application from Apple</a>, they use the <strong>CSIdentityGetEmailAddress()</strong>.</p>

<blockquote><strong>Note:</strong> In order to get the sample code from Apple to work, you will need to make a change to two lines in the <strong>IdentityController.m</strong> file. Anyplace where you see <strong>kCSLocalIdentityAuthority</strong> you need to change it to <strong>[[CBIdentityAuthority localIdentityAuthority] CSIdentityAuthority]</strong>. You will also need to add the <strong>Collaboration.framework</strong> framework to your project and add <strong>#import &lt;Collaboration/Collaboration.h&gt;</strong> to the <strong>IdentityController.h</strong> file.
</blockquote>

<p>The <em>IdentitySample</em> project provides a lot more code for demonstrating Identity Services, so take a close look at it to see some more usages examples.</p>

<blockquote><strong>Update:</strong> Apple wrote me back and said that it was indeed a bug, but it&#8217;s a duplicate.</blockquote>

<h2>Password Cracking Dictionaries</h2>

<p>I&#8217;m not going to take you too much farther into doing password cracking as the only legitimate uses for it that I can think of are either detecting weak passwords, or sanctioned corporate hacking where security experts are hired to attempt to find vulnerabilities.</p>

<p>I will say, however, that if you want to pursue creating a password cracking utility that uses a brute force method for any of these legitimate uses, you will, obviously, need a much larger dictionary than the little array I&#8217;ve put into the project. There are free dictionary files out there you should be able to find on Google without much trouble. You can simply load one of those up and you&#8217;ll be on your way to a little more sophisticated password cracker, or shall we call it, <em>weak password detector</em>?</p>

<h2>Conclusion</h2>

<p>For a comprehensive guide to the Identity Services API, first take a look at Apple&#8217;s <a href="http://developer.apple.com/documentation/Networking/Conceptual/IdentityServices_ProgGuide/Introduction/chapter_1_section_1.html">Identity Services Programming Guide</a>. Then, refer to the <a href="http://developer.apple.com/documentation/Networking/Reference/IdentityServices_Ref/identity-functions.html">Core Services Identity Reference</a> which will give you everything you need to load user information, save user information, and create new users. While most of the types you will find in Core Services are CF references, you can convert them toll-free to their NS counterparts with simple typecasting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cimgf.com/2008/04/09/cocoa-tutorial-introduction-to-identity-services/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
