Showing posts with label xcode. Show all posts
Showing posts with label xcode. Show all posts

Wednesday, March 14, 2012

How and when to use NSAssert ?

If you want to write a code

1. Which is easier to debug(for you as well as others :P)
2. is a standard piece of code

Don't forget to include NSAssert in your code.

Here is an example of how you can use it:

//Assertion Code  
NSAssert((count <= 4)&&(count >= 3),@"colorString components count should be in range(3,5)");


Whenever the condition given above becomes false, it raises NSInternalInconsistencyException along with description message.
Result in Console:

*** Assertion failure in +[ColorClass colorWithComponent:], /Users/mac/Desktop/ChartLib/Lib Files/Colors/ColorClass.m:66
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'colorString components count should be in range(3,5)'



Note:Please make sure that your XCode should be running in debug mode.

Wednesday, June 29, 2011

Integrating C++ files with Objective-C (tips)

This trick will be helpful for people who are trying to embed Opengl ES code in their iPhone project.
One way to let your compiler know that you will be using mix of C++ and objective-C will be to convert the extension of all .m files to .mm as discussed in one the previous post(LINK) but there is another way if you don't want to change all the extensions  !


In your project Settings, Under Build Settings > GCC 4.2- Language
Change the "Compile Source As" value to "Objective-C++"
































It will let you compile the code without changing the extensions of all the files.

I found this wonderful tip from Pete Cole blog. LINK

Wednesday, February 9, 2011

How to change _MyCompanyName_ in header of the XCode project files

If you are wondering how to change the username and company name of the header of the files being created in your XCode then you are at the right place !

//
//  PrintingAppDelegate.h
//  Printing
//
//  Created by ABC on 10/02/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

It looks like above and now I want to change __MyCompanyName__ to say "Reetu Inc." then I just need to do following step and hence all the new files I create in the project will have updated name and company name.

Steps:
1. Go to XCode > Project > Edit Project Settings




























2.  In Project Setting window, Select General Tab as shown below then go to Organization Name: as highlighted area in the screenshot below. Change it to whatever name you want. I have changed it to Reetu Inc.






































3. Now when you will create a new file, it will display the updated company name !

New file in Xcode with updated _MyCompanyName_