Tuesday, February 21, 2012

Countdown on apple app store !!

Countdown has started as app download count is approaching 25 BILLION on Apple app store. Enjoy your share of download and upload :)

Sunday, February 19, 2012

Display hiding file in Lion OS X

Wondering where is Application folder in  Lion OS X ?  XCode stores cache for Simulator when you install the app.

Its actually  hidden, you can do following steps to make it appear.

  1. Open in Finder Application>Utilities>Terminal
  2. Write the following line in Terminal Window:
    
    
    defaults write com.apple.Finder AppleShowAllFiles YES
  3. Press return
  4. Close the Finder.
You should find all the hidden files or folders next time you launch the Finder Window. After finding your cache folder you can again hide all hidden files by writing following line in Terminal Window

defaults write com.apple.Finder AppleShowAllFiles NO




Where to locate the cache folder ?




Saturday, February 18, 2012

How to create your First Mac (Cocoa) App.

Ok folks, here comes the long awaited first tutorial for Mac Development, with recent rush in Mac applications, people are searching for Mac Development Tutorials more and more.....hope this helps...
Good thing is you always have interface builder to create your screen just like mobile app development.


1. Just open the Xcode and start a  new project.











2. Then you choose Cocoa Application.




















3.Then you just give Product Name to your application and Create it and Save it on your computer.




















4. This is what your screen will look like now. On the bottom right, you can find the object library where the Label UI component is highlighted, we will drag and drop it on Window - MyFirstMacApp.




















5. Once you dropped it on the view, you can fix its width but not height.As you can see in the right side under view section, the height text field is greyed out.

























6. Now we will write our text  on the label under Textfield section on right side (highlighted with blue color).




















7. In the MainMenu file, you can find the options which will appear in the menu bar when you start the app.
























8. Well basically we are done. Here is what happens you press the Run. You see a new window open with the label which says "This is my first app", which we wrote in the step 6.




















9. And this is what the menu bar looks like which you can open as usual. In next coming tutorial, we will see how to do more UI stuff. Hope this does good for a just beginner.



















Thursday, February 16, 2012

How to get CGRect from NSValue ?


CGRect a = CGRectMake(0, 0, 12, 12);
CGRect b = CGRectMake(0, 15, 13, 13);
NSArray *array=[[NSArray alloc]initWithObjects:[NSValue valueWithCGRect:a]

//Get CGRect from NSValue
CGRect sectionRect = [[array objectAtIndex:0] CGRectValue];



How to store CGRect in an Array or Dictionary ?

Here is the code snippet

CGRect a = CGRectMake(0, 0, 720, 465);
CGRect b = CGRectMake(0, 465, 720, 465);
NSArray *array=[[NSArray alloc]initWithObjects:[NSValue valueWithCGRect:a],[NSValue valueWithCGRect:b], nil];




Wednesday, February 15, 2012

iMac how to change brightness

Ok. This has nothing to DO with iOS coding but if you are using iMac and don't know how to fix your brightness. Here is how:

F14: Decrease Brightness
F15: Increase Brightness




How to create selector for UIButton.

Although selector can be created for many other GUI components. Here is the code


SEL buttonSelector =@selector(OpenOrCloseNavigationLayoutView:); 





NSAutoReleasePool in iOS 5

So we used to use NSAutoReleasePool prior to iOS 5 as following
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];  
      ..  
     code  
     ...  
      [pool release];  





With arrival of iOS 5, you can use it as following:
 @autoreleasepool {  
     // Code benefitting from a local autorelease pool.  
     [UIView beginAnimations:nil context:nil];  
     [UIView setAnimationDuration:0.5];  
     [UIView setAnimationRepeatCount:100];  
     view.transform = CGAffineTransformMakeScale(1.0, 1.0);  
     [UIView commitAnimations];  
   }  




How to create wiggle animation for your UIView ?

So you wondering about how to create the world famous wiggling action in your app.

Wiggling action is what happens when you long press on icons on your iPhone/iPad screen and they start dancing. Here is the code:

   CATransform3D transform = CATransform3DMakeRotation(0.08, 0, 0, 1.0);  
   CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];  
   animation.toValue = [NSValue valueWithCATransform3D:transform];  
   animation.autoreverses = YES;   
   animation.duration = 0.1;   
   animation.repeatCount = 10000;   
   animation.delegate=self;  
   [[self layer] addAnimation:animation forKey:@"wiggleAnimation"];  



How to combine 2 or more UIGesture ?

So, this is useful when you are trying to implement following(this is just one of the case, you may have some other scenario but this article basically tells you to combine UIGestures):

Following a long press you  move the a view around so you are basically implementing  UILongPressGestureRecognizer and UIPanGestureRecognizer. You have to write following delegate methods in your .m



 #pragma mark - Gesture Delegate Method  
 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer  
 {  
   return YES;  
 }  
 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer  
 {  
   return YES;  
 }  
 - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{  
   return YES;  
 }  





If you use following delegate methods, then you wont have to have discrete gestures(which is how it is by default), it will start looking for long gesture and pan gesture (simultaneously)without any break in between.

And ofcourse don't forget to add the protocol in your .h <UIGestureRecognizerDelegate>.

Back in Action

Ok.. I am back after a long break.  I have lots to write on this blog.. I was just busy with so many things in my life so I had to stop doing the blog. There are so many things I need to fix in this blog so that people can fully benefit from this blog.

I just checked the stats for this blog and it has been doing great despite the fact that I haven't posted for so many months.

We just bought a huge iMac for myself. Check this out. So now I can enjoy my work even more !!