Thursday 24 March 2011

Conversions in objective C

 These are some conversions which an objective C developer often needs while writing code.

NSString to Char * -
NSString *testString = @"Testing"; 
char *testCharP; 
testCharP = (char*)[testString cStringUsingEncoding:NSUTF8StringEncoding];
Char * to NSString -
const char *testCharP = "Testing"; 
NSString *testString;
testString = [NSString stringWithUTF8String:testCharP]; 
NSData to NSString -
NSString* Str = [[NSString alloc] initWithData:tempData
                                         encoding:NSUTF8StringEncoding];
if data is NULL terminated - 
NSString* Str = [NSString stringWithUTF8String:[tempData bytes]];



 

Monday 14 March 2011

Xcode shortcuts

Comment Code -
-------------------------
Alt + /      or    Command + /

Switch Between .h & .m
-------------------------------
Command+Windows+Up-Arrow   or   Command+Option+Up-Arrow

Short API Documentation -
----------------------------------
Windows+Double-click or Command+Double-click

BookMark -
--------------
Alt+D or Control+D 

Go TO Bookmark -
------------------------
Alt+4 or Control+4

Zoom Editor-
----------------
Alt+Shift+E or Command+Shift+E

Indentation of Code -
---------------------------
Alt+] (Right) or Command+]
Alt+[ (Left)   or Command+[

Key bindings in Xcode -
-------------------------------
From the Xcode menu choose Preferences
Go to Tab Key Bindings
Check key Bindings Sets:"Xcode Default"
Create a Duplicate of all the default setting by clicking Duplicate button in case you have to revert it.
Click on  Actions in the list you want to change.

Enter the new key combination you want.
Click Ok to save your changes
Open Console -
-------------------
Alt+Shift+R or Command+Shift+R

Open Debugger-
-------------------
Alt+Shift+Y or Command+Shift+Y

Build Results -
-------------------
Alt+Shift+B


Jump to a Line -
----------------------
Alt + L



Wednesday 2 March 2011

Removing invisible breakpoints in xcode debugger

There are times when your debugger stuck at invisible breakpoints.To solve this issue just run the application and open the console of xcode , wait for the breakpoint to hit.Then enter the following command in console after "[gdb]" prompt.
  • clear

You will get confirmation like this "Deleted breakpoint 8" where 8 is the number of breakpoint deleted.
You can see your all breakpoints by this command
  • info breakpoints

Tuesday 1 March 2011

How to open and block ports in mac

This is my first post.
These commands are useful when you work on  your i-phone project in simulator for checking connection issues like blocking  a port in mac to check how you application will behave if network is unavailable to your app.

For blocking a port -
sudo ipfw add 9060 deny dst-port 5060 via en0

where 5060 is the port and 9060 is the id.

For unblocking a port -
 sudo ipfw del 9060

 where 9060 is the id you used to block port 5060.