Wednesday, July 10, 2013

Ten iOS interview questions

I had viewed some blogs, which mentioned ten iOS interview questions. I think it's basic but important. If you have 2-3 years iOS development experiments, you should answer the questions easily.

Ok, let's start.

1. Have you use objective-c runtime programming? If you did, what you use it for.

2. Have you use multi thread core data? which method you use? How do you do with   NSPersistenStoreCoordinator,NsManagedObjectContext and NSManagedObject

3. Have you use CoreAnimation and COreGraphics. What is the relationship between UI framework, CA framework and CG framework.

4. Have you use CoreText or CoreImage? Tell me about that.

5. What is NSNotification and KVO? What's the difference between them? when to use NSNotification and when to use KVO? can you use protocol and delegate to implement the same function like NSNotification and KVO? why?

6. Have you use NSOperationQueue? Why you use NSOperationQueue and what for? Tell me about the difference between NSOperationQueue and GCD.

7. What you need to care when you use GCD and block? are they the same thing?

8. How to deal with Asynchronous Network? how do you implement that?

9. How do you think of Objective-C, pros and cons? Have you think about the redo some functions about Objective-C?

10. Have you implement a framework or library? If you do, tell me about that. If you do not, try to design a public API.


These questions might be too hard for junior iOS developer. If you need to answer all of that, maybe you at least have 2-3 years development experiments.

Reference:
http://onevcat.com/2013/04/ios-interview/
http://wufawei.com/2013/05/11-interview-questions/

Sunday, June 2, 2013

iOS -- A new way to implement segment control


Recently I have found a new way to implement segment control, wich is HMSegmentControl.

I found a very good project in GitHub, here is the link:

https://github.com/HeshamMegid/HMSegmentedControl


Wednesday, May 29, 2013

Xamarin -- Running .Net in Mac

I just found a awesome IDE, Xamarin, which can run .Net project in Mac OS.

Here is the link:

http://monodevelop.com/Download







Saturday, April 20, 2013

Add a Textfield in UIActionsheet

If you want to add a UITextfield to a UIActionsheet in ios development, you can not just directly add the textfield to the actionsheet.

If you just add a textfield to actionsheet, you can not type any words in the textfield. It seems like some methods in textfield is not working properly.

So is it any way to add the textfield to actionsheet? The answer is yes.

Thanks to the following answer:

http://stackoverflow.com/questions/4367494/keypad-not-working-for-textfield-in-uiactionsheet


we can successfully add a textfield in actionsheet.  The idea is show the actionsheet first, and then add the textfield above the actionsheet.


I just dont want to go through the detail. I have add the code to github. If you are looking for the solution about this. You can download it freely.

Here is the link:

https://github.com/fisherv1/actionsheetWithTextFiled.git


Here is what it looks like:


Tuesday, March 19, 2013

Ubuntu setup Git Server

1. Setup

1.1 install Git-Core in Ubuntu server

        sudo apt-get install git-core

1.2 install Gitosis in Ubuntu server

        sudo apt-get install python-setuptools
        mkdir ~/src
        cd  ~/src
        git clone https://github.com/res0nat0r/gitosis.git
        cd gitosis
        sudo  python setup.py install




2. Configuration

2.1 Enable ssh service in Ubuntu server
   
      to use ssh-server, must open port 22 for
      install ubuntu open ssh
   
       sudo apt-get install openssh-server

       to make sure ssh server enable or not, run  ps -e | grep ssh

       if only can see ssh-agent, means ssh-server not start yet, if see sshd means, ssh-server already start.

       And then restart ssh server
       run :     sudo /etc/init.d/ssh restart

3. Add new user

3.1 cd to gitosis-admin
 
      copy new user's id_rsa.pub to keydir folder, named as new_user.pub

3.2  edit gitosis.conf

       vim gitosis.conf

      edit as follow:

     [group ProjectName]
     members = old_user1 old_user2 new_user
     writable = ProjectName

   save and exit

3.3 back to gitosis-admin folder, push the change to server, then the sever will allow new member to download

       git add .
       git commit -am "add new user"
       git push

       Now the user can clone from the new user

 
4. Create new project

 4.1    in local pc, open gitosis.conf, enter

     [group NewProject]
     members = matthewlu@mamembers = matthewlu@matthews-MacBook-Pro.local vic mac_mini
     writable = NewProject

   save and exit

   push the change to server
   git commit -am "create a new project"
   git push

4.2 in server, in repositories folder , create a new folder
      mkdir NewProject

     cd to NewProject

     Init a new git repository
     git init --bare

 4.3 in local machine

       Create the NewProject

       mkdir NewProject
      git init
      git remote add origin admin@YOURSERVER:NewProject
      git add .
      git commit -am "init a new project"
      git push origin master
 

5. Create .gitignore for new create Xcode git project

   5.1 touch .gitignore
         The location of .gitignore is same as .git, .gitignore is not inside .git


   5.2. vim .gitignore
           add the content below to .gitignore

# Mac OS X
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/

# Generated files
*.o
*.pyc


#Python modules
MANIFEST
dist/
build/

# Backup files
*~.nib
   
Then save and exit

5.3  add .gitignore to git

      git add .gitignore
      git commit  -am "create .gitignore file"
      git push origin master



6. Add ssh key to server

    get the publick key  key.pub

    copy the key content to server authorzied_key

    refresh ssh

7. gitignore file for visual studio

    #
# Windows and Mac OS X Temp Cache Files
#
[Tt]humbs.db
*.DS_Store

#
#Visual Studio files
#
*.[Oo]bj
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.lib
*.sbr
*.sdf
ipch/
obj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/

#
#Tooling
#
_ReSharper*/
*.resharper
[Tt]est[Rr]esult*

#
#Project files
#
[Bb]uild/

#
#Subversion files
#
.svn

#
# Microsoft Office Temp Files
#
~$*

# End of File


8. windows connect to ubuntu server
    the path format is below:
 
    192.168.1.26:repositories/EngagerIntranet.git

       

Monday, March 18, 2013

Converting Longitude and Latitude to a Meaningful Address



This part of code is from Book , Vandad Nahavandipoor.


1. Declare a property of type CLGeocoder


    #import
   #import  
     @interface
     Converting_Meaningful_Addresses_to_Longitude_and_LatitudeViewController : UIViewController
    @property (nonatomic, strong) CLGeocoder *myGeocoder;
    @end 



2. In viewdidload

            CLLocation *location = [[CLLocation alloc] initWithLatitude:+38.4112810
longitude:-122.8409780f]; self.myGeocoder = [[CLGeocoder alloc] init];
[self.myGeocoder
reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
if (error == nil && [placemarks count] > 0){
CLPlacemark *placemark = [placemarks objectAtIndex:0]; /* We received the results */
NSLog(@"Country = %@", placemark.country); 
NSLog(@"Postal Code = %@", placemark.postalCode);
NSLog(@"Locality = %@", placemark.locality);
}
else if (error == nil &&
[placemarks count] == 0){ NSLog(@"No results were returned.");
}
else if (error != nil){
NSLog(@"An error occurred = %@", error); }
}];