<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>ZaldzBugz Frameworks</title>
	<atom:link href="http://zaldzbugz.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://zaldzbugz.wordpress.com</link>
	<description>A man of tomorrow is forged by his battles today.</description>
	<lastBuildDate>Wed, 25 Jan 2012 10:18:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='zaldzbugz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/615a481643543b48f69a2b819ce205fd?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>ZaldzBugz Frameworks</title>
		<link>http://zaldzbugz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://zaldzbugz.wordpress.com/osd.xml" title="ZaldzBugz Frameworks" />
	<atom:link rel='hub' href='http://zaldzbugz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>PHP Notes</title>
		<link>http://zaldzbugz.wordpress.com/2010/07/21/php-notes/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/07/21/php-notes/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 04:00:49 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[PHP Notes]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=341</guid>
		<description><![CDATA[Cron Jobs in Cpanel The command to run: /usr/local/bin/php -f/home/[username]/public_html/[fileName].php Next you&#8217;ll want to select an option from all the select boxes. Remember to select an option in each box. If you want something to run every day at 1AM, select Minute: 0; Hour: 1; Day: Every; Month: Every; Weekday: Every; Happy Coding<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=341&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3><span style="color:#ff6600;">Cron Jobs in Cpanel</span></h3>
<p>The command to run:</p>
<pre><code>/usr/local/bin/php -f/home/[username]/public_html/[fileName].php</code></pre>
<p>Next you&#8217;ll want to select an option from all the select boxes.  Remember to select an option in each box. If you want something to run  every day at 1AM, select Minute: 0; Hour: 1; Day: Every; Month: Every;  Weekday: Every;</p>
<p>Happy Coding <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/341/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=341&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/07/21/php-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>Random sort NSArray</title>
		<link>http://zaldzbugz.wordpress.com/2010/07/16/randomly-sort-nsarray/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/07/16/randomly-sort-nsarray/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 07:06:30 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[Random Sort NSArray]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=328</guid>
		<description><![CDATA[This tutorial gives you information on how to sort an array randomly. First you need to have a function that handles the randomization. int randomSort(id obj1, id obj2, void *context ) { // returns random number -1 0 1 return (arc4random()%2);     } Then you could call this function to any array you wanted to <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=328&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This tutorial gives you information on how to sort an array randomly.</p>
<p>First you need to have a function that handles the randomization.</p>
<pre>int randomSort(id obj1, id obj2, void *context ) {
 // returns random number -1 0 1
 return (arc4random()%2);    
}</pre>
<p>Then you could call this function to any array you wanted to sort  randomly.</p>
<pre>[arrayObject sortUsingFunction:randomSort context:nil];</pre>
<p>Or you can use this one as much properly implemented random sorting of array.</p>
<pre>-(NSMutableArray *)randomSortArray:(NSMutableArray *)array {
 srandom(time(NULL));
 for (NSInteger x = 0; x &lt; [array count]; x++) {
 NSInteger randInt = (arc4random() % ([array count] - x)) + x;
 [array exchangeObjectAtIndex:x withObjectAtIndex:randInt];
 }
return array;
}</pre>
<p>&nbsp;</p>
<p>Happy Coding <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=328&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/07/16/randomly-sort-nsarray/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>iPhoneDev SDK Notes</title>
		<link>http://zaldzbugz.wordpress.com/2010/07/14/objective-c-notes/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/07/14/objective-c-notes/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 09:12:50 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[iPhoneDev SDK]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=306</guid>
		<description><![CDATA[Using Pointers //Using POINTER int a = 10;                //1. we set a = 10 int b = 15; const int *ptr = &#38;a;    //2. we point our pointer to the mem address of &#8220;a&#8221; a = 20;                          //3. we a= 20 //4. we output the *ptr that points <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=306&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3><span style="color:#ff6600;">Using Pointers</span></h3>
<p>//Using POINTER<br />
int a = 10;                //1. we set a = 10<br />
int b = 15;</p>
<p>const int *ptr = &amp;a;    //2. we point our pointer to the mem address of &#8220;a&#8221;<br />
a = 20;                          //3. we a= 20</p>
<p>//4. we output the *ptr that points to &#8220;a&#8221;<br />
//so any changes of a will be reflected also to *ptr value.<br />
NSLog(@&#8221;POINTER VALUE &#8211; %d&#8221;, *ptr); //20</p>
<h3><span style="color:#ff6600;">NSDate</span></h3>
<p>Adding interval to a date and create date from components (NSInteger values)</p>
<pre>NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar];
 NSDateComponents *dateComps = [[NSDateComponents alloc] init];
 [dateComps setDay:item.day];
 [dateComps setMonth:item.month];
 [dateComps setYear:item.year];
 [dateComps setHour:item.hour];
 [dateComps setMinute:item.minute];
//sample date is 2010-09-14 00:41:00
 NSDate *itemDate = [calendar dateFromComponents:dateComps];
[dateComps release];
int minutesBefore = 1; //1 minute
//we are adding 60 seconds to our current date here...
NSDate *fireDate = [itemDate dateByAddingTimeInterval:-(minutesBefore*60)];</pre>
<h3><span style="color:#ff6600;">UIDevice</span></h3>
<p>The <code>UIDevice</code> class provides a singleton  instance representing the current device. From this instance you can  obtain information about the device such as unique ID, assigned name,  device model, and operating-system name and version.</p>
<p>You also use  the <code>UIDevice</code> instance to detect changes in the device’s  characteristics, such as physical orientation. You get the current  orientation using the <code><a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/orientation">orientation</a></code> property or receive change notifications by registering for the <code><a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/c/data/UIDeviceOrientationDidChangeNotification">UIDeviceOrientationDidChangeNotification</a></code> notification. Before using either of these techniques to get  orientation data, you must enable data delivery using the <code><a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instm/UIDevice/beginGeneratingDeviceOrientationNotifications">beginGeneratingDeviceOrientationNotifications</a></code> method. When you no longer need to track the device orientation, call  the <code><a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instm/UIDevice/endGeneratingDeviceOrientationNotifications">endGeneratingDeviceOrientationNotifications</a></code> method to disable the delivery of notifications.</p>
<p>Similarly, you  can use the <code>UIDevice</code> instance to obtain information and  notifications about changes to the battery’s charge state (described by  the <code><a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/batteryState">batteryState</a></code> property) and charge level (described by the <code><a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/batteryLevel">batteryLevel</a></code> property). The <code>UIDevice</code> instance also provides access to  the proximity sensor state (described by the <code><a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html#//apple_ref/occ/instp/UIDevice/proximityState">proximityState</a></code> property). The proximity sensor detects whether the user is holding the  device close to their face. Enable battery monitoring or proximity  sensing only when you need it.</p>
<p>sample usage:</p>
<pre>UIDevice* device = [UIDevice currentDevice];
NSString* deviceId = [device uniqueIdentifier];</pre>
<pre><code>--

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];</code>
<code>--

if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
        ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {
}
</code></pre>
<h3><span style="color:#ff6600;">parentViewController &#8211; dismissing views</span></h3>
<p>The <strong>parent view controller</strong> is responsible for dismissing the modal view controller it presented using the presentModalViewController:animated: method. If you call this method on the modal view controller itself, however, the modal view controller automatically forwards the message to its parent view controller.</p>
<p>To dismiss the PRESENTED modal view, use below that is right.</p>
<pre><code>[[self parentViewController] dismissModalViewControllerAnimated:YES]; //right</code><code>
</code>
<span style="font-family:monospace;">[[picker parentViewController] dismissModalViewControllerAnimated:YES]; //right</span>
<code>[self dismissModalViewControllerAnimated:YES]; //wrong</code></pre>
<h3><span style="color:#ff6600;">Selectors</span></h3>
<p>Selectors lets you perform methods during such events.</p>
<p>You can perform selectors with delays using this one below.</p>
<pre>[self performSelector:@selector(method:) withObject:nil afterDelay:3];</pre>
<h3><span style="color:#ff6600;">UIAccelerometer</span></h3>
<p>The <code>UIAccelerometer</code> class lets you register to receive  acceleration-related data from the onboard hardware. As a device moves,  its hardware reports linear acceleration changes along the primary axes  in three-dimensional space. You can use this data to detect both the  current orientation of the device (relative to the ground) and any  instantaneous changes to that orientation. You might use instantaneous  changes as input to a game or to initiate some action in your  application.</p>
<p>UIAccelerometerDelegate:</p>
<p>The <code><a href="http://developer.apple.com/iphone/library/documentation/uikit/reference/UIAccelerometerDelegate_Protocol/UIAccelerometerDelegate/UIAccelerometerDelegate.html#//apple_ref/occ/intf/UIAccelerometerDelegate" target="_top">UIAccelerometerDelegate</a></code> is a formal protocol,  so your delegate object must implement the method it defines. The shared  accelerometer object delivers the acceleration data to your delegate at  the specified interval. It delivers these events on the main thread of  your application when it is in the <code><!--a target="_top" -->NSDefaultRunLoopMode<!--/a--></code> run loop mode.</p>
<p>See codes below:</p>
<pre>// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
 [super viewDidLoad];

 self.accelerometer = [UIAccelerometer sharedAccelerometer];
 self.accelerometer.updateInterval = .1;
 self.accelerometer.delegate = self;
}

-  (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
 labelX.text = [NSString stringWithFormat:@"%@%f", @"X: ", acceleration.x];
 labelY.text = [NSString stringWithFormat:@"%@%f", @"Y: ", acceleration.y];
 labelZ.text = [NSString stringWithFormat:@"%@%f", @"Z: ", acceleration.z];

 self.progressX.progress = ABS(acceleration.x);
 self.progressY.progress = ABS(acceleration.y);
 self.progressZ.progress = ABS(acceleration.z);
}</pre>
<h3><span style="color:#ff6600;">Enumerations</span></h3>
<p>TyfeDef is an alternative name assignment of an existing types. Enum makes your name assignment become an integral type and should only be used to declare variables which hold one of the  values listed in the declaration (that is, one of <code>kBlue</code>, <code>kRed</code>,  and <code>kGreen</code>).  You can assign a ColorType variable another value by casting, though, so you have to be careful  when reading enum values.</p>
<pre>#1
typedef enum {
 kBlue,
 kRed,
 kGreen
} ColorType;

#2

enum Ename { Bob, Mary, John };
typedef enum Ename EmployeeName;</pre>
<h3><span style="color:#ff6600;">UITouch</span></h3>
<p>Generally we have these responders to work with touches. We can override  these methods anyway.</p>
<pre>- (void)touchesBegan:(NSSet *)touches  withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches  withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches  withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches  withEvent:(UIEvent *)event;

Sample usage:

-  (void)touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event {
 //we acquire all touches happened in our view then we convert  those touches to coordinates
 UITouch *touch = [[event allTouches]  anyObject];
 CGPoint asd = [touch locationInView:self.view];
 NSLog(@"X Touch Location...%f", asd.x);
 NSLog(@"Y Touch  Location...%f", asd.y);
}</pre>
<h3><span style="color:#ff6600;">NSThread</span></h3>
<p>An NSThread object controls a thread of execution. You use an NSThread  when you want to terminate or delay a thread or you want a new thread.</p>
<p>A <em>thread</em> is an executable unit. A <em>task</em> is made up of one  or more threads. Each thread has its own execution stack and is capable of  independent I/O. All threads share the virtual memory address space and  communication rights of their task. When a thread is started, it is <em>detached</em> from its initiating thread. The new thread runs independently. That is, the  initiating thread does not know the new thread&#8217;s state.</p>
<p>Usage:</p>
<pre>[NSThread detachNewThreadSelector:@selector(myFunction) toTarget:self withObject:nil];</pre>
<p>Inside Method myFunction.</p>
<pre>- (void)myFunction {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// wait for 3 seconds before starting the thread, you don't have to do that. This is just an example how to stop the NSThread for some time
[NSThread sleepForTimeInterval:3];
[self performSelectorOnMainThread:@selector(makeMyProgressBarMoving) withObject:nil waitUntilDone:NO];
[pool release];
<span style="font-family:Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;line-height:19px;white-space:normal;font-size:13px;">}</span></pre>
<p>and this is inside makeMyProgressBarMoving</p>
<pre>- (void)makeMyProgressBarMoving {
float actual = [threadProgressView progress];
threadValueLabel.text = [NSString stringWithFormat:@"%.2f", actual];
if (actual &lt; 1) {
threadProgressView.progress = actual + 0.01;
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(makeMyProgressBarMoving) userInfo:nil repeats:NO];
}
else {
threadStartButton.hidden = NO;
//[NSThread exit];
}
}</pre>
<h3><strong><span style="color:#ff6600;">UIPopOverController</span></strong></h3>
<p>- This works only in iPad from OS3.2 and so on.</p>
<p>- To use this class you need to have a viewController that is displayed inside this popup. See below example.</p>
<pre>ViewController *viewController = [[ViewControlleralloc] initWithNibName:@"ViewController" bundle:nil];
UIPopoverController *aPopup = [[UIPopoverController alloc]initWithContentViewController:viewController];
aPopup.popoverContentSize = CGSizeMake(400.0f,180.0f);
viewController.aPopupController =  aPopup;</pre>
<p><strong>aPopController</strong> is a member variable of our ViewController. This is used only if you have methods inside the viewController class to dismiss it. Like the code below.</p>
<pre>[aPopupController dismissPopoverAnimated:YES];</pre>
<h3><span style="color:#ff6600;">NSLocal</span></h3>
<p>- Used to detect Local languange and location</p>
<pre>NSLocale *localInfo   = [NSLocale currentLocale];
NSString *codePays    = [localInfo objectForKey:NSLocaleLanguageCode];</pre>
<h3><span style="color:#ff6600;">UIPasteBoard</span></h3>
<p>- All your copied strings are stored here.</p>
<pre>UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
pasteBoard.items = nil; // Clear pasteboard to prevent pasting into other applications:</pre>
<h3><span style="color:#ff6600;">UIResponder</span></h3>
<p>//Below is used to remove keyboard after editing</p>
<pre>[textField resignFirstResponder];</pre>
<h3><span style="color:#ff6600;">UIActivityIndicatorView</span></h3>
<p>//Show how to animate indicator from loading the webView to finish loading.</p>
<pre>#pragma mark UIWebview delegate
- (void)webViewDidStartLoad:(UIWebView *)webView {
 [progressIndicator startAnimating];
 }
- (void)webViewDidFinishLoad:(UIWebView *)webView {
 [progressIndicator stopAnimating];
}</pre>
<h3><span style="color:#ff6600;">UIMenuController</span></h3>
<p>//Pop up buttons once you highlight uiTextField or UiWebview</p>
<p>//This can be disabled with the code below.</p>
<pre>- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
 if ( [UIMenuController sharedMenuController] )
 {
 [UIMenuController sharedMenuController].menuVisible = NO;
 }
}</pre>
<h3><span style="color:#ff6600;">NSArray &#8211; Random Sort</span></h3>
<p>First you need to have a function that handles the randomization.</p>
<pre>int randomSort(id obj1, id obj2, void *context ) {
 // returns random number -1 0 1
 return (arc4random()%3 - 1);    
}</pre>
<p>Then you could call this function to any array you wanted to sort  randomly.</p>
<pre>[arrayObject sortUsingFunction:randomSort context:nil];</pre>
<h3><span style="color:#ff6600;">UITabBar &#8211; Index of selected tabbar item<br />
</span></h3>
<p>In order to get the selected index of the selectedItem (tabbaritem).. You only need to do this.</p>
<pre>#pragma mark UI TAB BAR Delegate
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
 NSLog(@"Selected Item Index...%d",[[tabBar items] indexOfObject:tabBar.selectedItem]);
}</pre>
<h3><span style="color:#ff6600;">UIImagePickerController</span></h3>
<p>Image pickers helps users select images they want to use accordingly.</p>
<p>Note: UIImagePickerControllerDelegate should be included in your interface.<br />
1. Using the the Photo Library, we have the code below.</p>
<pre>UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
//picker.allowsImageEditing = NO;
[self presentModalViewController:picker animated:YES];
[picker release];</pre>
<p>2. Using the iPhone Camera , we have the code below.</p>
<pre>
<pre>UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
//picker.allowsImageEditing = NO;
[self presentModalViewController:picker animated:YES];
[picker release];</pre>
</pre>
<p>3. Using the iPhone Saved Photo Album , we have the code below.</p>
<pre>
<pre>UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.delegate = self;
//picker.allowsImageEditing = NO;
[self presentModalViewController:picker animated:YES];
[picker release];</pre>
</pre>
<p>Then, we use delegate methods to fetch image values from different source types. See code below.</p>
<pre>- (void)imagePickerController:(UIImagePickerController *)picker
 didFinishPickingImage:(UIImage *)image
 editingInfo:(NSDictionary *)editingInfo
{
 newImage.image = image; //this newImage is an outLet to your XIB which display a selected image.
 [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
 [[picker parentViewController] dismissModalViewControllerAnimated:YES];
}</pre>
<h3><span style="color:#ff6600;">UIButton</span></h3>
<p>Setting up uiButton with states</p>
<pre>UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

[button setImage:[UIImage imageNamed:@"btn_home2.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"btn_home1.png"] forState:UIControlStateSelected];

[button addTarget:self action:@selector(gobackToMainLibary:) forControlEvents:UIControlEventTouchUpInside];
button.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
[self.navigationBar addSubview:button];</pre>
<h3><span style="color:#008080;">error from Debugger: The program being debugged is not being  run</span></h3>
<p>If you have this kind of errors (also <span style="color:#ff0000;"><em>Error   launching remote program: security policy error.</em></span>) upon compiling application to simulator or your device. It has something to do with provisioning profiles.</p>
<p>Solution: Delete  and re-install all your <strong>Provisioning Profile</strong><strong>s</strong>:</p>
<ul>
<li>Navigate your XCode Organizer window</li>
<li>Select your device from Devices list</li>
<li><strong>Remove</strong> your Provisioning Profiles from Provisioning  Section</li>
<li>Download your Provisioning Profiles from your developer.apple.com  account</li>
<li><strong>Re-install</strong> your profiles moving all downloaded  files over the Xcode icon on the Dock</li>
</ul>
<h3><span style="color:#008080;">Push Notification</span></h3>
<p>To send Push Notifications to a device, you need a <em>device token</em>.  Device token is generated by Apple from Device ID and Application ID, so  this is unique per device and per application.</p>
<pre>See notes here:
<a href="http://" target="_blank">http://code.google.com/p/apns-php/wiki/ObjectiveC</a>
<a href="http://iphonesdkdev.blogspot.com/2009/03/apple-push-notification-service-apns.html" target="_blank">http://iphonesdkdev.blogspot.com/2009/03/apple-push-notification-service-apns.html</a></pre>
<h3><span style="color:#008080;">Native Animation</span></h3>
<p>Uses QuartzCore to animate objects</p>
<pre>#import &lt;QuartzCore/QuartzCore.h&gt;
TickerViewController *tickerController = [[TickerViewController alloc] initWithNibName:@"TickerViewController" bundle:nil];
 [myWebview addSubview:tickerController.view];

 CABasicAnimation *theAnimation;
 theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
 theAnimation.duration=10;
 theAnimation.repeatCount=2;
 theAnimation.autoreverses=NO;
 theAnimation.fromValue=[NSNumber numberWithFloat:0];
 theAnimation.toValue=[NSNumber numberWithFloat:-768];
 //[view.layer addAnimation:theAnimation forKey:@"animateLayer"];
 [[tickerController view].layer addAnimation:theAnimation forKey:@"animateLayer"];
 [tickerController release];</pre>
<h3><span style="color:#008080;">PDF Printing</span></h3>
<p>//used to print PDF</p>
<pre>See this link: <a href="http://www.danandcheryl.com/2010/05/how-to-print-a-pdf-file-using-cocoa" target="_blank">http://www.danandcheryl.com/2010/05/how-to-print-a-pdf-file-using-cocoa</a></pre>
<p>Happy Coding <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/306/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/306/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/306/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=306&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/07/14/objective-c-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending Email with Attachments</title>
		<link>http://zaldzbugz.wordpress.com/2010/07/12/sending-email-with-attachments/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/07/12/sending-email-with-attachments/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 04:10:02 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[Email]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=299</guid>
		<description><![CDATA[This tutorial gives you an idea on how to send emails in objective c with attachments. First we are aware that iPhone has this capablities already. But the question is how could we be able to use this feature in our own applications? Here is the answer: read. Anyway, there are two ways to implement <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=299&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This tutorial gives you an idea on how to send emails in objective c with attachments.</p>
<p>First we are aware that iPhone has this capablities already. But the question is how could we be able to use this feature in our own applications?</p>
<p>Here is the answer: read.</p>
<p>Anyway, there are two ways to implement emails sending in Objective C.</p>
<p>You could either use the UIApplication or the MFMailComposeViewController in MessageUI Framework.</p>
<p>Here is the procedure on sending an email using UIApplication.</p>
<p>Attach the code from this tip to a button, you can give your users a way  to promote your app to their friends via the iPhone’s built in Mail  app.</p>
<div>
<div>
<pre>- (void)sendEmailTo:(NSString*)to withCC:(NSString*)cc withBCC:(NSString*)bcc withSubject:(NSString*)subject withBody:(NSString*)body {
	NSString * url = [NSString stringWithFormat:@"mailto:?to=%@&amp;cc=%@&amp;bcc=%@&amp;subject=%@&amp;body=%@",
					  [to stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [cc stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [bcc stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [subject stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [body stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
 
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}</pre>
</div>
</div>
<p><strong>NOTE:</strong> Running this function in the iPhone Simulator  will have no effect because the simulator does not include the iPhone’s  Mail app. To see the effects of this function, it must be run on a  device.</p>
<h2>Usage</h2>
<p>Once you have that message defined in one of your classes, you can  open the Mail app with a pre-composed email with just one message call.  The following example opens an email and specifies a to, cc and bcc  address.</p>
<div>
<div>
<pre>[self sendEmailTo:@"me@me.com"
           withCC:@"cc@cc.com"
          withBCC:@"bcc@bcc.com"
      withSubject:@"Subject"
         withBody:@"&lt;p&gt;Hello, &lt;a href='http://zaldzbugz.wordpress.com'&gt;Hello&lt;/a&gt;, I am here!&lt;/p&gt;&lt;p&gt;&lt;a href='http://google.com'&gt;&lt;img src='image source here...'/&gt;&lt;/a&gt;&lt;/p&gt;"];</pre>
</div>
</div>
<p>Next is using the MessageUI Framework.</p>
<pre style="padding-left:30px;">//First we need to reference the Message UI framework.Then import
&lt;MessageUI/MessageUI.h&gt; and &lt;MessageUI/MFMailComposeViewController.h&gt;</pre>
<pre style="padding-left:30px;">//Here is the framework link incase you forgot. Macintosh
HD&gt;Developer&gt;Platforms&gt;iPhoneOS.platform&gt;developer&gt;SDKs&gt;iPhoneOS3.0.sdk&gt;System&gt;Library&gt;Frameworks

//Add this protocol to any interface you were using
&lt;MFMailComposeViewControllerDelegate&gt;</pre>
<p>Then add this code in you implementation file.</p>
<pre style="padding-left:30px;">-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
 [self dismissModalViewControllerAnimated:YES];
}

-(IBAction)mailIt {

 MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
 picker.mailComposeDelegate = self;

 [picker setSubject:@"This is a sample Subject"];

 //image...
 UIImage *roboPic = [UIImage imageNamed:@"podd.jpg"];
 NSData *imageData = UIImageJPEGRepresentation(roboPic, 1);
 [picker addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"podd.jpg"];

 //audio

 NSString *emailBody = @"This is a sample Body content.!";
 [picker setMessageBody:emailBody isHTML:YES];

 [self presentModalViewController:picker animated:YES];
 [picker release];
}
</pre>
<p>Happy Coding&#8230;:)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/299/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/299/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/299/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=299&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/07/12/sending-email-with-attachments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>UIApplication</title>
		<link>http://zaldzbugz.wordpress.com/2010/07/12/uiapplication/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/07/12/uiapplication/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 03:56:45 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[UIApplication]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=296</guid>
		<description><![CDATA[How to Open the SMS App With a Phone Number It’s the day before Christmas, so this is the last post in our advent tip series. We’ve really enjoyed writing about so many little things that are so easily accomplished with the iPhone SDK and we hope that they’ve helped you in developing your iPhone <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=296&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2 id="post-1073"><a title="Permanent Link to How to Open the SMS App With a  Phone Number" rel="bookmark" href="http://getsetgames.com/2009/12/24/iphonedev-advent-tip-24-how-to-open-the-sms-app-with-a-phone-number/">How to Open the SMS App With a Phone Number</a></h2>
<p>It’s the day before Christmas, so this is the last post in our <a href="http://getsetgames.com/tag/advent/">advent tip series</a>. We’ve  really enjoyed writing about so many little things that are so easily  accomplished with the iPhone SDK and we hope that they’ve helped you in  developing your iPhone apps. This may be the last blog post in this  series, but you can be sure we’ll still be writing about our adventures  with iPhone, cocos2d and OpenFeint development.</p>
<h2>Less Yap, More Tip</h2>
<p><img title="messages" src="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" alt="" width="69" height="85" />Today’s advent tip is how to open the Messages  app (aka the SMS app) with a specific phone number populated in the <strong>To:</strong> field. This is accomplished with great ease because the iPhone has  implemented the <strong>sms:</strong> URI scheme. Therefore, we can use  the UIApplication class’ openURL method, which we have seen before when  we discussed how to <a href="http://getsetgames.com/2009/12/12/iphonedev-advent-tip-12-how-to-dial-a-phone-number/">dial  a phone number</a>, <a href="http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/">pre-compose  an email</a>, and yes, even <a href="http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/">open  a URL</a>.</p>
<p>So here it is: the one line of code you need to pop open the SMS app  with a phone number:</p>
<div>
<div>
<pre>[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:5555555555"]];
<h2 id="post-1069"><a title="Permanent Link to How to Suspend Touch Input" rel="bookmark" href="http://getsetgames.com/2009/12/23/iphonedev-advent-tip-23-how-to-suspend-touch-input/">How  to Suspend Touch Input</a></h2>

Have you ever encountered a situation where you wish you could  just pause and resume touch input while developing an iPhone app? Sure,  you could always increase the complexity of your input handling by  considering the state of any number of variables, but there are some  times when just switching input off and on would be easiest.

We had a number of cases like this when developing <a href="http://getsetgames.com/games/addicus/">Addicus</a>. In particular,  because we have both the game and game over screens operating in a  single cocos2d scene, we were noticing some bugs that occurred because  of the way we handled input. This was solved by suspending input for  brief periods of time.
<h2>Input Goes Off</h2>

Here’s how to tell your iPhone app to stop responding to touch events  in just one line of code:
<div>
<div>
<pre>[[UIApplication sharedApplication] beginIgnoringInteractionEvents];</pre>
</div>
</div>
<h2 id="post-994"><a title="Permanent Link to How to Prevent the iPhone from  Sleeping" rel="bookmark" href="http://getsetgames.com/2009/12/17/iphonedev-advent-tip-17-how-to-prevent-the-iphone-from-sleeping/">How to Prevent the iPhone from Sleeping</a></h2>
<p><img title="put-the-iphone-to-sleep" src="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep.jpeg" alt="put-the-iphone-to-sleep" width="200" /><br />
Left idle, the iPhone goes into sleep mode after about a minute. This  narcoleptic behaviour saves on battery life, but there are situations  where you would not want the device to go to sleep. For instance, in the  middle of a multiplayer game that is turn-based, such as chess. You  could wait for longer than a minute for your opponent to make make their  move and you wouldn’t want to miss it when they did.<br />
To keep the iPhone awake and alert, simply run the following line of  code:</p>
<div>
<div>
<pre>[UIApplication sharedApplication].idleTimerDisabled = YES;</pre>
</div>
</div>
<p>Do use this tip sparingly though. The iPhone’s power is unmatched, to  be sure, but unfortunately it is not unlimited.</p>
<h2 id="post-987"><a title="Permanent Link to How to Show the Network  Activity Indicator" rel="bookmark" href="http://getsetgames.com/2009/12/16/iphonedev-advent-tip-16-how-to-show-the-network-activity-indicator/">How to Show the Network Activity Indicator</a></h2>
<p><img title="Screen shot  2009-12-16 at 10.14.26 PM" src="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM.png" alt="Screen shot 2009-12-16 at 10.14.26 PM" width="172" height="143" />The network activity indicator is like the <a href="http://getsetgames.com/2009/12/03/iphonedev-advent-tip-3-how-to-display-an-activity-indicator-with-uiactivityindicatorview/">UIActivityIndicatorView</a> we previously discussed, only it sits on the status bar, it is smaller,  and believe it or not, it is even easier to manipulate. It’s the little  rotating wheel of bars (pictured right) that shows up on the status bar  whenever your iPhone is accessing the network.</p>
<h2>Show It</h2>
<p>If you would like to let your users know that your iPhone app is  currently swapping data with the network, you can do so with this simple  line of code:</p>
<div>
<div>
<pre>[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;</pre>
</div>
</div>
<h2>Hide It</h2>
<p>You guessed it: once you’re done showing it, to hide it again, just  set the same UIApplication property to NO like so.</p>
<div>
<div>
<pre>[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;</pre>
</div>
</div>
<h2 id="post-980"><a title="Permanent Link to How to Retrieve Your App  Delegate Singleton Instance" rel="bookmark" href="http://getsetgames.com/2009/12/14/iphonedev-advent-tip-14-how-to-retrieve-your-app-delegate-singleton-instance/">How to Retrieve Your App Delegate Singleton  Instance</a></h2>
<p>You should be familiar with the application delegate class if you  have ever developed any kind of iPhone app. It is the class that  contains your app’s applicationDidFinishLaunching which most if not all  apps use as an entry point for execution. You might use it to keep track  of application-level state variables or objects, for example.<br />
As such, from time to time you will have a need to retrieve your  app’s application delegate instance. You can retrieve it from anywhere  within your app by running the following single line of code:</p>
<div>
<div>
<pre>MyAppDelegateClass *app = [[UIApplication sharedApplication] delegate];</pre>
</div>
</div>
<p>Just be sure to replace “MyAppDelegateClass” with your own iPhone  app’s application delegate class name.</p>
<h2 id="post-956"><a title="Permanent Link to How to Dial a Phone Number" rel="bookmark" href="http://getsetgames.com/2009/12/12/iphonedev-advent-tip-12-how-to-dial-a-phone-number/">How  to Dial a Phone Number</a></h2>
<p><img title="photo-4" src="http://getsetgames.com/wp-content/uploads/2009/12/photo-4-200x300.jpg" alt="photo-4" width="200" height="300" />With so many awesome games and  apps on the iPhone, it is easy to forget that it can actually be used to  make phone calls. No, really, it’s true! And as is the case with so  many other pieces of functionality, this is easy to accomplish with the  iPhone SDK.<br />
Like other phones, the iPhone supports the <strong>tel</strong> application protocol in URLs. This means that all we need to use is the  trusty openURL method of the UIApplication class. We have previously  discussed this method when <a href="http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/">pre-composing  emails</a> and, believe it or not, <a href="http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/">opening  a URL</a>.</p>
<h2>The Code</h2>
<p>Here is how to dial a phone number from your iPhone app in one line  of code:</p>
<div>
<div>
<pre>[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:555-555-5555"]];</pre>
</div>
</div>
<h2>Dialing From a Web Page</h2>
<p>You can also put links in your web pages that dial a phone number on  the iPhone by using the tel protocol like so:</p>
<div>
<div>
<pre>&lt;a href="tel:555-555-5555"&gt;Dial 555-555-5555&lt;/a&gt;</pre>
</div>
</div>
<h2 id="post-943"><a title="Permanent Link to How to Hide (and Show) the  Status Bar" rel="bookmark" href="http://getsetgames.com/2009/12/11/iphonedev-advent-tip-11-how-to-hide-and-show-the-status-bar/">How to Hide (and Show) the Status Bar</a></h2>
<p>On the iPhone’s 320×480 screen, pixel real estate is at a  premium, especially for games. Often, the status bar represents 20  pixels of height that you as a developer just can’t afford to give away.  Fortunately there are 2 simple ways to remove the status bar.</p>
<h2>UIStatusBarHidden</h2>
<p><img title="uistatusbarhidden2" src="http://getsetgames.com/wp-content/uploads/2009/12/uistatusbarhidden2.png" alt="uistatusbarhidden2" width="315" height="62" />The first way is by  adding a setting to your app’s info.plist file called UIStatusBarHidden.  This is ideal for apps that should never display the status bar. Just  follow these steps to change the setting:<br />
1. Open your iPhone app’s info.plist file.<br />
2. Command-click and select Add Row.<br />
3. Select “Status bar is initially hidden” from the drop down that  appears.<br />
4. Check the checkbox that appears next to the new row.<br />
You could also add this setting to your app’s info.plist file by  opening it in a text editor and adding the following 2 XML tags inside  the &lt;dict&gt; tag:</p>
<div>
<div>
<pre>&lt;dict&gt;
	&lt;key&gt;UIStatusBarHidden&lt;/key&gt;
	&lt;true/&gt;
	...</pre>
</div>
</div>
<h2>How to Do it With Code</h2>
<p>If you need the status bar to appear and disappear at runtime, then  you will need to use code to do so. You can hide the status bar with one  line of code:</p>
<div>
<div>
<pre>[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];</pre>
</div>
</div>
<p>And to show it again, simply call the above line and pass “NO” into  setStatusBarHidden instead of “YES”. You can also fade the status bar in  and out by passing “YES” into the “animated” part of the message.</p>
<h2 id="post-832"><a title="Permanent Link to How to Open the Mail App With a  Pre-Composed HTML Email" rel="bookmark" href="http://getsetgames.com/2009/12/06/iphonedev-advent-tip-6-how-to-open-the-mail-app-with-a-pre-composed-html-email/">How to Open the Mail App With a Pre-Composed  HTML Email</a></h2>
<div>
<a href="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1.jpg"><img title="photo 2-1" src="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1-200x300.jpg" alt="photo 2-1" width="200" height="300" /></a>Have you ever wanted to open  the Mail app with a pre-composed email? Then today’s iPhone development  advent tip is the one for you! This has many uses, but a common one is a  tell-a-friend feature in apps. If you attach the code from this tip to a  button, you can give your users a way to promote your app to their  friends via the iPhone’s built in Mail app.</p>
<h2>A Handy Function</h2>
<p>The sendEmailTo function, seen below, can be included in any class in  your app. This function gives you a simple interface to send emails. It  allows you to define “to” addresses, “cc” addresses, “bcc” addresses, a  subject and a body. The body supports HTML tags.</p>
<div>
<div>
<pre>- (void)sendEmailTo:(NSString*)to withCC:(NSString*)cc withBCC:(NSString*)bcc withSubject:(NSString*)subject withBody:(NSString*)body {
	NSString * url = [NSString stringWithFormat:@"mailto:?to=%@&amp;cc=%@&amp;bcc=%@&amp;subject=%@&amp;body=%@",
					  [to stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [cc stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [bcc stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [subject stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
					  [body stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
 
	[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}</pre>
</div>
</div>
<p><strong>NOTE:</strong> Running this function in the iPhone Simulator  will have no effect because the simulator does not include the iPhone’s  Mail app. To see the effects of this function, it must be run on a  device.</p>
<h2>Example Usage</h2>
<p>Once you have that message defined in one of your classes, you can  open the Mail app with a pre-composed email with just one message call.  The following example opens an email and specifies a to, cc and bcc  address. It populates the subject with “Addicus” and populates the body  with a short message about Addicus that includes a link and an image  (which is also a link). As you can see, this is done with good old HTML  tags. This results in the email in the above screenshot.</p>
<div>
<div>
<pre>[self sendEmailTo:@"mom@example.com"
           withCC:@"dad@example.com"
          withBCC:@"asecretfriend@example.com"
      withSubject:@"Addicus"
         withBody:@"&lt;p&gt;Check out this game, &lt;a href='http://addicusgame.com'&gt;Addicus&lt;/a&gt;, for the iPhone and iPod Touch. It's super-addictive!&lt;/p&gt;&lt;p&gt;&lt;a href='http://addicusgame.com'&gt;&lt;img src='http://getsetgames.com/wp-content/uploads/2009/11/icon_addicus.png'/&gt;&lt;/a&gt;&lt;/p&gt;"];</pre>
</div>
</div>
<p>If you would like to have the user specify the to, cc and bcc  addresses themselves, as you would in the case of a tell-a-friend  button, then you would call the following message:</p>
<div>
<div>
<pre>[self sendEmailTo:@""
           withCC:@""
          withBCC:@""
      withSubject:@"Addicus"
         withBody:@"&lt;p&gt;Check out this game, &lt;a href='http://addicusgame.com'&gt;Addicus&lt;/a&gt;, for the iPhone and iPod Touch. It's super-addictive!&lt;/p&gt;&lt;p&gt;&lt;a href='http://addicusgame.com'&gt;&lt;img src='http://getsetgames.com/wp-content/uploads/2009/11/icon_addicus.png'/&gt;&lt;/a&gt;&lt;/p&gt;"];</pre>
</div>
</div>
<p>// &lt;![CDATA[//</p>
</div>
<h2 id="post-739"><a title="Permanent Link to Eliminating class dependencies  on your application delegate" rel="bookmark" href="http://getsetgames.com/2009/12/04/iphonedev-advent-tip-4-eliminating-class-dependencies-on-your-application-delegate/">Eliminating class dependencies on your  application delegate</a></h2>
<p>Ever have the need to call a method inside your app delegate from  an arbitrary place in your code?  We’ve had to deal with this issue in a  few cases working on our <a href="http://getsetgames.com/2009/11/27/next-game-from-get-se/">new  project</a>.  We’re making use of a <em>UIScrollView</em> instance to  give us that popular flick scroll movement that is so popular on the  iPhone.  We’ve found that alot of people have been interested in doing  the same thing and you can read our blog on <a href="http://getsetgames.com/2009/08/21/cocos2d-and-uiscrollview/">that  particular challenge here</a>.  We have a <em>UIScrollView</em> instance  sitting inside our app delegate and there are certain parts of our code  where we need to move that <em>UIScrollView</em> among different layers  in Cocos 2D.  To do that we need access to the scroll view instance  itself.  That results in code like the following…</p>
<div>
<div>
<pre>myAppDelegate *app = [[UIApplication sharedApplication] delegate];
UIScrollView *appOverlayScrollView  = (UIScrollView *)app.view;
[[app window] sendSubviewToBack:appOverlayScrollView];</pre>
</div>
</div>
<p>This creates a messy dependency between an arbitrary class and the  app delegate class.  Wouldn’t it be great if we could send a message to  the app delegate and tell it to move the scroll view to the front or  back maintaining encapsulation?  Turns out you can indeed do this.  The <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html"><em>UIApplication</em></a> class contains a method called <a href="http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/sendAction:to:from:forEvent:"><em>sendAction</em></a> which is normally used to send an action message identified by a  selector to a specified target.  This method can easily be used to call  selectors in any object so the above code can be converted to…</p>
<div>
<div>
<pre>[[UIApplication sharedApplication]
sendAction:@selector(bringScrollViewToFront)
to:[[UIApplication sharedApplication] delegate]
from:self
forEvent:nil];</pre>
</div>
</div>
<p>The only downside to this approach is that I haven’t found a way to  supply arguments along with the selector so you need to be calling a  method with no arguments.  If you know of a way around this issue please  do let me know.</p>
<h2 id="post-650"><a title="Permanent Link to How to Open a URL in Safari" rel="bookmark" href="http://getsetgames.com/2009/12/01/iphonedev-advent-tip-1-how-to-open-a-url-in-safari/">How  to Open a URL in Safari</a></h2>
<p><a href="http://getsetgames.com/wp-content/uploads/2009/12/1.png"><img title="1" src="http://getsetgames.com/wp-content/uploads/2009/12/1-156x300.png" alt="1" width="156" height="300" /></a>Tis the season to broaden your iPhone dev  chops! We have been developing on the iPhone platform for about 6 months  now and it turns out that in that time, you tend to learn lots of  little tips and tricks. Since we’re overcome by the spirit of giving  around this time of year, we are going to be posting 24 of these  bite-sized iPhone development tips, 1 every day between now and  Christmas day. Consider it an advent calendar of iPhone dev tip goodies.</p>
<h2>On With The First Tip!</h2>
<p>Say you would like to open a URL in Safari. We used this on the “Get  Set” button on the main menu of <a href="http://getsetgames.com/games/addicus/">Addicus</a>. Here is how to  do it with just one line of code using the UIApplication class:</p>
<div>
<div>
<pre>[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://getsetgames.com/"]];</pre>
</div>
</div>
</pre>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/296/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/296/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/296/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=296&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/07/12/uiapplication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>

		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/messages.png" medium="image">
			<media:title type="html">messages</media:title>
		</media:content>

		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/put-the-iphone-to-sleep.jpeg" medium="image">
			<media:title type="html">put-the-iphone-to-sleep</media:title>
		</media:content>

		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/Screen-shot-2009-12-16-at-10.14.26-PM.png" medium="image">
			<media:title type="html">Screen shot  2009-12-16 at 10.14.26 PM</media:title>
		</media:content>

		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/photo-4-200x300.jpg" medium="image">
			<media:title type="html">photo-4</media:title>
		</media:content>

		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/uistatusbarhidden2.png" medium="image">
			<media:title type="html">uistatusbarhidden2</media:title>
		</media:content>

		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/photo-2-1-200x300.jpg" medium="image">
			<media:title type="html">photo 2-1</media:title>
		</media:content>

		<media:content url="http://getsetgames.com/wp-content/uploads/2009/12/1-156x300.png" medium="image">
			<media:title type="html">1</media:title>
		</media:content>
	</item>
		<item>
		<title>Objective-C Tutorial</title>
		<link>http://zaldzbugz.wordpress.com/2010/07/12/objective-c-tutorial/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/07/12/objective-c-tutorial/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 03:51:12 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[Objective-C]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=293</guid>
		<description><![CDATA[Objective-C is a programming language used in iPhone app development. You will be spending 90% of your time working with this language for most programming tasks that you will encounter as you work through app development. This tutorial is meant as a guide for programmers who want to get started fast on the language. If <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=293&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Objective-C is a programming language used in iPhone app development.   You will be spending 90% of your time working with this language for  most programming tasks that you will encounter as you work through app  development.  This tutorial is meant as a guide for programmers who want  to get started fast on the language.  If you need to know more about  what tools and so on that you will need for iPhone development in  general see our <a title="iPhone Programming Tutorial" href="http://mobileappmastery.com/iphone-programming-tutorial/">tutorial  on iPhone programming</a>.</p>
<h1>Objective-C Objects</h1>
<p>Objective-C is an object oriented programming language and you will  be spending most of your time creating and working with objects.  To  define an object to work with you simply write out the name of the class  and a name that will serve as the local pointer to the object:</p>
<pre>	NSNumber *numberObject;</pre>
<p>NSNumber is a commonly used class in Objective-C and here our object  is named numberObject.  The asterisk is used to indicate that the object  name is a pointer.</p>
<h1>Messaging Objects</h1>
<p>When you need an object to do something in Objective-C you must send  it a message.  In other programming languages you may be used to  “calling methods” with syntax that looks something like this:</p>
<pre>	alert.show();</pre>
<p>Objective-C handles this task a little bit differently by using this  idea of messages and we will refer to this process as sending a message  instead of calling a method.  To demonstrate this syntax let’s stick  with the example of an alert that we started with above.  To give some  context, an alert is a common user interface element that pops up with a  message for a user to read.  In programming languages like dot net or  Java you will probably call a method like “show” to invoke the behavior  of alert that shows the message.  To do the same thing with this object  in Objective-C you would write this:</p>
<pre>	[alert show];</pre>
<p>The first thing you will notice is that the object and method are  surround by square brackets.  This is the trademark Objective-C syntax  that people always notice and are sometimes vexed by.  Secondly, check  out how the method name is separated from the object here.  In this  context, we would refer to this statement as sending the “show” message  to the “alert” object.</p>
<h1>Messaging with Parameters</h1>
<p>Often you will need to send a message that includes one or more  parameters.  In other programming languages this could look something  like this:</p>
<pre>	alert.show("A Funny Message");
	alert.show("A Funny Message", 3);</pre>
<p>In Objective-C we can do a similar thing, but we also get to include  descriptive prefixes (specified in the class definition) to help us with  code documentation.  For example, here is how we would send messages  like the ones above:</p>
<pre>	[alert show:@"I say this!"];
	[alert show:@"I say this!" thisManyTimes:3];</pre>
<p>As you can see the syntax is a bit different and you get a little bit  more information.  This appears wordy and confusing to many new  Objective-C programmers, but you will get used to this soon enough (I  mean it!).</p>
<h1>Instantiating Objects in Objective-C</h1>
<p>Before you work with an object in Objective-C you will need to create  an local instance of the object.  This process is called instantiating  and when you are using Objective-C on the iPhone you will need to  allocate memory as well as create an object.  To allocate memory you  send a alloc message to the class itself (you can send messages to both  objects and classes).  To create the object itself, you will use a  constructor that is generally prefixed with the word “init” or simply  init.</p>
<p>Here is how you instantiate an object (from now on I will be using  generalized descriptive words for the various components in the  examples):</p>
<pre>	myClass *myObject = [[myClass alloc] init];</pre>
<h1>Releasing Objects</h1>
<p>When using Objective-C on the iPhone you must release objects that  you have created using alloc, new or copy.  This has to do with memory  management which will be discussed in the next section.  To release an  object you simply send the “release” message to the object.</p>
<pre>	[myObject release];</pre>
<p>Here is the pattern that you will typically follow when using objects  in Objective-C:</p>
<pre>	//allocate memory and create object
	myClass *myObject = [[myClass alloc] init];
	//Use object
	[myObject doStuff];
	//Release object
	[myObject release];</pre>
<h1>Memory Management and Reference Counting</h1>
<p>When you are working with Objective-C on the iPhone you need to  manage memory manually.  This is a very detailed and important topic and  if memory management is not done correctly then it could lead to memory  leaks or app crashes.  Managing iPhone memory is a simple system called  “reference counting”.</p>
<p>The idea is that the system will keep track of whether it needs to  keep the memory for an object available based on the number of other  components that indicate that they want the object to stick around.   Each component gets to indicate its interest in the object by adding a  reference (sometimes called retain) count to the object.  You may add to  an object’s reference count by sending the “retain” message to an  object.  So, if 5 components are interested in myObject then myObject  has a reference count of 5.  The system will keep your object’s memory  in place as long as the reference count is above 0.</p>
<p>As components no longer need an object to stick around they will  remove their interest in the object by sending a “release” message to  the object.  Each time a release message is sent to an object it’s  reference count goes down by 1.  Once the reference count reaches 0 the  system may destroy the object and re-use the memory at any time.</p>
<h1>Basic Memory Management Tips</h1>
<p>While reference counting is a simple system, it does require a lot of  attention to detail and being consistent in how you handle this is very  helpful.  The most important thing to remember to do is to release  every object that you create with the “alloc” keyword.  Every alloc must  be matched with a release.</p>
<p>The other thing you must do is to make sure to match every retain  message that you send to an object to a release message.  Once you are  finished with an object be sure that the reference count is 0.  If you  do this then you can be assured that you will not be wasting memory.</p>
<p>Do not send messages to objects that have been completely released  and have a retain count of 0.  If you do this your app will crash; this  is the most common and vexing problems in app development.</p>
<p>Here is an example of a typical life cycle of an object and it’s  reference count during each step:</p>
<pre>	myClass *myObject = [[myClass alloc] init];
	//Reference Count: 1

	[myObject retain];
	//Reference Count: 2

	[myObject retain];
	//Reference Count: 3

	[myObject release];
	//Reference Count: 2

	[myObject release];
	//Reference Count: 1

	[myObject release];
	//Reference Count: 0</pre>
<p>Once myObject reaches a reference count of 0 at the end the system  will destroy the object and if you attempt to send a message to myObject  your app will crash.  Notice how each alloc and retain is matched to a  release.  If you do not match alloc, new and retain messages with  corresponding release messages you will either leak or crash your app.</p>
<h1>Strings with NSString</h1>
<p>Let’s move on to some classes and objects that are used frequently in  Objective-C.  Many of these come from Foundation which provides  foundational programming functionality (sort of like it sounds).  Check  out the header files that come with XCode to see everything you can do  with Objective-C.  It provides a pretty rich framework.</p>
<p>Moving on to strings: in Objective-C the class you use to work with  string is called NSString and it is used like other objects:</p>
<pre>	NSString *myString = [[NSString alloc] initWithString:@"A String"];
	NSLog(myString);
	[myString release];</pre>
<p>NOTE: Above we use NSLog to write messages out to the console.  Here  we simply create an instance of NSString using the typical pattern  describe above (alloc, init &amp; release).  However, NSString comes  with additional functions that do not require you to use alloc or a  release message.  The same thing could be accomplished with this:</p>
<pre>	NSString *myString = @"A String";
	NSLog(myString);</pre>
<p>NSString also has functions that will help you compose new strings by  gluing other strings, numbers and objects together using the  stringWithFormat function:</p>
<pre>	NSString *lotsOfInsertedStuffString = [NSString stringWithFormat:@"I am adding this number: %i and this string:%@.", 45, myString];
	NSLog(lotsOfInsertedStuffString);</pre>
<p>NSString comes with a rich feature set so be sure to look up the  functions available to you in the header files.</p>
<h1>Counting and Numbers in Objective-C</h1>
<p>For the most part you may as well stick to using regular C style  integers and doubles when doing math.  Objective-C and C and often used  together and working with numbers using int and double is much easier  when doing math.  You can use the Objective-C class NSNumber however  when you need to style numbers in a particular way.  You will also be  using the C style for typical programming activities such as: looping,  if-then logic, case statements, structs and functions.</p>
<p>C Refresher for Integers and Doubles:</p>
<pre>	int i = 3;
	NSLog(@"i = %i", i);
	double d = 3.4;
	NSLog(@"d = %f", d);
	double dPlusi = d + i;
	NSLog(@"d + i = %f", dPlusi);</pre>
<h1>Objective-C Arrays with NSMutableArray</h1>
<p>Before we end let’s take a look at how to use the object oriented  arrays that you have available from Foundation.  Arrays are simply lists  of objects and in Objective-C you can put anything into array and you  can even mix and match objects.  Here is how you generally use an array:</p>
<pre>	//Instantiate an array
	NSMutableArray *myArray = [[NSMutableArray alloc] init];

	//Add elements to an array
	[myArray addObject:@"Element 1"];
	[myArray addObject:@"Element 2"];
	[myArray addObject:@"Element 3"]; 

	//Retrieve an object from an array
	NSLog([myArray objectAtIndex:0]); 

	//Retrieve the last object in an array
	NSLog([myArray lastObject]);</pre>
<p>One powerful reason to use arrays is that you can leverage the  for-each loop which is a way of repeating the same action on every  object in the array:</p>
<pre>	for (NSString *s in myArray) {
		NSLog(s);
	}</pre>
<p>Of course, you must release the array object when you are finished  (sorry for beating it in like this but it’s important!)</p>
<pre>	[myArray release];</pre>
<h1>That’s a Wrap!</h1>
<p>That should be enough to get you started in your Objective-C  programming career.  There are many more advanced features to the  language that you will eventually want to take on once you have a bit  more practice.  But, this will give you enough to get started with  iPhone development since you will be using Objective-C with the  Cocoa-Touch frameworks used to make most iPhone apps.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/293/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/293/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/293/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=293&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/07/12/objective-c-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>Working with dates in PHP and MYSQL</title>
		<link>http://zaldzbugz.wordpress.com/2010/06/30/working-with-dates-in-php-and-mysql/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/06/30/working-with-dates-in-php-and-mysql/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 06:56:17 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=288</guid>
		<description><![CDATA[For a more easier and efficient way of manipulating dates in PHP and MYSQL. In your database, make sure that data you need to save your date is of datatype integer then in PHP.. Use mktime()&#8230;This outputs an integer and you can use it to return actual date by date(&#8220;l&#8221;, [value of mktime]). $tstamp = <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=288&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For a more easier and efficient way of manipulating dates in PHP and MYSQL.</p>
<p>In your database, make sure that data you need to save your date is of datatype integer then in PHP..</p>
<p>Use mktime()&#8230;This outputs an integer and you can use it to return actual date by date(&#8220;l&#8221;, [value of mktime]).</p>
<p><strong>$tstamp = mktime(10, 11, 0, 8, 23, 2005);</strong></p>
<p><strong>$myDate = (</strong><code>"l", $tstamp</code><strong>); </strong><code>// Prints: August 23, 2005 is on a Saturday</code></p>
<p>Enjoy:)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/288/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/288/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/288/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=288&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/06/30/working-with-dates-in-php-and-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>Catching links inside UIWebView</title>
		<link>http://zaldzbugz.wordpress.com/2010/06/24/catching-links-inside-uiwebview/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/06/24/catching-links-inside-uiwebview/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 07:14:16 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[UIWebview tips]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=285</guid>
		<description><![CDATA[This aims to help you how to catch links (href) for example inside your UIWebView and do something first or after then request a URL to load. First you need to include the UIWebView delegate (UIWebViewDelegate) in order to use the method below: - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { //do something here if(([[[request URL] <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=285&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This aims to help you how to catch links (href) for example inside your UIWebView and do something first or after then request a URL to load.</p>
<p>First you need to include the UIWebView delegate (UIWebViewDelegate) in order to use the method below:</p>
<blockquote>
<pre>- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request
navigationType:(UIWebViewNavigationType)navigationType {
    //do something here

if(([[[request URL] absoluteString] isEqual:@"http://zaldzbugz.wordpress.com/postgre-sql/"])) {

return NO;

} else {

return YES;

}

}
</pre>
</blockquote>
<p>The code above explains that once you click an &lt;a&gt; element with HREF where the link assigned to is equal to http://zaldzbugz.wordpress.com/postgre-sql/. Then we don&#8217;t load the page (return NO), and you could also add other functions inside that condition.</p>
<p>There you catched it. Enjoy <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/285/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/285/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/285/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=285&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/06/24/catching-links-inside-uiwebview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>Tips on using UIWebview</title>
		<link>http://zaldzbugz.wordpress.com/2010/06/16/tips-on-using-uiwebview/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/06/16/tips-on-using-uiwebview/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 09:05:44 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[UIWebview tips]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=280</guid>
		<description><![CDATA[Loading the SVG file from your resources folder This one is quite straightforward. You need to get the correct path for your resources folder and the SVG file in that folder, which can be easily accomplished using the below snippet: NSString * filePath = [ [ NSBundle mainBundle] pathForResource: @ "filenameWithoutExtension" ofType: @ "svg" ; <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=280&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>Loading the SVG file from your resources folder</h1>
<p>This one  is quite straightforward. You need to get the correct path for your  resources folder and the SVG file in that folder, which can be easily  accomplished using the below snippet:</p>
<pre>NSString
 *
filePath =
 [
[
NSBundle
 mainBundle]

        pathForResource:
@
"filenameWithoutExtension"
 ofType:
@
"svg"
;
NSData
 *
svgData =
 [
NSData
 dataWithContentsOfFile:
filePath]
;</pre>
<p>I also wanted to reference the javascript I used in the  SVG file, instead of inline embedding. So I made sure that I set the  baseURL correctly for the UIWebView to resolve the path to the  javascript file in my resources directory:</p>
<pre>NSString
 *
resourcePath =
 [
[
NSBundle
 mainBundle]
 resourcePath]
;
NSURL
 *
baseURL =
 [
[
NSURL
 alloc]
 initFileURLWithPath:
resourcePath isDirectory:
YES
]
;

[
self.webView    loadData:
svgData
        MIMEType:
@
"image/svg+xml"

        textEncodingName:
@
"UTF-8"

        baseURL:
baseURL]
;
[
baseURL release]
;</pre>
<p>However to my surprise the above did not work for  locating my script file in the SVG referenced as below:</p>
<pre>&lt;script type="text/ecmascript" src="foo.js"/&gt;</pre>
<p>Well it turns out the src attribute is not actually in  the  <a rel="external nofollow" href="http://www.w3.org/TR/SVG11/script.html">SVG 1.1 specification</a> at all??  The way I solved that problem is to write a build script to embed the  script inline to the svg file (ie a preprocessing step) and make it part  of the build process. (More on that in a later post &#8230;)</p>
<h1>UIWebView loading contents when it is off-screen</h1>
<p>Another  surprise was trying to be able to load the SVG file when the UIWebView  was off-screen. My design hosted the UIWebView inside a UIScrollView and  I was loading the current page and caching the next and previous pages  to have a smooth transition as I swipe the scrollview. But it turns out  UIWebView has an issue with loading when it is off-screen. Ie it does  not render its contents, when it comes back into screen unless you  double tap into it. It sounds more like a bug to me.</p>
<p>To solve  this problem, I delayed the actual loading of the SVG file till:</p>
<pre>-
 (
void
)
scrollViewDidEndDecelerating:
(
UIScrollView *
)
scrollView</pre>
<p>for the current view that is becoming visible and I also  made sure that once it is loaded when the UIWebView is visible, I don&#8217;t  ask it to reload it every time the user swipes the view to left and  right.</p>
<h1>Calling a javascript function from Objective-C</h1>
<p>Part of my application is implemented in Javascript and using the DOM  to manipulate the SVG document. I need to be able to call some of my  Javascript functions from my Objective-C code. This is fairly  straightforward and well documented in the UIWebView reference  documentation in the SDK. All you need to do is to create an NSString  which contains the Javascript function call, and ask the UIWebView to  execute it as shown below:</p>
<pre>NSString
 *
jsCommand =
 [
NSString
 stringWithFormat:
@
"setActiveColor(%d, %d, %d);"
,
        redColor, greenColor, blueColor]
;
[
self.webView stringByEvaluatingJavaScriptFromString:
jsCommand]
;</pre>
<h1>Javascript communicating back with Objective-C code</h1>
<p>What happens when you need to call back your Objective-C code from  Javascript? Unfortunately at the time of this writing, there is no  proper API for this for the IPhone. (See  <a rel="external nofollow" href="http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html">Apple Documentation</a> for how to  do it in MacOS X using WebKit) Fortunately there is a hack, a lot of   <a rel="external nofollow" href="http://phonegap.com/">projects</a> have been using. It basically involves communication through a custom  protocol that you make up to pass some parameters and then parsing those  parameters in your Objective C code to call your corresponding  Objective-C methods.</p>
<p>Basically you create a protocol like  below:</p>
<pre>myapp:
myfunction:
myparam1:
myparam2</pre>
<p>And then in Javascript:</p>
<pre>document.location
 =
 "myapp:"
 +
 "myfunction:"
 +
 param1 +
 ":"
 +
 param2;</pre>
<p>Then back in your Objective-C code:</p>
<pre>-
 (
BOOL
)
webView:
(
UIWebView *
)
webView2
        shouldStartLoadWithRequest:
(
NSURLRequest
 *
)
request
        navigationType:
(
UIWebViewNavigationType)
navigationType {

        NSString
 *
requestString =
 [
[
request URL]
 absoluteString]
;
        NSArray
 *
components =
 [
requestString componentsSeparatedByString:
@
":"
]
;

        if
 (
[
components count]
 &gt; 1
 &amp;&amp;

                [
(
NSString
 *
)
[
components objectAtIndex:
0
]
 isEqualToString:
@
"myapp"
]
)
 {

                if
(
[
(
NSString
 *
)
[
components objectAtIndex:
1
]
 isEqualToString:
@
"myfunction"
]
)

                {

                        NSLog(
[
components objectAtIndex:
2
]
)
; // param1

                        NSLog(
[
components objectAtIndex:
3
]
)
; // param2

                        // Call your method in Objective-C method using the above...

                }

                return
 NO
;
        }

        return
 YES
; // Return YES to make sure regular navigation works as expected.

}</pre>
<p>Hacky: yes. Gets the job done: yes</p>
<h1>Disabling the selection flash</h1>
<p>Once you do the above steps, you  are basically mostly on your way to have a functioning application that  makes use of UIWebView as a component. But as any good IPhone  application, you need to add more polish and get rid of the user  annoyances.</p>
<p>The first annoyance is, what happens when you tap  inside the UIWebView control that is hosting an SVG file. There is a  default behavior that happens for all image files, including SVG files.  The background of the image (including the border area) flashes quickly  to some default grayish color.</p>
<p>Turns out there is a way to turn  this off through the use of the WebKit CSS  property-webkit-tap-highlight-color, and setting the alpha of the color  to 0, in my Javascript code does the trick:</p>
<pre>document.documentElement
.style
.webkitTapHighlightColor
 =
 "rgba(0,0,0,0)"
;</pre>
<h1>Disabling the &#8220;action&#8221; pop-up</h1>
<p>The second thing  I needed to disable is the &#8220;action&#8221; popup that appears if you tap and  hold the contents of the UIWebView for a few seconds. This is also  controlled through a CSS property called-webkit-touch-callout, and  setting that to &#8220;none&#8221; in this case does the trick:</p>
<pre>document.documentElement
.style
.webkitTouchCallout
 =
 "none"
;</pre>
<h1>Disabling default zoom effect</h1>
<p>The final user  annoyance I had was the zooming effect that happens by default, when you  double tap the content area. Well for many applications this may be a  desired effect, but in my case, I needed to disable the zooming. I was  hoping that there is another CSS property that is something like  webkit-disable-doubletap-zoom but unfortunately no such property exists  (at least as of this writing.)</p>
<p>The only other idea I came up  with was to be able to detect double tapping and calling the standard  preventDefault on the event when that touch happens in my Javascript  code. But it turns out that SVG DOM does not at the moment fully  implement the  <a rel="external nofollow" href="http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/">touch and gesture events</a> . You  should be able to use those when you are hosting regular HTML though.</p>
<p>The final approach I came up with was to be able to intercept the touch  events before they even reach UIWebView and stop them in my Objective-C  code. To do this, you need to read a bit more about how the  <a rel="external nofollow" href="http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/chapter_5_section_3.html">touch events are routed in Cocoa</a> . (Requires login to the IPhone Dev Center) Basically the idea is to  override the hit testing part of the UIWebView and detect the double tap  there. In order to that I subclassed UIWebView and overrode the hitTest  method in my implementation. Other than that I keep it up the  superclass to do the rest.</p>
<pre>-
(
UIView *
)
hitTest:
(
CGPoint)
point withEvent:
(
UIEvent *
)
event {

        NSSet
 *
touches =
 [
event allTouches]
;
        BOOL
 forwardToSuper =
 YES
;
        for
 (
UITouch *
touch in
 touches)
 {

                if
 (
[
touch tapCount]
 &gt;=
 2
)
 {

                        // prevent this 

                        forwardToSuper =
 NO
;
                }

        }

        if
 (
forwardToSuper)
{

                //return self.superview;

                return
 [
super hitTest:
point withEvent:
event]
;
        }

        else
 {

                // Return the superview as the hit and prevent

                // UIWebView receiving double or more taps

                return
 self.superview;
        }

}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/280/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/280/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/280/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=280&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/06/16/tips-on-using-uiwebview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
		<item>
		<title>UITableViewCell &#8211; Customization</title>
		<link>http://zaldzbugz.wordpress.com/2010/06/11/uitableviewcell-customization/</link>
		<comments>http://zaldzbugz.wordpress.com/2010/06/11/uitableviewcell-customization/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 08:50:08 +0000</pubDate>
		<dc:creator>zaldzbugz</dc:creator>
				<category><![CDATA[UITableViewCell - Customization]]></category>

		<guid isPermaLink="false">http://zaldzbugz.wordpress.com/?p=258</guid>
		<description><![CDATA[This is how you call your UITablewVieCell class inside your - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath. (Considering that you were using a NIB &#8211; viewbased). static NSString *CellIdentifier = @"Cell" CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) NSArray *cellObject =[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:nil  options:nil]; for(id currentCell in cellObject) { if([currentCell isKindOfClass:[UITableViewCell class]]) <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=258&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is how you call your UITablewVieCell class inside your <em>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath. (Considering that you were using a NIB &#8211; viewbased).<br />
</em></p>
<blockquote>
<pre>static NSString *CellIdentifier = @"Cell"

CustomCell *cell = (CustomCell  *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)
NSArray *cellObject =[[NSBundle mainBundle]  loadNibNamed:@"CustomCell" owner:nil  options:nil];

for(id currentCell in cellObject) {
if([currentCell isKindOfClass:[UITableViewCell class]]) {

cell = (CustomCell*)currentCell;
cell.memberVariable.text = @"text";
break;

}
}
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;</pre>
</blockquote>
<p>Enjoy. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/zaldzbugz.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/zaldzbugz.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/zaldzbugz.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/zaldzbugz.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/zaldzbugz.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/zaldzbugz.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/zaldzbugz.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/zaldzbugz.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/zaldzbugz.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/zaldzbugz.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/zaldzbugz.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/zaldzbugz.wordpress.com/258/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/zaldzbugz.wordpress.com/258/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/zaldzbugz.wordpress.com/258/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=zaldzbugz.wordpress.com&amp;blog=6289619&amp;post=258&amp;subd=zaldzbugz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://zaldzbugz.wordpress.com/2010/06/11/uitableviewcell-customization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c28010c5341dbc3be53d3309ce7fa16f?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">zaldzbugz</media:title>
		</media:content>
	</item>
	</channel>
</rss>
