Archive for the ‘ iOS ’ Category

Proper way to show/hide animating Activity Indicator

There are scenarios when one does some heavy weight fetching of data from an external database thats time consuming. During the fetching, we want to give appropriate feedback to user that something is being done. Thats when Activity Indicator (UIActivityIndicator) object comes in handy. Its a spinner that shows and spins and then stops animating and disappears when the process is finished.

A point to be noted is that one should always start Spinner in a separate thread.

Wrong (works only sometimes):

[activityindicator startanimating];
//Some code
[activityindicator stopanimating];


[NSThread detachNewThreadSelector:@selector(threadStartAnimating: ) toTarget:self withObject:nil];
// Some code  
[spinner stopAnimating];
[self.navigationcontroller pushviewcontroller:viewcontroller animated:YES]; 

-(void)threadStartAnimating: (id)data
[spinner startAnimating];

How do I add an existing framework to my iOS project in Xcode4 ?

As a iOS developer, when I migrated to XCode4, it took me a while to know how one can add an existing framework to his/her Xcode iOS project. So, I thought of sharing it with others who may be facing similar problem:

select your project,

  1. select the project on left. You need to go the the panel on the left and select the the topmost item which is your project. This will give you interface that allows you to find a Build Phases tab.
  2. go to the ‘build phases’ tab,
  3. open the ‘Link binary with Libraries’ section
  4. Use the + to add the framework you want

kUTTypeImage ld: symbol(s) not found for architecture armv6

Use kUTTypeImage in your code. Build fails with following error:
ld: symbol(s) not found for architecture armv6

Include MobileCoreServices framework and import <MobileCoreServices/UTCoreTypes.h> in the class file.