<?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>worth.Posting</title>
	<atom:link href="http://blog.teliaz.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.teliaz.com</link>
	<description></description>
	<lastBuildDate>Sat, 14 Aug 2010 10:52:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Why Google Chrome?</title>
		<link>http://blog.teliaz.com/?p=710</link>
		<comments>http://blog.teliaz.com/?p=710#comments</comments>
		<pubDate>Thu, 12 Aug 2010 15:15:54 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=710</guid>
		<description><![CDATA[There are some features that most ppl hasnt noticed in google Chrome. For my opinion Google Chrome will be the no1 choise of all net freaks. Incognito mode (private browsing) For times when you want to browse in stealth mode, for example, to plan surprises like gifts or birthdays, Google Chrome offers the incognito browsing [...]]]></description>
			<content:encoded><![CDATA[<p>There are some features that most ppl hasnt noticed in google Chrome. For my opinion Google Chrome will be the no1 choise of all net freaks.</p>
<h2>Incognito mode (private browsing)</h2>
<p><img class="alignnone size-full wp-image-711" title="chrome_icognito" src="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_icognito.jpg" alt="" width="310" height="388" /></p>
<p>For times when you want to browse in stealth mode, for example, to plan surprises like gifts or birthdays, Google Chrome offers the incognito browsing mode. Here&#8217;s how the incognito mode works:</p>
<p>Webpages that you open and files downloaded while you are incognito aren&#8217;t recorded in your browsing and download histories.<br />
All new cookies are deleted after you close all incognito windows that you&#8217;ve opened.<br />
Changes made to your Google Chrome bookmarks and general settings while in incognito mode are always saved.<br />
Keyboard shortcut: <strong> Ctrl+Shift+N</strong></p>
<h2>Advanced Search in Address Bar</h2>
<p>Chrome uses a search engine as your type a url. So the address bar can be used for search and for inserting a url. Autocomplete is very helpful even in very specific searches.<br />
<a href="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_bar1.jpg"><img class="alignnone size-full wp-image-712" title="chrome_bar1" src="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_bar1.jpg" alt="" width="625" height="152" /></a></p>
<p>Also Check out this screen. In options</p>
<p><img class="alignnone size-full wp-image-713" title="chrome_options" src="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_options.jpg" alt="" width="587" height="576" /></p>
<p>There are default Search options but also Other search engines from Sites you use mostly (this is done for you automatically)<br />
<a href="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_options2.jpg"><img class="alignnone size-full wp-image-714" title="chrome_options2" src="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_options2.jpg" alt="" width="567" height="402" /></a></p>
<h2>Quick Search</h2>
<p>Type your search. As you type you can see the number of occurrences (current occurrences is highlighted in orange).<br />
Check out that the search string is highlighted in the scrollbar also.<br />
<a href="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_search2.jpg"><img class="alignnone size-full wp-image-719" title="chrome_search" src="http://blog.teliaz.com/wp-content/uploads/2010/08/chrome_search2.jpg" alt="" width="600"  /></a></p>
<p>Keyboard shortcut: <strong> CTRL + F</strong></p>
<h2>Speed</h2>
<p>see some past test i did with tracemonkey <a href="http://blog.teliaz.com/?p=275" alt="tracemonkey"> here </a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=710</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wiscp on iPhone</title>
		<link>http://blog.teliaz.com/?p=697</link>
		<comments>http://blog.teliaz.com/?p=697#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:47:19 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[alpine]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[openssh]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[winscp]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=697</guid>
		<description><![CDATA[First make sure you have ssh and bsd subsystem installed from installer. If you cant find the source reboot or turn off wifi and back on. Next get WinSCP and find your iPhone’s ip by going to (on your iphone) settings &#62; Wi-Fi &#62; “Your selected WiFi” &#62; Look under IP Address- Connect to your [...]]]></description>
			<content:encoded><![CDATA[<p>First make sure you have ssh and bsd subsystem installed from installer. If you cant find the source reboot or turn off wifi and back on.</p>
<p>Next get <a href="http://winscp.net/eng/index.php">WinSCP</a> and find your iPhone’s ip by going to (on your iphone) settings &gt; Wi-Fi &gt; “Your selected WiFi” &gt; Look under IP Address- Connect to your iPhone using WinSCP (user: root password: alpine) Change File Protocol to SCP.</p>
<p><img src="http://blog.teliaz.com/wp-content/uploads/2010/07/winscp2.png" alt="" title="winscp2" width="519" height="357" /></p>
<p>Once OpenSSH is installed your phone will be vunerable to all users in a specific wifi subnet. Make sure to Use the WinSCP terminal window an use this command to change password:</p>
<pre class="brush: php">
passwd root
type in password, press return
type it in again, press return
</pre>
<p>To avoid frequent logouts remember to change the Setting -> General -> Auto-Lock (5 minutes or Never)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=697</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capture Save/Load/Remove Image in documents directory</title>
		<link>http://blog.teliaz.com/?p=685</link>
		<comments>http://blog.teliaz.com/?p=685#comments</comments>
		<pubDate>Thu, 08 Jul 2010 22:52:25 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[save]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=685</guid>
		<description><![CDATA[NSFileManager offers a convenient way to write images to and load them from the documents directory. If you’re frequently doing that in your project, I suggest to wrap up NSFileManager support in three simple methods: Save/Load/Remove Image Methods //saving an image - (void)saveImage:(UIImage*)image:(NSString*)imageName { NSData *imageData = UIImagePNGRepresentation(image); //convert image into .png format. NSFileManager *fileManager [...]]]></description>
			<content:encoded><![CDATA[<p>NSFileManager offers a convenient way to write images to and load them from the documents directory.<br />
If you’re frequently doing that in your project, I suggest to wrap up NSFileManager support in three simple methods:</p>
<h2 style="font-size:15px">Save/Load/Remove Image Methods</h2>
<pre class="brush: c">
//saving an image

- (void)saveImage:(UIImage*)image:(NSString*)imageName {

NSData *imageData = UIImagePNGRepresentation(image); //convert image into .png format.

NSFileManager *fileManager = [NSFileManager defaultManager];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@&quot;%@.png&quot;, imageName]];

[fileManager createFileAtPath:fullPath contents:imageData attributes:nil];

NSLog(@&quot;image saved&quot;);

}

//removing an image

- (void)removeImage:(NSString*)fileName {

NSFileManager *fileManager = [NSFileManager defaultManager];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@&quot;%@.png&quot;, fileName]];

[fileManager removeItemAtPath: fullPath error:NULL];

NSLog(@&quot;image removed&quot;);

}

//loading an image

- (UIImage*)loadImage:(NSString*)imageName {

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@&quot;%@.png&quot;, imageName]];

return [UIImage imageWithContentsOfFile:fullPath];

}
</pre>
<h2 style="font-size:12px">Now, you can easily save an image like:</h2>
<pre class="brush: c">[self saveImage: myUIImage: @&quot;myUIImageName&quot;];</pre>
<h2 style="font-size:12px">or load it like:</h2>
<pre class="brush: c">myUIImage = [self loadImage: @&quot;myUIImageName&quot;];</pre>
<h2 style="font-size:12px">or remove it like:</h2>
<pre class="brush: c">[self removeImage: @&quot;myUIImageName&quot;];</pre>
<h2 style="font-size:15px">Capture an image</h2>
<pre class="brush: c">
- (UIImage*) getGLScreenshot {
    NSInteger myDataLength = 320 * 480 * 4;

    // allocate array and read pixels into it.
    GLubyte *buffer = (GLubyte *) malloc(myDataLength);
    glReadPixels(0, 0, 320, 480, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

    // gl renders &quot;upside down&quot; so swap top to bottom into new array.
    // there&#039;s gotta be a better way, but this works.
    GLubyte *buffer2 = (GLubyte *) malloc(myDataLength);
    for(int y = 0; y &lt;480; y++)
    {
        for(int x = 0; x &lt;320 * 4; x++)
        {
            buffer2[(479 - y) * 320 * 4 + x] = buffer[y * 4 * 320 + x];
        }
    }

    // make data provider with data.
    CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, NULL);

    // prep the ingredients
    int bitsPerComponent = 8;
    int bitsPerPixel = 32;
    int bytesPerRow = 4 * 320;
    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
    CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
    CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;

    // make the cgimage
    CGImageRef imageRef = CGImageCreate(320, 480, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);

    // then make the uiimage from that
    UIImage *myImage = [UIImage imageWithCGImage:imageRef];
    return myImage;
}

- (void)saveGLScreenshotToPhotosAlbum {
	UIImageWriteToSavedPhotosAlbum([self getGLScreenshot], nil, nil, nil);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=685</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CLLocationManager delegate method is not called in iOS4</title>
		<link>http://blog.teliaz.com/?p=675</link>
		<comments>http://blog.teliaz.com/?p=675#comments</comments>
		<pubDate>Thu, 08 Jul 2010 21:02:38 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[CLLocation]]></category>
		<category><![CDATA[CLLocationManager]]></category>
		<category><![CDATA[didupdatetolocation]]></category>
		<category><![CDATA[iOS4]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[simulator]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=675</guid>
		<description><![CDATA[Weird bug-easy solution. I did have this weird issue also when updating to SDK4.0. I couldn&#8217;t get CLLocationManager to work on simulator. This problem also existed in iPhone Simulator 3.1.3. The solution is quite weird. Open the Airport (wifi) in your mac and the CLLocationManager will work as before fetching the Cupertino, or in my case fetching a wide area [...]]]></description>
			<content:encoded><![CDATA[<div style="width: 100%; float: left;"><img class="postImage alignleft size-thumbnail wp-image-602" style="padding:8px;" title="extra-xcode" src="http://blog.teliaz.com/wp-content/uploads/2010/07/orig_iphone_maps_logo.jpg" alt="" width="200" height="200" />Weird bug-easy solution.<br />
I did have this weird issue also when updating to SDK4.0. I couldn&#8217;t get CLLocationManager to work on simulator. This problem also existed in iPhone Simulator 3.1.3.</p>
<p>The solution is quite weird. <strong>Open the Airport (wifi) in your mac</strong> and the CLLocationManager will work as before fetching the Cupertino, or in my case fetching a wide area of my country.<br />
I guess the Location is estimated by the internet ip address of your connection.</p>
</div>
<p><span id="more-675"></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=675</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NSString Quickies</title>
		<link>http://blog.teliaz.com/?p=662</link>
		<comments>http://blog.teliaz.com/?p=662#comments</comments>
		<pubDate>Sat, 03 Jul 2010 08:37:34 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[objective c]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[NSString]]></category>
		<category><![CDATA[obective c]]></category>
		<category><![CDATA[programmming]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=662</guid>
		<description><![CDATA[Yet another small useful collection of small code snippets for NSString. General &#8216;join&#8217; an array of strings into a single string NSArray *chunks = ... get an array, say by splitting it; string = [chunks componentsJoinedByString: @&#38;amp;amp;quot; /// &#38;amp;amp;quot;]; would produce something like oop /// ack /// bork /// greeble /// ponies &#8216;split&#8217; a string [...]]]></description>
			<content:encoded><![CDATA[<div style="width: 100%; float: left;"><img class="postImage alignleft size-thumbnail wp-image-602" title="extra-xcode" src="http://blog.teliaz.com/wp-content/uploads/2010/06/extra-xcode-150x150.png" alt="" width="200" height="200" /><br />
Yet another small useful collection of small code snippets for NSString.</div>
<p><span id="more-662"></span></p>
<h3>General</h3>
<ul>
<li><strong>&#8216;join&#8217; an array of strings into a single string</strong>
<pre class="brush: php">NSArray *chunks  = ... get an array, say by splitting it;
string = [chunks componentsJoinedByString: @&amp;amp;amp;quot; /// &amp;amp;amp;quot;];</pre>
<p>would produce something like</p>
<pre class="brush: c">oop /// ack /// bork /// greeble /// ponies</pre>
</li>
<li><strong>&#8216;split&#8217; a string into an array</strong>
<pre class="brush: php"> NSString *string = @&amp;amp;amp;quot;oop:ack:bork:greeble:ponies&amp;amp;amp;quot;;
NSArray *chunks = [string componentsSeparatedByString: @&amp;amp;amp;quot;:&amp;amp;amp;quot;];</pre>
</li>
<li><strong>Converting string to an integer</strong>
<pre class="brush: php">
NSString *string = ...;
int value = [string intValue];
</pre>
<p>Similarly, there is a <code>floatValue</code> and <code>doubleValue</code> <code>NSString</code> methods.</li>
<li><strong>Iterating attributes in an attributed string</strong><br />
This prints out each of the attribute runs from an attributed string:</p>
<pre class="brush: c">- (void) iterateAttributesForString: (NSAttributedString *) string
{
    NSDictionary *attributeDict;
    NSRange effectiveRange = { 0, 0 };

    do {
        NSRange range;
        range = NSMakeRange (NSMaxRange(effectiveRange),
                             [string length] - NSMaxRange(effectiveRange));

        attributeDict = [string attributesAtIndex: range.location
                                longestEffectiveRange: &amp;amp;amp;effectiveRange
                                inRange: range];

        NSLog (@&quot;Range: %@  Attributes: %@&quot;,
               NSStringFromRange(effectiveRange), attributeDict);

    } while (NSMaxRange(effectiveRange) &lt; [string length]);

} // iterateAttributesForString</pre>
</li>
<li><strong>Making localizable strings</strong><br />
You will need a file named <code>Localizable.strings</code> that lives in your <code>English.lproj</code> directory (or whatever localization directory is appropriate). It has this syntax:</p>
<pre class="brush: c">&quot;BorkDown&quot; = &quot;BorkDown&quot;;
&quot;Start Timer&quot; = &quot;Start Timer&quot;;
&quot;Stop Timer&quot; = &quot;Stop Timer&quot;;</pre>
<p>That is, a key followed by a localized value.In your code, you can then use <code>NSLocalizedString()</code> or one of its variants:</p>
<pre class="brush: c">        [statusItem setTitle: NSLocalizedString(@&quot;BorkDown&quot;, nil)];</pre>
<p>The second argument is ignored by the function. Obstensively it is a <code>/* comment */</code> in the strings file so that you can match the key back to what it is supposed to actually be.</li>
<li><strong>NSLog without the extra crud</strong><br />
<code>NSlog</code> puts too much crud in front of the logging line. For a foundation tool that output stuff, it gets in the way. I&#8217;d still like for a replacement to expand <code>%@</code>, which the <code>printf()</code> family won&#8217;t do. Here&#8217;s a some code that&#8217;ll do that.</p>
<pre class="brush: c">#include &lt;stdarg.h&gt;

void LogIt (NSString *format, ...)
{
    va_list args;

    va_start (args, format);

    NSString *string;

    string = [[NSString alloc] initWithFormat: format  arguments: args];

    va_end (args);

    printf (&quot;%s\n&quot;, [string cString]);

    [string release];

} // LogIt</pre>
</li>
<li><strong>Putting an image into an attributed string</strong><br />
You&#8217;ll need to use a text attachment.</p>
<pre class="brush: c">- (NSAttributedString *) prettyName
{
    NSTextAttachment *attachment;
    attachment = [[[NSTextAttachment alloc] init] autorelease];
    NSCell *cell = [attachment attachmentCell];

    NSImage *icon = [self icon]; // or wherever you are getting your image
    [cell setImage: icon];

    NSString *name = [self name];
    NSAttributedString *attrname;
    attrname = [[NSAttributedString alloc] initWithString: name];

    NSMutableAttributedString *prettyName;
    prettyName = (id)[NSMutableAttributedString attributedStringWithAttachment:
                                                attachment]; // cast to quiet compiler warning
    [prettyName appendAttributedString: attrname];

    return (prettyName);

} // prettyName</pre>
<p>This puts the image at the front of the string. To put the image in the middle of the string, you&#8217;ll need to create an attributedstring with attachment, and then append that to your final attributed string.</li>
<li><strong>Stripping out newlines from a string</strong><br />
So you have an NSString and want to yank out the newlines. You can do a  split and join, like in scripting languages, or you can make a mutable copy and manipulate that:</p>
<pre class="brush: c">    NSMutableString *mstring = [NSMutableString stringWithString:string];
    NSRange wholeShebang = NSMakeRange(0, [mstring length]);

    [mstring replaceOccurrencesOfString: @&quot;
&quot;
             withString: @&quot;&quot;
             options: 0
             range: wholeShebang];

    return [NSString stringWithString: mstring];</pre>
<p>(this can also be used for generic string manipulations, not just stripping out newlines).This technique takes half the time (at least) of split/join. But probably not enough to make an impact. In a simple test, split/join took 0.124 seconds to strip 36909 newlines in a 1.5 meg textfile, and 0.071 seconds to do the same.</li>
<li><strong>Substring matching</strong><br />
<code>NSRange range = [[string name] rangeOfString: otherString options: NSCaseInsensitiveSearch];</code></li>
<li><strong>Today&#8217;s date as a string</strong><br />
The general solution for converting a date to a string is NSDateFormatter. Sometimes you need to generate a date string in a particular format easily. For instance if you need &#8220;December 4, 2007&#8243;, you can use:</p>
<pre class="brush: c">[[NSDate date] descriptionWithCalendarFormat: @&quot;%B %e, %Y&quot; timeZone: nil locale: nil]</pre>
<p>(Thanks to Mike Morton for this one)</li>
<li><strong>Trimming whitespace from ends of a string</strong>
<pre class="brush: c">    NSString *ook = @&quot;\n \t\t hello there \t\n  \n\n&quot;;
    NSString *trimmed =
        [ook stringByTrimmingCharactersInSet:
                 [NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSLog(@&quot;trimmed: &#039;%@&#039;&quot;, trimmed);</pre>
<p>produces</p>
<pre class="brush: c">2009-12-24 18:24:42.431 trim[6799:903] trimmed: &#039;hello there&#039;</pre>
</li>
</ul>
<h3>Graphics</h3>
<ul>
<li><strong>Draw a string in bold</strong>
<pre class="brush: c">- (void) drawLabel: (NSString *) label
           atPoint: (NSPoint) point
              bold: (BOOL) bold {
    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
    NSFont *currentFont = [NSFont userFontOfSize: 14.0];

    if (bold) {
	NSFontManager *fm = [NSFontManager sharedFontManager];
	NSFont *boldFont = [fm convertFont: currentFont
                               toHaveTrait: NSBoldFontMask];
	[attributes setObject: boldFont
                    forKey: NSFontAttributeName];
    } else {
	[attributes setObject: currentFont
                    forKey: NSFontAttributeName];
    }

    [label drawAtPoint: point  withAttributes: attributes];;

} // drawLabel</pre>
</li>
</ul>
<h3>Random</h3>
<ul>
<li><strong>Put a string on the pasteboard</strong><br />
Here&#8217;s a category for easily putting a string on the paste|clipboard:</p>
<pre class="brush: c">
@implementation NSString (PasteboardGoodies)

- (void) sendToPasteboard
{
        [[NSPasteboard generalPasteboard]
            declareTypes: [NSArray arrayWithObject: NSStringPboardType]
            owner:nil];
        [[NSPasteboard generalPasteboard]
            setString: self
            forType: NSStringPboardType];
} // sendToPasteboard

@end // PasteboardGoodies</pre>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=662</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode Color Themes</title>
		<link>http://blog.teliaz.com/?p=641</link>
		<comments>http://blog.teliaz.com/?p=641#comments</comments>
		<pubDate>Wed, 30 Jun 2010 15:31:24 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[fonts]]></category>
		<category><![CDATA[objective c]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=641</guid>
		<description><![CDATA[This is a small collection of my personal preference of color themes for xcode programming environment. For those who are looking for a dark theme. You can chose from one of the following color themes. I&#8217;m currently using teliaz theme, it has been tested and works very smoothly. To get teliaz theme run the following [...]]]></description>
			<content:encoded><![CDATA[<p><div style="width:100%;float:left;">
<img src="http://blog.teliaz.com/wp-content/uploads/2010/06/extra-xcode-150x150.png" alt="" title="extra-xcode" width="200" height="200" class="postImage alignleft size-thumbnail wp-image-602" /> <br/> This is a small collection of my personal preference of color themes for xcode programming environment. For those who are looking for a dark theme. You can chose from one of the following color themes. I&#8217;m currently using teliaz theme, it has been tested and works very smoothly.
</div>
<p></p>
<p>To get<br />
<h2 style="font-size: 12px">teliaz theme</h2>
<p> run the following code in Terminal:</p>
<pre class="brush: php">
mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/TeliazTheme.xccolortheme &amp;&gt; TeliazTheme.xccolortheme
</pre>
<p>To get<br />
<h2 style="font-size: 12px">Ego theme</h2>
<p> run the following code in Terminal:</p>
<pre class="brush: php">
mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/XCodeColorTheme.xccolortheme &amp;&gt; EgoTheme.xccolortheme
</pre>
<p>&#8220;EGO&#8221; uses the font &#8220;DejaVu Sans Mono&#8221; at 12pt. Some of you may know it as &#8220;Panic Sans&#8221; from Panic&#8217;s Coda (which is a repackaged version of it). You can grab the font over at <a href="http://dejavu-fonts.org/wiki/index.php?title=Download">dejavu-fonts.org</a>. If you already have Code installed, feel free to swap in Panic Sans in place of DejaVu Sans Mono.</p>
<p>To get<br />
<h2 style="font-size: 12px">Humane Theme</h2>
<p> run the following code in Terminal:</p>
<pre class="brush: php">
mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/Humane.xccolortheme &amp;&gt; Humane.xccolortheme
</pre>
<p>Now just restart Xcode, go to Preferences > Fonts &#038; Colors, and select &#8220;one of these themes&#8221; from the color theme drop down. Hope you like it!! Happy coding&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=641</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Objective C &#8211; Basic Datatypes and NSLog</title>
		<link>http://blog.teliaz.com/?p=623</link>
		<comments>http://blog.teliaz.com/?p=623#comments</comments>
		<pubDate>Mon, 28 Jun 2010 22:37:04 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[objective c]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=623</guid>
		<description><![CDATA[Have you been frustrated sometimes trying to debug an application and really making it worse, the output of your logs are not as desired. Complete chaos and nonsense. Some of the concepts here will be familiar in c coding language, as objective c is just an extended c with object oriented approach. Take a quick [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://blog.teliaz.com/wp-content/uploads/2010/06/extra-xcode-150x150.png" alt="" title="extra-xcode" width="200" height="200" class="postImage alignleft size-thumbnail wp-image-602" /> <br/><br />
Have you been frustrated sometimes trying to debug an application and really making it worse, the output of your logs are not as desired. Complete chaos and nonsense.<br/><br />
Some of the concepts here will be familiar in c coding language, as objective c is just an extended c with object oriented approach. Take a quick look at this table that will surely clear things up. <br/><br/></p>
<div style="clear: both">
<style>
table.leading_line tr td { border-right: 1px solid #aaa; } 
</style>
<table class="leading_line">
<tr>
<th>Type</th>
<th>Constants</th>
<th>NSLog</th>
<th>Short Explanation </th>
</tr>
<tr>
<td>char </td>
<td> &quot;a&quot;, &quot;\n&quot; </td>
<td> %c</td>
<td> &#8211; </td>
</tr>
<tr>
<td>short int</td>
<td> &#8211; </td>
<td> %hi, %hx, %ho</td>
<td> %hi, %hx, %ho</td>
</tr>
<tr>
<td>unsigned short int</td>
<td>  &#8211; </td>
<td> %hi, %hx, %ho</td>
<td> %hi,<br/> %hx (hex notation), <br/>%ho (octa notation)</td>
</tr>
<tr>
<td>int</td>
<td>12, -97, 0xFFE0, 0177 </td>
<td> %i, %x, %o</td>
<td> also %d can be used in objective-c </td>
</tr>
<tr>
<td>unsigned int</td>
<td>12u, 100U, 0xFFU  </td>
<td> %u, %x, %o</td>
<td>as above</td>
</tr>
<tr>
<td>long int</td>
<td>12L, -200l, 0xfffL  </td>
<td> %lu, %lx, %lo</td>
<td>as above</td>
</tr>
<tr>
<td>long long int</td>
<td>0xe5e5e5e5LL, 500LL  </td>
<td> %lli, %llx, %llo</td>
<td>as above</td>
</tr>
<tr>
<td>long long unsigned int</td>
<td>0xe5e5e5e5ULL, 120ULL  </td>
<td> %llu, %llx, %llo</td>
<td>as above</td>
</tr>
<tr>
<td>float</td>
<td> 12.34f, 3.1e-5f </td>
<td> %f, %e, %g</td>
<td> %f (with 6 decimal place by default),<br/> %e (with scientific notation), %g (personal preference most readable)</td>
</tr>
<tr>
<td>double</td>
<td> 12.34, 3.1e-5 </td>
<td> %f, %e, %g</td>
<td> as above</td>
</tr>
<tr>
<td>long double</td>
<td> 12.34l, 3.1e-5l </td>
<td> %Lf, %Le, %Lg</td>
<td> as above</td>
</tr>
<tr>
<td>id</td>
<td> &#8211; </td>
<td>%p </td>
<td></td>
</tr>
</table>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=623</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NIBs or code? Why not both? Here’s nib2objc.</title>
		<link>http://blog.teliaz.com/?p=616</link>
		<comments>http://blog.teliaz.com/?p=616#comments</comments>
		<pubDate>Sun, 27 Jun 2010 21:55:45 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[objective c]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[nib2obj]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=616</guid>
		<description><![CDATA[(Somehow this project seems to me so simple, that I’m sure someone has done this before. Anyway). This is my feeble attempt to bring an answer to the eternal dichotomy between those arguing about the relative benefits of creating user interfaces via Interface Builder or via pure Objective-C code: let me introduce nib2objc. Unbeknown to [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://blog.teliaz.com/wp-content/uploads/2010/06/extra-xcode-150x150.png" alt="" title="extra-xcode" width="200" height="200" class="postImage alignleft size-thumbnail wp-image-602" /><br />
(Somehow this project seems to me so simple, that I’m sure someone has done this before. Anyway). This is my feeble attempt to bring an answer to the eternal dichotomy between those arguing about the relative benefits of creating user interfaces via Interface Builder or via pure Objective-C code: let me introduce nib2objc.<br />
<span id="more-616"></span><br />
Unbeknown to most of us, the ibtool utility bundled with Interface Builder and Xcode allows us to inspect the contents of NIB files (or XIBs, for that matter) and get from them nice property lists XML streams, which I transform in NSDictionary instances, which I loop over and over util I get something that looks like this:</p>
<pre class="brush: c">
UIView *view6 = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 460.0)];
view6.frame = CGRectMake(0.0, 0.0, 320.0, 460.0);
view6.alpha = 1.000;
view6.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
view6.backgroundColor = [UIColor colorWithWhite:0.750 alpha:1.000];
view6.clearsContextBeforeDrawing = NO;
// ...

UIButton *view9 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
view9.frame = CGRectMake(167.0, 65.0, 72.0, 37.0);
view9.adjustsImageWhenDisabled = YES;
view9.adjustsImageWhenHighlighted = YES;
view9.alpha = 1.000;
view9.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
view9.clearsContextBeforeDrawing = NO;
view9.clipsToBounds = NO;
view9.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
// ...
[view9 setTitleShadowColor:[UIColor colorWithWhite:0.000 alpha:1.000] forState:UIControlStateSelected];

// ...
[view6 addSubview:view9];
// ...
</pre>
<p>Using this tool, I can now use IB for design, and then generate the code for those designs, in case I prefer to use a code-only approach (usually for UITableViewCells, as I explained before). For the moment it only works with UIKit classes, but I don’t think it might be a problem to extend it to AppKit classes as well.</p>
<p>I hope this project is useful to all of you! As usual, open source, public domain and on <a href="http://github.com/akosma/nib2objc/">Github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=616</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C Categories as Stylesheets</title>
		<link>http://blog.teliaz.com/?p=589</link>
		<comments>http://blog.teliaz.com/?p=589#comments</comments>
		<pubDate>Sun, 27 Jun 2010 20:52:04 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[objective c]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=589</guid>
		<description><![CDATA[It is very important that iPhone and iPad applications use visual styles in a coherent way. This helps users learn how to use your application faster, it helps them scan your UI for important information as quickly as possible, and it also can convey a strong marketing message; companies who want iPhone or iPad applications [...]]]></description>
			<content:encoded><![CDATA[<p>
<img src="http://blog.teliaz.com/wp-content/uploads/2010/06/extra-xcode-150x150.png" alt="" title="extra-xcode" width="200" height="200" class="postImage alignleft size-thumbnail wp-image-602" /><br />
It is very important that iPhone and iPad applications use visual styles in a coherent way. This helps users learn how to use your application faster, it helps them scan your UI for important information as quickly as possible, and it also can convey a strong marketing message; companies who want iPhone or iPad applications often have complex visual identities, including predefined fonts and colors, and they will want their applications to match those choices.﻿<br />
<span id="more-589"></span></p>
<p>However, getting all the UI widgets to look similarly can be complex, particularly in large applications; what if your client or their designers change their minds about the font size or some background color right before shipping your project? Of course you can “search and replace” all occurrences of some color using Xcode, but you have the risk of leaving some unchanged widget somewhere. And believe me, this happens really often.</p>
<p>In this article I will discuss a simple approach, using Objective-C categories, to keep your styling information separated from the rest of the application, using a system that will be familiar to developers used to creating websites using CSS (Cascading Style Sheets).</p>
<h3>FIRST APPROACH: SIMPLE CATEGORIES</h3>
<p>The first, easiest approach is to create simple UIFont and UIColor categories in your application, and provide semantic descriptions of the data you want to style; for example “customerNameFont” and “companyPhoneColor” are good names. You can add as many class methods as you want to the UIFont and UIColor classes for that:</p>
<pre class="brush: c">
@interface UIFont (YourAppName)

+ (UIFont *)customerNameFont;
+ (UIFont *)customerPhoneFont;

@end

@implementation UIFont (YourAppName)

+ (UIFont *)customerNameFont
{
    return [UIFont fontWithName:@&quot;Helvetica&quot; size:22.0];
}

+ (UIFont *)customerPhoneFont
{
    return [UIFont boldSystemFontOfSize:15.0];
}

@end
</pre>
<p>﻿<br />
And we provide the same treatment to the UIColor class:</p>
<pre class="brush: c">
@interface UIColor (YourAppName)

+ (UIColor *)customerNameColor;
+ (UIColor *)customerPhoneColor;

@end

@implementation UIColor (YourAppName)

+ (UIColor *)customerNameColor
{
      return [UIColor blueColor];
}

+ (UIColor *)customerPhoneColor
{
      return [UIColor redColor];
}
@end
</pre>
<p>Then, you can use those method names in the rest of your application:</p>
<pre class="brush: c">
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @&quot;Cell&quot;;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                       reuseIdentifier:CellIdentifier] autorelease];

        // And here goes the styling!
        cell.textLabel.font = [UIFont customerNameFont];
        cell.textLabel.textColor = [UIColor customerNameColor];

        cell.detailTextLabel.font = [UIFont customerPhoneFont];
        cell.detailTextLabel.textColor = [UIColor customerPhoneColor];
    }

    Customer *cust = [self.data objectAtIndex:indexPath.row];
    cell.textLabel.text = cust.name
    cell.detailTextLabel.text = cust.phone

    return cell;
}
</pre>
<p>The advantage of this simple approach is that all styles are managed from a central location, and you can change the fonts and colors of your application in a single step.</p>
<p>There are, however, two major disadvantages:</p>
<p>Colors and fonts defined on their respective categories will not be available in Interface Builder, so you might have to override viewDidLoad or other methods to force the styling at a certain moment, or to set the color and font values manually, which might lead to duplicate information.<br />
Some UI elements have support for even more styling information, like shadows or CGAffineTransform values, which cannot be handled in a simple way with this method.<br />
We need some kind of CSS for iPhone applications, and the next section provides a rudimentary approach to that problem.</p>
<h3>SECOND APPROACH, “CASCADING STYLE” CLASSES</h3>
<p>Let’s push the idea of semantic styling a bit; in the previous example, we created separated categories for UIFont and UIColor and used them in atomic form, changing individual properties of your widgets, one by one.</p>
<p>What if you wanted to set several properties at once, just like with CSS classes on web pages? What if you had a system which could be extended to support more properties, for other, as of yet unknown, future UI widgets? For that, we would need a special container for style information, like a CSS stylesheet, and we should be able to assign this container to any kind of visual widget; in turn, those widgets would automatically adapt their layout and appearance. There are many different ways to do this; and this is just one of them.</p>
<p>First I declare a class called AKCascadingStyle, which holds basic styling information, and which is able to apply that information to any kind of object passed in parameter:</p>
<pre class="brush: c">
@interface AKCascadingStyle : NSObject
{
@private
    UIFont *_font;
    UIColor *_textColor;
    UIColor *_backgroundColor;
    UIColor *_tintColor;
}

@property (nonatomic, retain) UIFont *font;
@property (nonatomic, retain) UIColor *textColor;
@property (nonatomic, retain) UIColor *backgroundColor;
@property (nonatomic, retain) UIColor *tintColor;

+ (id)style;
+ (id)styleFromObject:(id)object;

- (void)applyToObject:(id)object;
- (void)setValuesFromObject:(id)object;

@end
</pre>
<p>This class can be inherited and extended, and its methods can be overridden, as we’ll see shortly, to add support for more properties. Then I add a category on NSObject (careful with this!) to support adding and retrieving style information in the form of AKCascadingStyle instances:</p>
<pre class="brush: c">
@class AKCascadingStyle;

@interface NSObject (AKCascadingStyle)

@property (nonatomic, retain) AKCascadingStyle *cascadingStyle;

@end
</pre>
<p>Why a category on NSObject? Because not everything you see on your iPhone screen is a subclass of UIView! UIBarButtonItems, for example, inherit from UIBarItem, which itself inherits from NSObject, and not from UIView. By the way, by extending NSObject, this code could also be used in Mac OS X applications, for example, without modification.</p>
<p>Given that categories cannot add ivars to existing classes, the getter of this property will call the [AKCascadingStyle styleFromObject:] method above:</p>
<pre class="brush: c">
@implementation NSObject (AKCascadingStyle)

@dynamic cascadingStyle;

- (void)setCascadingStyle:(AKCascadingStyle *)style
{
    [style applyToObject:self];
}

- (id)cascadingStyle
{
    return [AKCascadingStyle styleFromObject:self];
}

@end
</pre>
<p>Both [AKCascadingStyle applyToObject:] and [AKCascadingStyle styleFromObject:] are polymorphic (as all Objective-C methods are) so subclasses can extend their functionality as required (but don’t forget to send the same message to “super” before!):</p>
<pre class="brush: c">
@interface ShadowStyle : AKCascadingStyle
{
@private
    CGSize _shadowOffset;
    UIColor *_shadowColor;
}

@property (nonatomic) CGSize shadowOffset;
@property (nonatomic, retain) UIColor *shadowColor;

@end
</pre>
<p>Then, to use these style classes in your own controllers, just do the following:</p>
<pre class="brush: c">
- (IBAction)addStyle:(id)sender
{
    self.contentsTextView.cascadingStyle = [ShadowStyle style];
}
</pre>
<p>Setting this property will automatically set all the required parameters in your widget; text color, background colors, transformations, you name it. You can inherit styles in order to reuse them, and you can style pretty much any kind of UIKit widget with it.</p>
<p>You can download the code of this project from <a href="http://github.com/akosma/AKCascadingStyle">Github</a>! Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=589</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone 4 vs iPhone 3GS (Comparison Sheets)</title>
		<link>http://blog.teliaz.com/?p=564</link>
		<comments>http://blog.teliaz.com/?p=564#comments</comments>
		<pubDate>Thu, 24 Jun 2010 14:35:01 +0000</pubDate>
		<dc:creator>teliaz</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[tech news]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone 4]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[specs]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://blog.teliaz.com/?p=564</guid>
		<description><![CDATA[Check this informative comparison sheets&#8230;. Some extra specs: • Front glass panel of the iPhone is constructed of Corning Gorilla Glass ● 3.7V 1420 mAh Li-Polymer battery ● iPhone 4 has a whopping 512 MB ● Improved audio chamber aids in clarifying sounds leaving the iPhone ● Apple has integrated the UMTS, GPS, Wi-Fi, and bluetooth antennas into [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://cdn.venturebeat.com/wp-content/uploads/2009/02/iphone4.png" class="alignnone" width="263" height="282" /><br />
Check this informative comparison sheets&#8230;.<br />
<span id="more-564"></span><br />
<a href="http://blog.teliaz.com/wp-content/uploads/2010/06/iphone-3gs-vs-iphone-4.png"><img title="iphone-3gs-vs-iphone-4" src="http://blog.teliaz.com/wp-content/uploads/2010/06/iphone-3gs-vs-iphone-4.png" alt="" width="492" height="877" /></a></p>
<p><!--more--></p>
<p><a href="http://blog.teliaz.com/wp-content/uploads/2010/06/iphone-3gs-vs-iphone-4.png"></a><a href="http://blog.teliaz.com/wp-content/uploads/2010/06/IphonesComparison.jpg"><img title="IphonesComparison" src="http://blog.teliaz.com/wp-content/uploads/2010/06/IphonesComparison.jpg" alt="" width="616" height="2000" /></a></p>
<p>Some extra specs:</p>
<p><strong>•</strong> Front glass panel of the iPhone is constructed of <strong><a href="http://www.corning.com/specialtymaterials/index.aspx" target="_blank">Corning Gorilla Glass</a><br />
<span style="font-weight: normal;">● 3.7V 1420 mAh Li-Polymer battery<br />
● iPhone 4 has a whopping 512 MB<br />
● Improved audio chamber aids in clarifying sounds leaving the iPhone<br />
</span></strong>● Apple has integrated the UMTS, GPS, Wi-Fi, and bluetooth antennas into the stainless steel inner frame<br />
● AGD1 is the new 3 axis gyroscope</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.teliaz.com/?feed=rss2&amp;p=564</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
