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

<channel>
	<title>Hello World!!&#187; objective-c tips</title>
	<atom:link href="http://bhags.org/?feed=rss2&#038;tag=objective-c-tips" rel="self" type="application/rss+xml" />
	<link>http://bhags.org</link>
	<description>Welcome to Sinyu&#039;s  site</description>
	<lastBuildDate>Mon, 06 Nov 2017 04:17:27 +0000</lastBuildDate>
	<language>ja</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8.1</generator>
	<item>
		<title>iOS Tips for beginner</title>
		<link>http://bhags.org/?p=133</link>
		<comments>http://bhags.org/?p=133#comments</comments>
		<pubDate>Tue, 16 Jul 2013 11:08:45 +0000</pubDate>
		<dc:creator><![CDATA[bhags]]></dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-c]]></category>
		<category><![CDATA[objective-c tips]]></category>

		<guid isPermaLink="false">http://bhags.org/?p=133</guid>
		<description><![CDATA[ネットサーフィングしながらかき集めたTIPS. いつか誰かの役に立つはず。（自分含む） Open a[...]]]></description>
				<content:encoded><![CDATA[<p>ネットサーフィングしながらかき集めたTIPS.<br />
いつか誰かの役に立つはず。（自分含む）</p>
<ol>
<li>Open an URL in Safari</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@&quot;http://www.google.com/&quot;]];
</pre>
<li>Hide the status bar</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
</pre>
<li>Dial a Phone Number (iPhone Only)</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@&quot;tel://9662256888&quot;]];
</pre>
<li>Launch the Apple Mail</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@&quot;mailto://mymail@myserver.com&quot;]];
</pre>
<li>stop responding to touch events</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
</pre>
<li>active the touch events</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
</pre>
<li>Show the network Activity Indicator</li>
<pre class="brush: php; title: ; notranslate">
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
</pre>
<li>Hide the network Activity Indicator</li>
<pre class="brush: php; title: ; notranslate">
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
</pre>
<li>Prevents iPhone goes into sleep mode</li>
<pre class="brush: php; title: ; notranslate">
[UIApplication sharedApplication].idleTimerDisabled = YES;
[UIApplication sharedApplication].applicationIconBadgeNumber = 10;
</pre>
<li>Display an alert window</li>
<pre class="brush: php; title: ; notranslate">
UIAlertView* alert = [[[UIAlertView alloc] initWithTitle:@&quot;Warning&quot; message:@&quot;too many alerts&quot; delegate:nil cancelButtonTitle:@&quot;OK&quot; otherButtonTitles:nil] autorelease];
[alert show]
</pre>
<li>Get the path to the Documents folder</li>
<pre class="brush: php; title: ; notranslate">
NSArray*  paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString* documentsDirectory = [paths objectAtIndex:0];
</pre>
<li>Push another view controller onto the Navigation Bar</li>
<pre class="brush: php; title: ; notranslate">
[self.navigationController pushViewController:anotherVC animated:YES];
</pre>
<li>Fade away a UIView by animating the alpha down to 0</li>
<pre class="brush: php; title: ; notranslate">
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];  // fade away over 1 seconds
[aView setAlpha:0]; 
[UIView commitAnimations];
</pre>
<li>Get the name of the app</li>
<pre class="brush: php; title: ; notranslate">
self.title = [[[NSBundle mainBundle] infoDictionary] objectForKey:@&quot;CFBundleName&quot;];
</pre>
<li>Change the status bar to black</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
Change the style of the navigation bar (from in a view controller):
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
</pre>
<li>Save a NSString into NSUserDefaults</li>
<pre class="brush: php; title: ; notranslate">
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:loginName forKey:kUserLoginName];
Get an NSString from NSUserDefaults:
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
NSString* loginName = [defaults stringForKey:kUserLoginName];
</pre>
<li>Check to make sure an objects support a method before calling it</li>
<pre class="brush: php; title: ; notranslate">
if ([item respondsToSelector:@selector(activateBOP:)]) {
    [item activateBOP:closeBOP];
}
</pre>
<li>Log the name of the class and function</li>
<pre class="brush: php; title: ; notranslate">
NSLog(@&quot;%s&quot;, __PRETTY_FUNCTION__);
Add rounded corners and/or a border around any UIView item (self)
self.layer.borderColor  = [UIColor whiteColor].
self.layer.cornerRadius = 8;     // rounded corners
self.layer.masksToBounds = YES;  // prevent drawing outside border
</pre>
<li>Open Google Maps app with directions between two lat/long points</li>
<pre class="brush: php; title: ; notranslate">
NSString *urlString = [NSString stringWithFormat:@&quot;http://maps.google.com/maps?saddr=%f,%f&amp;daddr=%f,%f&amp;dirflg=d&quot;, start.latitude, start.longitude, finish.latitude, finish.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]]; 
</pre>
<li>Save bool to User Defaults</li>
<pre class="brush: php; title: ; notranslate">
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@&quot;Yes Bool&quot;];
</pre>
<li>Copy a file from x to y</li>
<pre class="brush: php; title: ; notranslate">
[[NSFileManager defaultManager] copyItemAtPath:x toPath:y error:nil];
1

&lt;li&gt;Display a new view&lt;/li&gt;
1
[self presentModalViewController:(UIViewController *) animated:YES];
</pre>
<li>Screen touches method</li>
<pre class="brush: php; title: ; notranslate">
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
</pre>
<li>Get documents directory</li>
<pre class="brush: php; title: ; notranslate">
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
</pre>
<li>Load URL</li>
<pre class="brush: php; title: ; notranslate">
[MyWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@&quot;http://couleeapps.hostei.com&quot;]]];  
</pre>
<li>Get Current Date and time</li>
<pre class="brush: php; title: ; notranslate">
NSCalendar *gregorian = [NSCalendar currentCalendar];
NSDateComponents *dateComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:[NSDate date]];
Own enum type:
typedef enum {
    a = 0, b = 1, c = 2
} enumName;
</pre>
<li>Quartz draw arc</li>
<pre class="brush: php; title: ; notranslate">
CGContextRef ctxt = UIGraphicsGetCurrentContext();
CGContextAddArc(ctxt, x, y, radius, startDeg, endDeg);
</pre>
<li>Make the device vibrate</li>
<pre class="brush: php; title: ; notranslate">
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
</pre>
<li>Open the Messages app with a specific phone number</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@&quot;sms:123456789&quot;]];
</pre>
<li>Stop responding to touch events</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
</pre>
<li>Start responding again</li>
<pre class="brush: php; title: ; notranslate">
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
</pre>
<li>single line of code browser</li>
<pre class="brush: php; title: ; notranslate">
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString: [urlText stringValue]]]];
</pre>
<li>Change the title on the back button on a UINavigationView. Use this code on the UINavigationController before pushing the view</li>
<pre class="brush: php; title: ; notranslate">
UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@&quot;Back&quot; style: UIBarButtonItemStyleBordered target:nil action:nil];
self.navigationItem.backBarButtonItem = backBarButtonItem;
[backBarButtonItem release];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bhags.org/?feed=rss2&#038;p=133</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
