Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Juguang XIAO between40and2

:octocat:
View GitHub Profile
View Ugliness of iOS Programming
Ugliness of iOS Programming
First of all, i love iOS and iOS development ecosystem.
However, after I quick learnt Ruby on Rails, I found how messy iOS Programming Frameworks are. Apple guys must feel innocent on this. They have worked hard to make the frameworks easy to use, powerful yet flexible.
one end is, "there is more than one way to do a thing". I first heard it from Perl, which they are proud of that.. However, the downside of this is there is no conversion or culture.
There is no so-called application framework for iOS officially from Apple. After rough understanding on UIKit and Foundation, the developers need a further direction on how to improve the productivity on iOS development.
@between40and2
between40and2 / WelcomeToBlockWorld
Last active Dec 10, 2015
WelcomeToBlockWorld. get habit to use block-based, rather than old-style return-based invocation.
View WelcomeToBlockWorld
WelcomeToBlockWorld
http://www.cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html
View gist:5194810
iOS & RoR
Wired combination? In my past 12 years, I have used more than these technologies on GUI and Web. Finally I fell in these 2.
One feature charms me in RoR is the feature of metaprogramming. Ruby supports it and Rails fully uses it. It sucks me into deeper thought on metaphysics of programming. Why are we (as programmers) here? What can machine (software) facilitates men (programmers) ? I would like to share some of my ideas.
Before iOS, I was working intensively with Adobe Flex. The beauty of Flex's flexible architecture attacks me, plus its UI expressiveness. I was my dream back in 2005, to present fancier UI on Web via programmable Flash. In 2010, the year I came to meet iOS, there was the debate on whether Flash should be run on iOS, I was wondering whether I should go for iOS. I became so determined after I realised the depth and width of iOS technologies are much greater than of Flash/Flex. Another obviously plus on iOS is, I can carry on my program anywhere I go.
@between40and2
between40and2 / gist:5194833
Last active Dec 15, 2015
rails plugin migration
View gist:5194833
http://stackoverflow.com/questions/4974039/rails-project-organization-with-many-models
http://stackoverflow.com/questions/6550103/in-which-folder-should-i-put-global-shared-partial-templates
http://stackoverflow.com/questions/6550103/in-which-folder-should-i-put-global-shared-partial-templates
<pre><code>$ cd your_repo_root/repo_name
$ git fetch origin
$ git checkout gh-pages
@between40and2
between40and2 / JXZip
Last active Dec 16, 2015
JXZip, hopefully easy to use to zip/unzip in iOS
View JXZip
I was in somehow confused to use ZipArchive.
First of all, I do not know which one is the "official" version of it.
https://github.com/mattconnolly/ZipArchive
Or
http://code.google.com/p/ziparchive/
View iOS-Callback
Here is my sum on which callback mechanism should be used for which cases.
- for UIView and UIVC, use delegate
- for model change, use NSNotification or KVO. However, KVO is not designed for communicating "events", therefore NSNotif is the preferred.
- for Data Access, use block.
for UIControl subclass, use target-action.
Bye Delegate, Hello Block
@between40and2
between40and2 / scm-svn-git
Last active Dec 16, 2015
favorite links for SCM, SVN, Git. etc.
View scm-svn-git
http://svnbook.red-bean.com/en/1.0/index.html
View iOS-Keyboard
After 3 years of iOS development practice, finally I have chance to fully work with the soft keyboard. I found the Apple official docs is far from enough to deal with every cases of iOS soft keyboard. Then online 3rd party docs are helpful but not complete either. I can understand it since everyone is busy, very few people to write a complete guide for any specific topics.
Then I come to this. I have to do trial and error to grasp this piece of knowledge. One problem I was facing is when device is in landscape, you cannot use keyboard's height to adjust textview/tableview's contentInsets, since the height actually seems as its "width". UIWindow is mounted always in portrait mode, and keyboard frame goes with it. When device and UI is in landscape, the keyboard frame is still measured as it is in portrait. The solution:
CGRect frameEnd = [[notif.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
frameEnd = [self.view convertRect: frameEnd fromView: nil];
@between40and2
between40and2 / ios-object-attribute-access
Last active Dec 25, 2015
Given an Objective-C object and an attribute name, how can you access (read/write) it?
View ios-object-attribute-access
return [self.object valueForKey: attrName];
--
SEL getterSEL = NSSelectorFromString( attrName);
@between40and2
between40and2 / class_addIvar-useless
Created Oct 24, 2013
class_addIvar, in Objective-C runtime, is useless
View class_addIvar-useless
class_addIvar, in Objective-C runtime, is useless, because it does not support to add ivar in an EXISTING class.
https://developer.apple.com/library/ios/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html#//apple_ref/c/func/class_addIvar
You can use the concept of idInfo (see id-ego-superego), to add run-time generated objects' property.
You can’t perform that action at this time.