<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Guang光 on Medium]]></title>
        <description><![CDATA[Stories by Guang光 on Medium]]></description>
        <link>https://medium.com/@whimsical_Guang?source=rss-25de372727a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lyL1ufjUvqfGbgMq.jpeg</url>
            <title>Stories by Guang光 on Medium</title>
            <link>https://medium.com/@whimsical_Guang?source=rss-25de372727a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 23:14:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@whimsical_Guang/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[UIInterpolatingMotionEffect for Newbies?]]></title>
            <link>https://medium.com/@whimsical_Guang/uiinterpolatingmotioneffect-for-newbies-72787aa3f3e7?source=rss-25de372727a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/72787aa3f3e7</guid>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Guang光]]></dc:creator>
            <pubDate>Fri, 13 Nov 2015 05:55:31 GMT</pubDate>
            <atom:updated>2015-11-13T06:10:44.472Z</atom:updated>
            <content:encoded><![CDATA[<p>UIInterpolatingMotionEffect for Newbies?</p><p>Its name seems to relate with animation, but its method seems to take care of it from A<a href="https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIMotionEffect_class/index.html#//apple_ref/occ/instm/UIMotionEffect/keyPathsAndRelativeValuesForViewerOffset:">pple’s documentation</a>. This “abstract super class” (🙄?)has one task : getting the key path!</p><p>Go steps: ☞ alloc the class ☞ init with key path and motion ☞ effect type<br>☞set their value.</p><pre>UIInterpolatingMotionEffect * xMotionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@”center.x” type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];</pre><pre>xMotionEffect.minimumRelativeValue = y;<br>xMotionEffect.maximumRelativeValue = x;</pre><pre>[view addMotionEffect:xMotionEffect];</pre><p>But does it reflect the factual physics? Not sure yet. So the relative values could be arbitrary. I wrote a little method to test a Label , a imageView, and an animation drawing.</p><pre>[self applyMotionEffectToView:self.apodTitle withX:@(90) andY:@(0)];<br>[self applyMotionEffectToView:self.beluga withX:@(-30) andY:@(50)];[self applyMotionEffectToView:lineView withX:@(-40) andY:@(15)];</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/203/1*ecuuOagferx15q72qWDHsw.gif" /></figure><p>If the image from imageView is aspect fill, UIInterpolatingMotionEffect expend the view bit to see what was not seen when the phone is not tilting.</p><p>Text Label adds the playfulness. The animation drawing, not sure if it does something more. The effect is cool, but it is hard to trick the mind to feel I am for real gazing into the space of ocean with a beluga from a screen sized device…🐋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72787aa3f3e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[api : Astronomy Picture of the Day for the Newbies.]]></title>
            <link>https://medium.com/@whimsical_Guang/api-astronomy-picture-of-the-day-for-the-newbies-7d4244f7482b?source=rss-25de372727a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d4244f7482b</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Guang光]]></dc:creator>
            <pubDate>Sun, 01 Nov 2015 21:15:49 GMT</pubDate>
            <atom:updated>2015-11-02T05:44:38.994Z</atom:updated>
            <content:encoded><![CDATA[<p>NASA posts amazing images of the far out distance from the rest of the earth: <a href="http://apod.nasa.gov/apod/astropix.html">http://apod.nasa.gov/apod/astropix.html</a>. How do I just get one image to show up on my simulator as a newbie for iOS development?<br>YES! It is less than 15 lines of code.</p><p>api: mentioned often, and seems important. Sign up so I can have access to NASA’s api in order to get the image of the day! Go to this site <a href="https://api.nasa.gov/index.html#live_example">https://api.nasa.gov/index.html#live_example</a> and sign up. You’ll receive an email with a key to open the door of NASA’s images of the space! Maybe that is what api is about.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uIA_kp79Sy5syZfcV3mYLQ.png" /></figure><pre>@implementation ViewController<br>-(void)viewDidLoad {<br>[super viewDidLoad];</pre><pre>NSString * urlS = @”https://api.nasa.gov/planetary/apod?api_key= (PASTE YOUR KEYS THAT NASA SENT YOU AFTER ABOVE SIGN UP)&quot;; </pre><pre>// It looks similar like the below <br>//NSString * urlS = @&quot;<a href="https://api.nasa.gov/planetary/apod?concept_tags=True&amp;api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo">https://api.nasa.gov/planetary/apod?concept_tags=True&amp;api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo</a>&quot;;<br>...<br>}</pre><p>Try to open the link in web browser. You get something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rrlI-VCh88ppV1sfoSqqTQ.png" /></figure><p>Wow! Try to copy and paste the fist line <a href="http://apod.nasa.gov/apod/image/1511/monumentvalley_pacholka_1080.jpg">http://apod.nasa.gov/apod/image/1511/monumentvalley_pacholka_1080.jpg</a> . You might get this! <strong>✌︎</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWnRtY_1M3DUk066FrCujQ.png" /></figure><p>With the key I got from NASA’s email, I was able to get the link of the apod (picture of the day), and some info about that picture! Lets pack that <strong>data</strong> into objective C recognizable/friendly boxes and use them in the iOS land.</p><pre>-(void)viewDidLoad {<br>[super viewDidLoad];<br>NSString * urlS = @&quot;https://api.nasa.gov/planetary/apod?api_key= <em>(</em>☞☛<em>your-NASA-api-key</em>☞❉✲✺❋✮✣✢⦿<em>)</em>&quot;;</pre><pre>NSURL * url = [NSURL URLWithString:urlS];<br>NSData * apiData = [NSData dataWithContentsOfURL:url];<br>NSDictionary * apiResult = [NSJSONSerialization JSONObjectWithData:apiData options:0 error:nil];<br>...<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u5yBAsUNPuY7wWAUAC_gkA.png" /></figure><p>Put break point at line <em>NSURL * url</em> = [ …. ] <strong><em>NSURL</em></strong> turns a <em>NSString</em> of a URL weblink to something like an informational set of data. Step to next line <em>NSData * apiData </em>=[ … ] apiData looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajx6FGPfMb-yahyOCIDSeg.png" /></figure><p>NOT really readable. Step to the next line? <em>NSDictionary * apiResult = […]</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KyB74GEy4diy_o940VpXw.png" /></figure><p>♡ ! A dictionary of 5 elements. [0]explanation, [1]title, [2]url, [3]media type, [4]concepts. ︎☞get the title from the dictionary <em>apiResult.</em></p><pre>NSString * imageURLString = [apiResult objectForKey:@”url”];<br>NSString * title = [apiResult objectForKey:@&quot;title&quot;];<br>self.apodTitle.text = title;</pre><p>☛get the image from the dictionary <em>apiResult. However, The image URL string just as the big NASA link </em><a href="https://api.nasa.gov/planetary/apod?concept_tags=True&amp;api_key=NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo">https://api.nasa.gov/planetary/apo</a>…., that we have to make it go through NSData unpacking process for Xcode to get the full information about it. It is not really a string after all.</p><pre>NSURL * imageURL =[NSURL URLWithString:imageURLString];<br>NSData *imageData2 = [NSData dataWithContentsOfURL:imageURL];<br>UIImage * testImage = [UIImage imageWithData:imageData2];<br>self.test.image = testImage;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ug5yseWALbhg5t6wPczbcw.png" /></figure><p>Things I learned:<br>☛api is hard to understand fully, but it has to do with this motion of getting the data from NASA open api services by a quick registration, delivering it to objective C! Like visiting friend’s place to pick up something but let them know first.<br>☛Different ways to unpack the api for Xcode to get the full content of this NASA image-of- the-day api, one of them is</p><pre>[NSJSONSerialization JSONObjectWithData:apiData options:0 error:nil];</pre><p>It returns a <em>NSDictionary with </em>readable information about what exactly is packed in<em> NSData.</em></p><p>.🎈✨. <a href="https://github.com/guangLess/Astronomy-Picture-of-the-Day-for-the-Newbies">Github example</a></p><p>FYI: you might see the following error : <em>App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file. </em>It has to do with iOS 9 update. Google has an explanation.</p><p><a href="http://googleadsdeveloper.blogspot.com/2015/08/handling-app-transport-security-in-ios-9.html">http://googleadsdeveloper.blogspot.com/2015/08/handling-app-transport-security-in-ios-9.html</a></p><p><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d4244f7482b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NSTimer for the newbies]]></title>
            <link>https://medium.com/@whimsical_Guang/nstimer-for-newbies-20b6ee939cca?source=rss-25de372727a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/20b6ee939cca</guid>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[nstimer]]></category>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[Guang光]]></dc:creator>
            <pubDate>Wed, 21 Oct 2015 05:44:08 GMT</pubDate>
            <atom:updated>2015-11-01T19:14:05.046Z</atom:updated>
            <content:encoded><![CDATA[<p>NSTimer for the newbies</p><p>If objective C is a computer language living in the Xcode system nurtured by physical machinery things, then what is time inside of it? That was overwhelming. To simply display time, NSTimer does it.</p><pre>-(NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:self selector:(tobeSelectedMethod) userInfo:nil repeats:(BOOL)yesOrNo;</pre><p>While there are other NSTimer class methods we could use to execute the motion of time passing, but this is the preferred option because it starts timing once called.</p><pre>-(void)viewDidLoad{<br>[super viewDidLoad];<br>self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 <br>                                              target:self <br>                                     selector:@selector(startTimer1)       <br>                                     userInfo:nil repeats:YES];<br>}</pre><pre>-(NSString *)startTimer1{<br>  //gap is an integer in between time interval value.<br>  self.gap = 1;<br>  self.interval1 += self.gap;</pre><pre>  //format self.interval<br>  NSUInteger seconds = (int)self.interval;<br>  NSUInteger minutes = seconds/60;<br>  NSUInteger hours = minutes/60;<br>  NSString *timeString1 = [NSString stringWithFormat:@&quot;%lu:%lu:%lu&quot;,(unsigned long)hours, minutes%60, seconds%60];<br>  <br>  //display the time with UILabel<br>  self.timeLabel.text = timeString1; <br>  return timeString1;<br>}</pre><p>…and it stops this timing by:</p><pre>[self.timer invalidate];</pre><p>Most bits in the above code are self-explanatory and mentioned in many tutorials:<br><em>scheduledTimerWithTimeInterval</em> takes<strong> <em>NSInterval</em></strong>, which acts just like the second in real time. <em>@selector</em> activates another method, which relies on the <strong><em>NSTimer</em></strong> to fulfill itself. <em>repeats:YES</em> asks the timer to expand it’s interval <strong>1 </strong>continuously as a rhythm. Therefore, we have the every second ticking, tic, tic, tic … Think about a <a href="https://en.wikipedia.org/wiki/Metronome"><strong>metronome</strong></a><strong>:</strong> a<strong> </strong>finger pushes the ticker pole( scheduledTimer…), the weight on the ticker pole controls the beat (WithTimeInterval…), wind the nob on the side (repeats:YES). <em>selector:@selector </em>play the music<em> </em>on the beat!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F110PhF9eauS7wQ%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fmetronome-110PhF9eauS7wQ&amp;image=http%3A%2F%2Fmedia.giphy.com%2Fmedia%2F110PhF9eauS7wQ%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="499" height="162" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a288cacb4300001d6e8f62cebc98967/href">https://medium.com/media/1a288cacb4300001d6e8f62cebc98967/href</a></iframe><p>This is an example on how NSTimer method <em>scheduledTimerWithTimeInterval </em>varies if assigning :<br>interval to 1, 0.1,1. gap to 1,1,10. <a href="https://github.com/guangLess/nstimer-for-theNewbies">https://github.com/guangLess/nstimer-for-theNewbies</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*5rSXhmcCDWxIrrJyNSb2yg.gif" /></figure><p>Notice: <em>TimeInterval:</em> can be different numbers. 1 is 1 second. 10 is 10 second. If it is 10, then there are 10 second in-between each time tick. <em>self.gap = 1 </em>can be other numbers as well. Play!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fa2SR6Ag8ChUlO%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Ftime-a2SR6Ag8ChUlO&amp;image=http%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fa2SR6Ag8ChUlO%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="292" frameborder="0" scrolling="no"><a href="https://medium.com/media/55e8a6dcaae26778945c7c10171afa90/href">https://medium.com/media/55e8a6dcaae26778945c7c10171afa90/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20b6ee939cca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Forking for the newbies]]></title>
            <link>https://medium.com/@whimsical_Guang/forking-for-the-newbies-89b8ed116b6f?source=rss-25de372727a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/89b8ed116b6f</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[fork]]></category>
            <dc:creator><![CDATA[Guang光]]></dc:creator>
            <pubDate>Thu, 08 Oct 2015 05:55:43 GMT</pubDate>
            <atom:updated>2015-10-08T15:33:22.872Z</atom:updated>
            <content:encoded><![CDATA[<p>Forking for the newbies</p><p>Learning Git is amazing. It feels like building bridges, and imagining traffic rules. As a beginner, I am yet to be in an active communicative situation where I have various branches with various collaborators in various locations. For now, Git related tasks seem one directional, and problems like this have happened a few times:</p><ul><li>Guang forks labX from <em>git@github.com:learn-co-students/labX.git</em>.<br>Guang writes code in this objective C lab; ⌘U to test. A red alert shows an error that was beyond her knowledge. Tim, the instructor, fixes the alert on labX and pushes it to the repository <em>learn-co-students/labX.git</em>. She searches the question and finds keywords “upstream &amp; syncing”<br>and a Github help page.</li><li>“Sync a fork of a repository to keep it up-to-date with the upstream repository.” is a great sentence for Guang’s problem.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*azl9MHPvBDtERX58zQQkIg.png" /></figure><p><a href="https://help.github.com/articles/syncing-a-fork/">Syncing a fork - User Documentation</a></p><p>.</p><pre>git remote -v<br>git remote add upstream git@github.com:learn-co-students/labX.git<br>git remote -v</pre><pre>git fetch upstream<br>git checkout master //if not on master branch<br>git merge upstream/master</pre><p>Understood:<br><em>upstream</em> is a word that is commonly agreed upon to name the remote repository pointing at the thing you’re forking. It is not a special git method such as remote, add, status, etc.</p><p><em>(remote)/(branch) format<br>origin / master</em></p><p>The name of remote is origin, the name of the branch is master–both by default. None of them are special. If you <em>git help master </em>(or <em>origin</em>, or <em>upstream</em>) you will get <em>No manual entry for gitmaster</em>.</p><p>So…<a href="http://git-scm.com/book/ch3-5.html">“origin” is not special</a> (a useful, short read from <em>git)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*dR0vvZHGAqO9XnljwdFvQg.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89b8ed116b6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>