<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>alexbrie . com</title>
	
	<link>http://www.alexbrie.com</link>
	<description>Just another blog</description>
	<lastBuildDate>Sat, 04 Feb 2012 08:07:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/AlexbrieCom" /><feedburner:info uri="alexbriecom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Life without an iPhone</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/tRSve_k8tPA/</link>
		<comments>http://www.alexbrie.com/2012/02/life-without-an-iphone/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 08:07:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iDevBlogADay]]></category>
		<category><![CDATA[just posts]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=67</guid>
		<description><![CDATA[Like everyone else, when I saw the iPhone shown by Steve Jobs on stage back in January 2007, I realized it would change everything. I just had no idea how much it would change me &#8211; I&#8217;d earn my living creating apps for it, I&#8217;d surround myself with Apple-made gadgets and services and, most importantly, [...]]]></description>
			<content:encoded><![CDATA[<p>Like everyone else, when I saw the iPhone shown by Steve Jobs on stage back in January 2007, I realized it would change everything. I just had no idea how much it would change me &#8211; I&#8217;d earn my living creating apps for it, I&#8217;d surround myself with Apple-made gadgets and services and, most importantly, I&#8217;d never leave home without it.<br />
<span id="more-67"></span><br />
My brand new iPhone 4S (white, 16GB) started giving me problems about three weeks ago. It would randomly disconnect from the cellular network and never connect again, with network status ranging from &#8220;Searching..&#8221; to &#8220;Invalid SIM&#8221; or even &#8220;No SIM&#8221;. The only solution was to manually reboot it by powering it off and on. At first this happened once a day or night, so the first thing I&#8217;d do each morning was to check out if I was still reachable. Then it increased to twice a day and, eventually, it would stay more in the disconnected state than in the reachable one. It was still working as a Wifi-connected device but, when I wanted to give a phone call, I was forced to reboot the phone just to be able to see the network carrier. Also, no one could call me  (which wasn&#8217;t that bad, actually).</p>
<p>None of the solutions I found online worked. I tried placing some adhesive tape on parts of the microSIM in order to prevent an alleged shortcut (I can&#8217;t find the link that advised this), I also upgraded the iOS version to 5.0.1 9A406 instead of 5.0.1 9A405. The errors persisted. </p>
<p>The last solution was to go to the store. There is no Apple Store in Romania, so I had to take it down to Orange, the provider from where I had purchased it. Then the bad news struck: they would have to change the device and give me another one. That wouldn&#8217;t have been a bad news normally, but since they didn&#8217;t have it in their replacement stock, I had to leave my beautiful looking iPhone with them, get a temporary dumbphone instead for a few days and wait until a new iPhone shipment arrived. Apparently there were quite a lot of similar problems with the 4S that there was a waiting list,so leaving my device with them and waiting for the replacement shipment was the only way to go. And this might take up to 15 days.</p>
<p>I never realized how dependent I was of my iPhone, how addicted to its mobile internet browsing, my favorite games, the gestures, full screen keyboard or its UI, until I was forced, for the past week, to use a Sony Ericsson W302 instead. Phone calls are lousy, due to its meager speakers I can barely understand what the other person is saying; typing text messages on a physical numbers-only keyboard seemed like a punishment from hell. Internet connection doesn&#8217;t work (and I don&#8217;t have the will to make it work, as WAP-compatible websites are fewer and fewer). </p>
<p>Being forced to use a dumbphone made me appreciate just how much a smartphone has to offer. The always-reachable internet, the always-near entertainment, its ease of use and familiar interface &#8211; those are things you can&#8217;t just detox from. Not after almost 4 years of continuous iPhone interaction.</p>
<p>Is it a good thing? Is it bad? I only know that I am impatiently waiting for my i4S to come back from service. It can&#8217;t come soon enough.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2012/02/life-without-an-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2012/02/life-without-an-iphone/</feedburner:origLink></item>
		<item>
		<title>A few recipes about dates / using NSDate</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/FBwzpoba-5E/</link>
		<comments>http://www.alexbrie.com/2012/01/recipes-about-dates-nsdate/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 18:40:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=63</guid>
		<description><![CDATA[The app I&#8217;ve been working lately makes a bit more use of NSDate than my usual ones. I thought I&#8217;d share with the world a few pieces of code I&#8217;ve been using; How to test if two NSDate dates belong to the same day: I created a category on NSDate and added the following method [...]]]></description>
			<content:encoded><![CDATA[<p>The app I&#8217;ve been working lately makes a bit more use of NSDate than my usual ones. I thought I&#8217;d share with the world a few pieces of code I&#8217;ve been using;</p>
<h3>How to test if two NSDate dates belong to the same day:</h3>
<p>I created a category on NSDate and added the following method to it:</p>
<pre>-(BOOL)isSameDay:(NSDate *) otherDate
{
    unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit;
    NSDateComponents *comps_self = [[NSCalendar currentCalendar] components:unitFlags fromDate:self];
    NSDateComponents *comps_other = [[NSCalendar currentCalendar] components:unitFlags fromDate:otherDate];

    if ([comps_self day]==[comps_other day] &amp;&amp;
        [comps_self month]==[comps_other month] &amp;&amp;
        [comps_self year]==[comps_other year]) {
        return YES;
    }
    return NO;
}</pre>
<p>I can now call [mydate isSameDay:otherdate]</p>
<h3>Find out the first and last days in the month that contains a given date</h3>
<pre>-(void) updateMonthIntervalForDate:(NSDate*)date{
    unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit;
    NSDateComponents* dc = [[NSCalendar currentCalendar] components:unitFlags fromDate:date];
    dc.day=1;
    NSDate* startOfMonth = [[NSCalendar currentCalendar] dateFromComponents:dc];
    NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
    offsetComponents.month=1;
    NSDate* endOfMonth = [[NSCalendar currentCalendar] dateByAddingComponents:offsetComponents toDate:self.startVisibleDate options:0];
    // ... do whatever you want with startOfMonth and endOfMonth
}</pre>
<h3>Last but not the least, print out nicely Print out the full name of the month, or the abridged name</h3>
<p>First of all, create a NSDateFormatter; the docs says it&#8217;s not inexpensive, so if you need it several times, try and reuse it instead of recreating it over and over again.</p>
<pre>    dateFormatter = [[NSDateFormatter alloc] init];</pre>
<p>Next, decide the date format you want to output</p>
<h5>Abridged version (like 01 Jan)</h5>
<pre>    [dateFormatter setDateFormat:@"dd MMM"];</pre>
<h5>Full month name (January)</h5>
<pre>    [dateFormatter setDateFormat:@"MMMM"];</pre>
<p>Sure, this is in the docs as well, but I did quite a bit of searches to find out the part about MMMM for the full NSDate month name. So maybe it will help someone.</p>
<p>Once you have the date formatter ready, you can invoke it to get the nice string from your NSDate:</p>
<pre>     NSString* mystring = [[dateFormatter stringFromDate:crtEntry.date] uppercaseString];</pre>
<p>This was it. I wish you happy coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2012/01/recipes-about-dates-nsdate/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2012/01/recipes-about-dates-nsdate/</feedburner:origLink></item>
		<item>
		<title>.. And a New Year</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/9DEQZ8KQnJo/</link>
		<comments>http://www.alexbrie.com/2012/01/and-a-new-year/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 18:15:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=51</guid>
		<description><![CDATA[XMas is gone, New Year&#8217;s is gone, the holidays are over and I am back to work. Same old stuff. Like Dilbert says,  there shouldn&#8217;t be anything special about a  random point in the space-time continuum. But there is something special. Each new year is the perfect reminder that time flies and we should do [...]]]></description>
			<content:encoded><![CDATA[<p>XMas is gone, New Year&#8217;s is gone, the holidays are over and I am back to work. Same old stuff. Like Dilbert <a href="http://dilbert.com/strips/comic/2011-12-31/">says</a>,  there shouldn&#8217;t be anything special about a  random point in the space-time continuum.</p>
<p>But there is something special. Each new year is the perfect reminder that time flies and we should do something with our lives.. something more than merely living them. It&#8217;s also the perfect moment to look back, draw the line and have some accounting done &#8211; what we did this past year, how it fared compared to the previous ones and, most importantly, what we expect from the future.</p>
<p>For me, the past year was the year of Clean Writer. First Clean Writer for Mac, then <a href="http://www.cognitivebits.com/products/clean-writer-pro.html">Clean Writer Pro for Mac</a>, and at the last minute <a href="http://www.cognitivebits.com/products/clean-writer-ipad.html">Clean Writer for iPad</a> 2.0 . There were also major updates to Self Help Classics and Business Inspiration Classics, and a few other minor apps (like <a href="http://itunes.apple.com/us/app/sidetodo/id433878678?mt=12">SideTodo</a> for Mac and some simple iOS apps  that nobody cares about). I finally started my own company &#8211; <a href="http://www.cognitivebits.com/">Cognitive Bits</a>, lost months negotiating business contracts which failed at the last moment, lost some more months developing products that I <a href="http://www.alexbrie.com/2011/10/the-problem-with-ebook-apps/">couldn&#8217;t possibly sell</a>. I started a <a href="https://groups.google.com/group/indiedevro">google group</a> for Bucharest iOS &amp; Android devs and organized a few meetups, met some really nice iOS devs at the <a href="http://www.alexbrie.com/2011/11/what-i-learned-from-techtalk-2011-london/">London Tech Talk</a> and learned a few very important lessons that I will list below.</p>
<p><strong>1. If you like what you&#8217;re doing, keep doing it.</strong></p>
<p>I won&#8217;t go into much details here. Bottom line is, I love what I am doing as a job(working on my own apps and projects) and I hope I&#8217;ll be able to keep doing it. I don&#8217;t like working for clients, so I hope I won&#8217;t be forced to do it.</p>
<p><strong>2. Learn from the source.</strong></p>
<p>Stackoverflow is great, and so are developer forums around the web. But I should rely more on Apple&#8217;s docs, the WWDC videos and iOS development books. Don&#8217;t waste time learning from bad teachers when you have access to the best ones.</p>
<p><strong>3. Motivation comes from like-minded people</strong></p>
<p>Meeting other iOS devs from the UK or Bucharest and listening to their success stories was the most energizing thing that could have happened to me in the past year. I hope 2012 will harvest the results of this newly found motivation.</p>
<p><strong>4. Inspiration comes from non-like-minded people</strong></p>
<p>I think that good ideas come from the interaction of people with different interests (you know, Art vs Technology kind of stuff). Sure, some believe their ideas are golden &#8211; &#8220;<em>I have a great app idea, you implement it and we split the revenue</em>&#8220;; I learned to avoid them politely(as in &#8220;<em>sorry, I&#8217;m a bit swamped right now, maybe we&#8217;ll do this later</em>&#8220;). But overall, talking to others is a great thing and it gives you new insights and ideas. Use this.</p>
<p><strong>5. Last, but not least: Polish your app</strong></p>
<p>Great ideas with no polish have little chance of being successful. Great polish with no decent idea &#8230; that&#8217;s not great either. Bottom line: don&#8217;t throw away the effort you have put into developing your app, only because you didn&#8217;t take a bit more time to polish it. Yep, this comes from my own experience.</p>
<p>&nbsp;</p>
<p>I want the above five to be my guidelines for 2012, and I hope that these insights will help this year to be significantly more successful than the previous.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2012/01/and-a-new-year/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2012/01/and-a-new-year/</feedburner:origLink></item>
		<item>
		<title>Adjusting UITextView size on Keyboard show/hide events, for iOS5</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/LCYBxOMlp30/</link>
		<comments>http://www.alexbrie.com/2011/12/adjusting-uitextview-size-on-keyboard-showhide-events-for-ios5/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 10:52:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=48</guid>
		<description><![CDATA[The time has come to, once again, blog over here as part of #idevblogaday. Remember the project I was telling you last time? I can reveal it now, as it&#8217;s been on the AppStore for a while now &#8211; Clean Writer for iPad, 2.0, a fully recoded, feature rich redesigned version of my quite popular [...]]]></description>
			<content:encoded><![CDATA[<p>The time has come to, once again, blog over here as part of <a href="http://idevblogaday.com/calendar">#idevblogaday</a>.</p>
<p>Remember <a href="http://www.alexbrie.com/2011/12/uitextview-apple-quirks-and-cutting-ones-losses/">the project</a> I was telling you last time? I can reveal it now, as it&#8217;s been on the AppStore for a while now &#8211; <a href="http://itunes.apple.com/us/app/clean-writer/id383001862?mt=8">Clean Writer for iPad</a>, 2.0, a fully recoded, feature rich redesigned version of my quite popular iPad plain-text editor for writers.</p>
<p>One thing that plagued the previous version was how the keyboard would cover up the text entry textview. I had tried to fix it by automatically adjusting the text view size, but there were always problems.</p>
<p>I ended up with a fix based on a recipe from Pragmatic Programmer&#8217;s <a href="http://pragprog.com/book/sfipad/ipad-programming">iPad Programming</a> book.</p>
<p><span id="more-48"></span>The original recipe,  copy/pasted below, is:</p>
<p>1. In my view controller&#8217;s viewDidLoad method:</p>
<pre> - (void)viewDidLoad {</pre>
<pre>    [super viewDidLoad];</pre>
<pre>// Do any additional setup after loading the view, typically from a nib....<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">    </span></pre>
<pre>    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillAppear:)</pre>
<pre>                                                 name:UIKeyboardWillShowNotification object:self.view.window];</pre>
<pre>    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillDisappear:)</pre>
<pre>                                                 name:UIKeyboardWillHideNotification object:self.view.window];</pre>
<pre>}</pre>
<p>2. the keyboard notification handlers:</p>
<pre>-(void) matchAnimationTo:(NSDictionary *) userInfo {</pre>
<pre>    [UIView setAnimationDuration: [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];</pre>
<pre>    [UIView setAnimationCurve: [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];</pre>
<pre>}</pre>
<pre>-(CGFloat) keyboardEndingFrameHeight:(NSDictionary *) userInfo {</pre>
<pre>    CGRect keyboardEndingUncorrectedFrame =   [[ userInfo objectForKey:UIKeyboardFrameEndUserInfoKey ]  CGRectValue];</pre>
<pre>    CGRect keyboardEndingFrame =  [self.view convertRect:keyboardEndingUncorrectedFrame  fromView:nil];</pre>
<pre>    return keyboardEndingFrame.size.height;</pre>
<pre>}</pre>
<pre>-(CGRect) adjustFrameHeightBy:(CGFloat) change multipliedBy:(NSInteger) direction {</pre>
<pre>    CGRect r = CGRectMake(mainView.frame.origin.x, mainView.frame.origin.y, mainView.frame.size.width, mainView.frame.size.height + change * direction);</pre>
<pre>    return r;</pre>
<pre>}</pre>
<pre>-(void)keyboardWillAppear:(NSNotification *)notification {</pre>
<pre>    [UIView beginAnimations:nil context:NULL];</pre>
<pre>    [self matchAnimationTo:[notification userInfo]];</pre>
<pre>    mainView.frame =  [self adjustFrameHeightBy:[self keyboardEndingFrameHeight: [notification userInfo]] multipliedBy:-1];</pre>
<pre>    [UIView commitAnimations];</pre>
<pre>}</pre>
<pre>-(void)keyboardWillDisappear:(NSNotification *) notification {</pre>
<pre>        [UIView beginAnimations:nil context:NULL];</pre>
<pre>        [self matchAnimationTo:[notification userInfo]];</pre>
<pre>        mainView.frame = [self adjustFrameHeightBy:[self keyboardEndingFrameHeight: [notification userInfo]] multipliedBy:1];</pre>
<pre>        [UIView commitAnimations];</pre>
<pre>}</pre>
<p>Now, the problem with the above code(as I discovered) is that on iOS5, on the iPad, something else can happen other than the keyboard appearing or disappearing. You can now Split or Undock your keyboard. In this case, the keyboard will receive a <em>UIKeyboardWillHideNotification</em> but it won&#8217;t receive any <em>UIKeyboardWillShowNotification</em> one, receiving <em>UIKeyboardWillChangeFrameNotification</em> instead.</p>
<p>To sum up, in iOS5 you might get more <em>UIKeyboardWillHideNotification</em> than <em>UIKeyboardWillShowNotification</em>, so it will mess up the pairing described above, as we are only interested in the pairs of keyboardWillShow/keyboardWillHide events. Since I wanted my textview to adjust size only when the keyboard actually appeared and not when it docked/undocked, I added the following simple fix:</p>
<p>1. add a boolean flag to my controller:</p>
<pre> BOOL keyboard_needs_adjustment_status; // initialized to NO<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;"> </span></pre>
<p>2. change keyboardWillAppear and keyboardWillDisappear methods to to:</p>
<pre>-(void)keyboardWillAppear:(NSNotification *)notification {</pre>
<pre>    [UIView beginAnimations:nil context:NULL];</pre>
<pre>    [self matchAnimationTo:[notification userInfo]];</pre>
<pre>    mainView.frame =  [self adjustFrameHeightBy:[self keyboardEndingFrameHeight: [notification userInfo]] multipliedBy:-1];</pre>
<pre>    [UIView commitAnimations];</pre>
<pre>    keyboard_needs_adjustment_status = YES;</pre>
<pre>}</pre>
<pre>-(void)keyboardWillDisappear:(NSNotification *) notification {</pre>
<pre>    if (keyboard_needs_adjustment_status) {</pre>
<pre>        [UIView beginAnimations:nil context:NULL];</pre>
<pre>        [self matchAnimationTo:[notification userInfo]];</pre>
<pre>        mainView.frame = [self adjustFrameHeightBy:[self keyboardEndingFrameHeight: [notification userInfo]] multipliedBy:1];</pre>
<pre>        [UIView commitAnimations];</pre>
<pre>    }</pre>
<pre>    else{</pre>
<pre>        // if kb is undocked or split</pre>
<pre>    }</pre>
<pre>    keyboard_needs_adjustment_status = NO;</pre>
<pre>}<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;"> </span></pre>
<p>That was it. A quick bug fix that saved the day for my users. If you want to see it in action and get a great app also, <a href="http://itunes.apple.com/us/app/clean-writer/id383001862?mt=8">Clean Writer for iPad</a> is a great app with way more to offer, and is on sale in the Productivity category, only $0.99 <img src='http://www.alexbrie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Happy Holidays, everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2011/12/adjusting-uitextview-size-on-keyboard-showhide-events-for-ios5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2011/12/adjusting-uitextview-size-on-keyboard-showhide-events-for-ios5/</feedburner:origLink></item>
		<item>
		<title>UITextView, Apple quirks and cutting one’s losses</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/HUoCASUc_UQ/</link>
		<comments>http://www.alexbrie.com/2011/12/uitextview-apple-quirks-and-cutting-ones-losses/#comments</comments>
		<pubDate>Fri, 09 Dec 2011 15:12:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=46</guid>
		<description><![CDATA[I&#8217;m in the middle of a project which excites me a lot, especially because I want to have it finished in the next couple of days, so that with a bit of luck the app would go live to the appstore before December 22 (the dreaded date when iTunesConnect will shut down for an entire [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the middle of a project which excites me a lot, especially because I want to have it finished in the next couple of days, so that with a bit of luck the app would go live to the appstore before December 22 (the dreaded date when iTunesConnect will shut down for an entire week). I&#8217;ve only had 3.5 hours of sleep last night, and about 5 the night before.</p>
<p>One of the things I was doing at 5AM in the morning was trying to find <strong>the current point location of the cursor</strong> inside a <strong>UITextView</strong> (iOS 4.3+ or even 5.0 &#8211; whichever works).</p>
<p>I couldn&#8217;t.</p>
<p>Now, it&#8217;s not unusual to not be able to do things in iOS. What is unusual is that Apple&#8217;s docs said I should have been able to.</p>
<p>Let me explain. See, UITextView, <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextView_Class/Reference/UITextView.html">according to the documentation</a>, conforms to UITextInput protocol. UITextInput protocol, according to the documentation, has a <strong>required</strong> property <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UITextInput_Protocol/Reference/Reference.html#//apple_ref/occ/intfp/UITextInput/selectedTextRange">selectedTextRange</a> that gives &#8220;the range of the selected text in a document&#8221; and, in particular, the caret(insertion-point). It should be straightforward.  (PS. do not mistake selectedTextRange for <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UITextView_Class/Reference/UITextView.html#//apple_ref/occ/instp/UITextView/selectedRange">selectedRange</a> which returns just the <em>range</em> of the selection inside the text string.</p>
<p>To my frustration and despair, it didn&#8217;t work. My code would crash again and again complaining that selectedTextRange is an unrecognized selector. Even more frustrating, Google doesn&#8217;t offer any clue (except for one <a href="http://stackoverflow.com/questions/8002893/uitextfield-sigabrts-on-selectedtextrange">stackoverflow question</a> and the fact that people enjoy giving stupid answers although they don&#8217;t understand the question). Or that others <a href="http://stackoverflow.com/questions/3679199/cursor-position-in-a-uitextview">don&#8217;t think it&#8217;s possible</a>.</p>
<p>So I gave up implementing what I wanted, cut my losses and moved on to implementing some other features. But if you have any idea about a decent way to achieve this (and, no, I don&#8217;t really want to use a custom 3rd party uitextview clone just to be able to know the CGPoint position of the cursor), I&#8217;d greatly appreciate your input.</p>
<p>Until then, ain&#8217;t it weird that a required property in a required protocol doesn&#8217;t seem to be  fully implemented in Apple&#8217;s one of the most important core UI objects?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2011/12/uitextview-apple-quirks-and-cutting-ones-losses/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2011/12/uitextview-apple-quirks-and-cutting-ones-losses/</feedburner:origLink></item>
		<item>
		<title>Quick introduction to Grand Central Dispatch and why you should use it</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/aPP3sAe9_tM/</link>
		<comments>http://www.alexbrie.com/2011/11/quick-introduction-to-grand-central-dispatch-and-why-you-should-use-it/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 14:30:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=44</guid>
		<description><![CDATA[Hello idevs! Time sure flew by lately, so here I am, once more having to post one of my development adventures, forced by the unwritten agreement I took when joining the iDevBlogADay project. As any programmer can tell you, in most (over 95%) of your programming tasks you won&#8217;t have to deal with threads or [...]]]></description>
			<content:encoded><![CDATA[<p>Hello idevs! Time sure flew by lately, so here I am, once more having to post one of my development adventures, forced by the unwritten agreement I took when joining the iDevBlogADay project.</p>
<p>As any programmer can tell you, in most (over 95%) of your programming tasks you won&#8217;t have to deal with threads or any form of asynchronous programming. Chances are you will never need to deal with this, in most programming jobs. However, in iOS world, you have to. And unless people scare you upfront by pushing big words like threads and asynchronous programming, you should totally spend 5 minutes to at least grasp the big picture.</p>
<p><span id="more-44"></span>I don&#8217;t have time to get into details(and I also don&#8217;t feel like it), so I&#8217;ll just cut to the chase and talk non-programming for a second: whenever you do something that relates to the network, with opening up big files or other time-expensive operations, you risk freezing your app for longer than you&#8217;d wish. People will notice, get angry, quit the app, leave bad reviews, which will in turn bankrupt you. You don&#8217;t want this.</p>
<p>The good news is that Apple gave you several ways to handle this kind of situations in many ways, depending on your needs.</p>
<p>In 99% of the situations I needed this kind of non-blocking behavior, I handled them by just calling <strong>[self performSelectorInBackground:@selector(mybackgroundMethod) withObject:nil]</strong>. <strong>performSelectorInBackground</strong> can be found in NSObject, so all your objects and classes will have it by default. It&#8217;s pretty straightforward and was good enough to keep me company for the past 3 years.</p>
<p>The downside to *<strong>performSelectorInBackground</strong>* is that it&#8217;s pretty slow(it creates a NSThread object dynamically, etc); also, passing data to the method you want to keep in background it is a pain, as you hav to wrap it up in the withObject parameter, or as a global in your object. Calling back methods on your main thread was also convoluted, involving calls to &#8220;<strong>performSelectorOnMainThread:withObject:waitUntilDone:</strong>&#8220;. Not exactly straightforward.</p>
<p>Enter Grand Central Dispatch. It&#8217;s a new technology added by Apple in the past years, and you really should take a look at it. It might look pretty scary at first look, but perhaps I&#8217;ll be of help. If not, this <a href="http://en.wikipedia.org/wiki/Grand_Central_Dispatch">wikipedia article</a> is also a good start for the beginners.</p>
<p>What is GCD? It&#8217;s a technology that Apple made that works like threads but way more optimized, and also takes advantage of the multiple cores in your processor, so it will make your app faster. GCD works with &#8220;<em>dispatch queues</em>&#8221; instead of threads. You create (or use the default ones) queues in which you push fragments of code. If you push these fragments using &#8220;dispatch_sync&#8221;, these blocks of code will run sequentially just like normal code does. However, when you call &#8220;dispatch_async&#8221;, they start behaving like threads &#8211; won&#8217;t block your app, and possibly be called in the background on your iPhone 4S second core.</p>
<p>For the bare minimum basic functionality, you need to do as little as:</p>
<p>1. put your possibly time consuming code in</p>
<p><code>dispatch_async(dispatch_get_global_queue(0, 0), ^{<br />
.... // your code here<br />
});<br />
</code><br />
2. when you need to do something to the view, you will need to surround your code by</p>
<p><code>dispatch_async(dispatch_get_main_queue(), ^{<br />
....// your code here<br />
});<br />
</code><br />
You will notice that this actually looks a lot like defining a method with your possibly time consuming code and call that method by passing it as an argument to <em>performSelectorInBackground</em>. Similarly, when you wanted to have some code called on the main thread you&#8217;d put it in its own method which you&#8217;d call with <em>perform..onMainThread&#8230;</em> The same idea, really, only that GCD is cleaner code (no more defining methods for background/foreground stuff &#8211; you just use blocks), you type less and it&#8217;s faster, especially for multiple threads(queues).</p>
<p>Once again, slower this time: at the bare minimum, you have to deal with two built-in queues: the one returned by calling <em>dispatch_get_global_queue(0, 0)</em> which is a default background one, and <em>dispatch_get_main_queue()</em>, which is your main program queue. You can also create your own custom queues and give them nice names, which makes it easier to debug or follow in your app&#8217;s logs.</p>
<p>Here&#8217;s a hopefully better sample:</p>
<p><code>-(void)letMeShowYouASampleOfGCD{<br />
int precision = 50;<br />
dispatch_async(dispatch_get_global_queue(0, 0), ^{<br />
//here i do whatever I want do do,<br />
//such as computing the 100th digit of PI*e,<br />
//or checking out if I can download an internet resource.<br />
precision = precision + 50; // just to show how easy it is to send data to blocks<br />
[self computePiTimesEWithPrecision:precision];<br />
});<br />
}</code></p>
<p>You notice that you call the code by writing it in a block, which is also nothing scary; it&#8217;s just some code surrounded by <strong>^{}</strong> and possibly some parameters. I&#8217;ll write about them some other time, if you wish. The nice things about blocks is that they basically behave like methods, but you have less to worry about sending data to them. They &#8220;see&#8221; surrounding variables and can read them. Obviously instead of simply calling <em>computePiTimesEWithPrecision</em> I could have written the code directly there. But you understand that it was just an example.</p>
<p>Now, the other  thing to remember about GCD is that what you compute in a background queue happens in the background. In order to update your main view (let&#8217;s say by setting the text value of a UILabel), you need to call once more <em>dispatch_async</em>,  this time on the main queue.<br />
Like this:</p>
<p><code>-(void) computePiTimesEWithPrecision:(int)precision{<br />
// I do my computation, nothing special here<br />
// result = ...;<br />
dispatch_async(dispatch_get_main_queue(), ^{<br />
[myResult setText:[NSString stringWithFormat:@"%@", result]];<br />
});<br />
}<br />
</code><br />
So that&#8217;s about it. The extremely basic introduction to GCD. I hope it wasn&#8217;t too confusing and provided you with enough info to start playing with GCD by yourself or to start learning more from <a href="http://en.wikipedia.org/wiki/Grand_Central_Dispatch">wikipedia</a> or <a href="https://developer.apple.com/library/ios/#documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html">apple&#8217;s docs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2011/11/quick-introduction-to-grand-central-dispatch-and-why-you-should-use-it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2011/11/quick-introduction-to-grand-central-dispatch-and-why-you-should-use-it/</feedburner:origLink></item>
		<item>
		<title>What I learned from TechTalk 2011, London</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/4jMnmFB9WEU/</link>
		<comments>http://www.alexbrie.com/2011/11/what-i-learned-from-techtalk-2011-london/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 18:32:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iDevBlogADay]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=42</guid>
		<description><![CDATA[I guess it&#39;s my time again for #idevblogaday. I&#39;ll keep this post short, as I&#39;m still struggling with a bug that prevents me from submitting Clean Writer Pro. At the beginning of this week I was at Apple&#39;s iOS5 TechTalk in London. It was great. Apart from the rare opportunity of meeting great iOS developers [...]]]></description>
			<content:encoded><![CDATA[<p>I guess it&#39;s my time again for <a href="http://idevblogaday.com/">#idevblogaday</a>. I&#39;ll keep this post short, as I&#39;m still struggling with a bug that prevents me from submitting <a href="http://www.cognitivebits.com/news/soon-clean-writer-pro.html">Clean Writer Pro</a>. </p>
<p>At the beginning of this week I was at Apple&#39;s iOS5 TechTalk in London. It was great. Apart from the rare opportunity of meeting great iOS developers from around the world(I met awesome guys from UK, Vietnam, Germany, Canada, Romania and more), the talks day also brought me a (hopefully long-lasting) inspiration and motivation. In particular, there are three most important things I came back with:</p>
<ul>
<li>Try to create innovative, distruptive and industry-changing apps. Second best is to make them awesome and distinctive.</li>
<li>Don&#39;t get stuck in the past. Although it&#39;s obviously cool to support old devices&#47;OS versions, it&#39;s most often not worth the effort. Aim to use latest tech for the latest devices, as they are the most popular (of the 250 million total iOS devices, 50% have been sold in the past year &#8211; that&#39;s one huge market)</li>
<li>Go international &amp; localize. There are lots of non-US iOS owners.</li>
</ul>
<p>Two less important but still interesting things I learned:</p>
<ul>
<li>Always try to learn. Past WWDC videos and iOS video tutorials on iTunesU are way worth the effort to download and study. </li>
<li>There&#39;s no such thing as a small niche. It all depends on the app and your marketing plan.</li>
</ul>
<p>3+2 ideas. That&#39;s it. But they were totally worth the trip. Talk to you later.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2011/11/what-i-learned-from-techtalk-2011-london/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2011/11/what-i-learned-from-techtalk-2011-london/</feedburner:origLink></item>
		<item>
		<title>Compacted Google Reader</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/skrHmv09-uo/</link>
		<comments>http://www.alexbrie.com/2011/11/compacted-google-reader/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 13:08:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=38</guid>
		<description><![CDATA[After Google Reader&#8217;s UI change of today I, like millions of users, was furious. I won&#8217;t go into detail about the reasons (you can read them on my Romanian blog), but summing them up is easy: the new UI was probably designed on a couple of 30&#8243; computer screens and is a visual insult to [...]]]></description>
			<content:encoded><![CDATA[<p>After Google Reader&#8217;s UI change of today I, like millions of users, was furious. I won&#8217;t go into detail about the reasons (you can read them on my <a href="alexbrie.net/design-google-reader-si-steve-jobs">Romanian</a> blog), but summing them up is easy: the new UI was probably designed on a couple of 30&#8243; computer screens and is a visual insult to anyone trying to use it on a normal, smaller, screen. Regardless of the colors and fonts used, the new Google Reader UI is unusable due to its excessive use of whitespace which fills up the screen with unneeded padding and margins, while the actual content is crammed into a tiny space forcing you to scroll like a mad man.<br />
Solutions started to appear pretty soon after, in the form of user-side scripts using browser extensions such as Greasemonkey or UserCSS.<br />
Being a Safari user myself I followed a Twitter friend&#8217;s suggestion and created my own little UserCSS stylesheet which fixes the excessive whitespace issue, while keeping the new style.<br />
If you are curious to try it, check out this <a href="https://github.com/cognitivebits/Cognitive-Bits-Public-Scripts">page on Github</a>. You can easily insert the style into a Greasemonkey script, if you wish.<br />
<strong>From this..</strong><br />
<img class="alignnone" src="https://img.skitch.com/20111101-nf5m5uwd5s9eu4metyhqxmwkx6.png" alt="" width="610" /></p>
<p><strong>..To this</strong></p>
<p><img class="alignnone" src="https://img.skitch.com/20111101-kx1i8g6dbdnw5u2u5r7191ncxs.png" alt="" width="500" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2011/11/compacted-google-reader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2011/11/compacted-google-reader/</feedburner:origLink></item>
		<item>
		<title>Are you coming to the TechTalks?</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/TjgxaYO880I/</link>
		<comments>http://www.alexbrie.com/2011/10/are-you-coming-to-the-techtalks/#comments</comments>
		<pubDate>Fri, 28 Oct 2011 16:03:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iDevBlogADay]]></category>
		<category><![CDATA[just posts]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=35</guid>
		<description><![CDATA[One week ago, Apple announced its iOS5 Tech Talk World Tour, with a great talk agenda prepared. The announcement email took a bit longer to reach me, so I first learned about it from Twitter. Needless to say, I instantly applied. My target of choice? London, obviously &#8211; I knew there&#8217;s a great iOS community [...]]]></description>
			<content:encoded><![CDATA[<p>One week ago, Apple announced its <a href="http://developer.apple.com/techtalk/">iOS5 Tech Talk World Tour</a>, with a great talk agenda prepared. The announcement email took a bit longer to reach me, so I first learned about it from Twitter. Needless to say, I instantly applied. My target of choice? London, obviously &#8211; I knew there&#8217;s a great iOS community in UK which I&#8217;d love to meet, I had never been there and also wanted to combine tourism with business (can we call it business if it&#8217;s a talk for developers teaching them new tech tricks to use in their apps?). Eventually, after 5 long days of waiting, I got notified of having been accepted to the London tech talk (I had access to two iOS accounts and had also applied to Rome to double my chances &#8211; I was only accepted to London, though). </p>
<p>So&#8230; London, here I come!</p>
<p>Due to the late notice(<em>trying to book a flight with less than 14 days before the flight</em>) I missed the last economy seats on the direct British Airlines flight, my only option was Lufthansa with a pretty awful schedule, risky plane changes in Germany and more expensive with over 50%. Also, it turns out that I might not be able to visit London at all, as I&#8217;ll be arriving late in the evening of the 6th and will leave the on the 8th at noon. Well, that&#8217;s how life is sometimes, you can&#8217;t have it all. I wasn&#8217;t planning to be too much of a tourist, but I had hoped to take a peek at some standard London attractions; but, after all, that&#8217;s not the reason why I&#8217;m going there. </p>
<p>Anyways, to conclude this useless post, I was wondering if any of the iOS developers reading this blog are coming there &#8211; if so, why don&#8217;t you leave a comment with your blog url/twitter so maybe we can get together during one of the breaks and, you know, socialize? If you&#8217;re not coming to the London Tech Talk on November 7th but to another one, where is that? Still curious to find out! <img src='http://www.alexbrie.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2011/10/are-you-coming-to-the-techtalks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2011/10/are-you-coming-to-the-techtalks/</feedburner:origLink></item>
		<item>
		<title>More AppStore scams  – Flash Video Exposer</title>
		<link>http://feedproxy.google.com/~r/AlexbrieCom/~3/5_Y4pQ066MA/</link>
		<comments>http://www.alexbrie.com/2011/10/more-appstore-scams-flash-video-exposer/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 08:35:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AppStore]]></category>

		<guid isPermaLink="false">http://www.alexbrie.com/?p=31</guid>
		<description><![CDATA[While casually browsing the AppStore I noticed an intriguing app called &#8220;Flash Video Exposer&#8221; which, at the time, was #1 Top Paid app in the Romanian iPad App Store. It was also in the top 30 paid apps in the iPhone App Store. Problem is, all user reviews unanimously cry that this app is a [...]]]></description>
			<content:encoded><![CDATA[<p>While casually browsing the AppStore I noticed an intriguing app called &#8220;<a href="http://itunes.apple.com/ro/app/flash-video-exposer/id473049897?mt=8">Flash Video Exposer</a>&#8221; which, at the time, was #1 Top Paid app in the Romanian iPad App Store. It was also in the top 30 paid apps in the iPhone App Store. Problem is, all user reviews <strong>unanimously cry</strong> that this app is a scam, and a pretty expensive one actually (8 euro).</p>
<p>Curious to learn how it was possible that an app whose users call a fake can still be in the App Store, I started looking for more information.<br />
It <a href="http://www.appannie.com/search/?q=Flash+Video+Exposer">turns out</a> that this is a resubmitted version(under a minor name change) of an app that had been previously removed from the store (we can&#8217;t tell if at Apple&#8217;s initiative or simply at the developer&#8217;s). It used to be called &#8220;Flash Video Expose&#8221; and, as such, managed to receive many complaints, dedicated <a href="http://itracki.com/2011/07/17/10229/">blog posts</a> about the scam, and even <a href="http://www.youtube.com/watch?v=wHzvZqJejzU">YouTube reviews</a> exposing it. What matters is that now it&#8217;s back, with a minor name twist and a different &#8220;developer&#8221; listed, selling the same fake features for an even higher price. And, according to the download charts and product reviews, it works.</p>
<p>Don&#8217;t bother looking for it in the US App Store; probably having learned its lesson, the developer didn&#8217;t submit it there; since the US App Store is under thorough scrutiny from the IT press, popular blogs and, obviously, Apple staff, when you want your scammy app to fly below the radar you should avoid it.</p>
<p>How well does such a scam do? According to <a href="http://www.appannie.com/flash-video-exposer/ranking/#view=best-grossing-ranks">AppAnnie</a>, pretty well &#8211; it is the most popular/grossing Utility app in tens of App Stores. True, revenue from minor App Stores is significantly smaller than it would have been from the US store but, with a bit of luck, if this scam remains undiscovered for a couple of months, it should bring its author a few hundred thousands in revenue, if not <em>millions of dollars</em>.</p>
<p>If you ask me what Apple could have done to prevent this, my answer is simple: they need to add a visible &amp; easy to access contact form inside iTunes App Store for app complaints. As it is now, people don&#8217;t have a clear method to notify Apple of App Store issues such as scams, copyright infringements or ill-behaved apps. Sure, adding this would be a logistic nightmare and likely affect the reputation of the App Store ecosystem, but it&#8217;s necessary and way overdue.</p>
<p>Until then, blog posts such as this one and Tweets are the only means we have of letting Apple know that they should do more to protect their users. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.alexbrie.com/2011/10/more-appstore-scams-flash-video-exposer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.alexbrie.com/2011/10/more-appstore-scams-flash-video-exposer/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.339 seconds -->

