Wednesday, April 27, 2011

How to check memory leaks in XCode 4 ?

You need to go to Product>Profile on the top menu of XCode 4 as shown in screenshot below.




























Then you will see following window, you can just choose Leaks and Press Profile button, it will start the Instrument and start tracking leaks and allocation.






































As soon as you press Profile, it will start Instrument and the simulator/device(You can change in the settings of the Instrument whether you want to run it on simulator or device) will start running the app.
You scroll through various pages on your app. While doing so,  if you view the red line in Leaks windows of Instrument as shown below then you have memory leak detected ! You can move the dotted line with slider to find out how many bytes leaked at what time in a small yellow pop up.































When you double click the red thick line of memory leak as shown  above , in the lower portion of the Instrument you will be able to see all the leaks and related info. If I want to find detailed info about a particular leak,  in this tutorial as you can see the blue highlighted line of leak, I am going to inspect about that leak hence I will just click the arrow which comes up in its address field.










This will refresh the window and tell you the details with  Responsible Caller column in the end of the table , it gives the specific method  name where the leaks has occurred. If you double click the row, it will open that corresponding .m file where that method has been implemented.


































Now you can see that the line is highlighted where the leak has occurred in the method of a .m file in the project.










 Hope this helps to someone new in fixing memory leaks !

Monday, April 11, 2011

Tutorial on UIGestureRecognizer

I am going to cover Gestures topic today.

We have 2 views on our ViewController , they toggle on the swipe gesture of the user.



You will need to define a view class with the gesture added to it as following


You will have to define a protocol in its header file to be able to talk to main controller class which we will implement below in the blog.

This is another view with another swipe gesture implemented on it.
 
Same as above class we will to create protocol in its header file as well to be able to talk to main view controller.














Now we have a view controller class, where above views are added as sub view.

Firstly , there is view 1 visible and view 2 is hidden.
User swipes to left, it will hide view 1 and  display view 2.
User swipes to right, it will hide view 2 again and display view 1.

You can the protocol methods implemented in this view controller class.






























You will have to include the class1 and class2 protocol in your view controller's header file as following:








You can download the code, to study the code more deeply.


Download Sample Code

How to get raw data from the Image ?





Now you can have all the pixel data in rawData. You can access it as following:








where offset goes from 0 to 4*w*h with an increment of 4.

Saturday, April 9, 2011

Recognize single and double tap on iPhone using UITapGestureRecognizer

If you have used elements like UIButton, UIImageView and you want to find out whether user tapped once or twice on it then you can do following and solve the problem very easily !

1. Create a subclass of UIButton or UIImageView whatever it is, in its implementation class you can define UITapGestureRecognizer methods like following:
























Then one of the following methods will be executed whenever a touch event is generated by user.You need to write these methods in the same file as above .













And your work is finished here now. You can just create an object of the class you have defined above and enjoy the single tap / double tap work like charm ... you dont need to code the hell out to recognise the single or double tap now !!














Tuesday, April 5, 2011

Difference between NSString: isEqualTo and NSString: compare

isEqualTo is used for comparing the value of string.

for e.g.

NSString *a=@"Reetu";
NSString *b=@"Mike";
NSString *c=@"Mike";


if([a isEqualTo:b]) -> It will return No;
if([c isEqualTo:b]) -> It will return YES;

compare is used comparing(generally for sorting the string) by lexical order(in dictionary which string will come first).

if([a compare:b]) -> It will return 1;
if([b compare:a]) -> It will return -1;

Where is Application Loader with XCode 4 ?

See yourself in screenshow below

Tuesday, March 29, 2011

Mac OSX Lion

I am going to discuss the features which you can benefit only in this version of Mac OS X i.e. Mac OSX Lion.

1.  Mac App Store



















2. Full Screen Apps: Now you can  create enriched user experience by handling the full screen view in a very friendly way using recently added features of NSApplication, NSWindow, and the NSWindowDelegate Protocol.
































3.  Aqua Theme with pop over feature like iPad, Overlay Scrollbars just like iPhone, iPad's scrollview's overlaying beautiful translucent scrollbar.Also the best part : Multi-Touch gestures and animations feature can be integrated in your mac apps now !!

4. AV Foundation: Do the changes to your audio/video input in real time !! Think about million possiblities it gives rise to.

5. Versions available just like SVN of your documents on your local machine itself ! How COOL !
Now I know what exact changes were done on what date on my document.

6. Auto Resume . If your restarts, then it will open in same state when it starts again .. Its already there in windows 7. I guess it doesnt excite me that much.

7. Sandboxing of apps on Mac just like iPhone OS.

8. File Accessibility management that simultaneous writes can be handled without error. :)

Thursday, March 24, 2011

How to add frameworks to your project in XCode 4 ?

See yourself in screenshot below.
Press the + button in Link Binary with Libraries section: It will open the list of available frameworks from where you can choose.

How to reject Binary of your app on App Store ?

1. Login into your iTunes Connect Account @ https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa


2. Click Manage your Application. It will take you the list of the applications present on App Store. Select the app you want to reject the binary of. You will need to view the detail of the application. Then you will see following screen as shown below:  On this screen,you need to click on Binary Details.

3. Then you  will see following screen, where you can just press Reject This Binary.
 4. DONE ! Your status of the application will change to Developer Rejected the Binary with red dot !


How to create provisioning file for distribution build of iphone/ipad application?

Log in into your Provisioning Portal. @http://developer.apple.com/ios/manage/overview/index.action

Press New Profile Button. Note that Under Provisioning(Left Side Menu), Distribution Tab is selected.



Select relevant app ID  you made for a specific app which you are going to sign with this provisioning file.


How to create App ID ? (It is also used for creating Bundle ID of the apps)