NSURL

September 7, 2009

Use UTF8 encoding while creating NSRUL from NSString from following function

- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding

Otherwise NSURL will not be valid.

Final Touch!!!

September 4, 2009

Giving final touch on my 3 iPhone app. Most of them are game. I think people will like it. All of them are based on iPhone native UIKIt. In my opinion there is a marginal  line between UIKIT based game and OpenGL game. Hope will explain it in some day. Mind it, you can do most of 2D game by native API, you don’t need OpenGL access. But some case you have to use it.

iPhone Memory Management

August 31, 2009

May be this is the most hot and cracking part on iPhone development. Most of the dev face lot lot of time this issue. This is not a issue only for iPhone but also true for all other development platform. In my opinion, apple gave us a very nice and easy memory management system. You may not agree with me but I believe it’s true. Let me explain why.

First of all, consider C++. you have to allocate memory by your self and have to free also. So, HW access in your hand and have to maintain lot of factor. I think some programmer love overloading new() and delete() function for better memory management  system, but overloading new() or delete() is not childish thing. You have to have all low level knowledge like HW locking and thread safety issue. Anyway, I’m not here to tell about new() and delete(), I want to talk about apple memory management system. 

This is a ownership basis thing. Like: if you acquire something explicitly then you have to leave it explicitly. So, question is what is explicitly?

  1. When you call alloc function. Like: NSMutableArray* myArray = [[NSMutableArray alloc] init];
  2. When you use retain. Like: NSArray* holdingArray = [[NSArray array] retain];
  3. When you copy something. Like: NSArray* shallowArray = [otherArray copy];

These the case when you have to have call the release. So, it’s simple!!!! One of the most beautiful thing is the you can send message to a nil object. It will not mind but you can’t send message to a freed object. It will mind a lot ;) .

UV in iPhone native

August 20, 2009

You can change the pixel rectangle or part of image  by defining  layer.contentsRect. It’s like UV cut.

 

very handy links

February 8, 2009

http://code.google.com/p/chipmunk-physics/

http://code.google.com/p/cocos2d-iphone/wiki/GamesUsingCocos2d

Cool!!!

September 23, 2008

Take a look:

__init__ methods are optional, but when you define one, you must remember to explicitly call the ancestor’s __init__ method (if it defines one). This is more generally true: whenever a descendant wants to extend the behavior of the ancestor, the descendant method must explicitly call the ancestor method at the proper time, with the proper arguments.

About lambda

September 14, 2008

So-called lambda functions can be used anywhere a function is required as in-line function in C++.

def f(x):
return x*2
f(4)

We can replace this function by:
g = lambda x: x*2
g(4)

Same!!!!!!

  1. type
  2. str
  3. dir

The type Function

  • The type function returns the datatype of any arbitrary object.
  • type(1) — > <type ‘int’>.

The str Function

  • The str coerces data into a string.
  • Every datatype can be coerced into a string.
  • str(1) — > ’1′.

Introducing dir

  • dir returns a list of the attributes and methods of any object: modules, functions, strings, lists, dictionaries… pretty much anything.

Introducing callable

  • the callable function takes any object and returns True if the object can be called, or False otherwise.

Two special command.

import __builtin__
dir(__builtin__)

Data type

September 11, 2008

Python has three native data types:
1. Dictionary.
2. List.
3. Tuples.

Dictionary

  • Defining a Dictionary: d = {“server”:”mpilgrim”, “database”:”master”} — you create a new dictionary with two elements and assign it to the variable d. Each element is a key-value pair, and the whole set of elements is enclosed in curly braces
  • Dictionary Keys Are Case-Sensitive.
  • You mis Datatypes in a Dictionary.

List

  • Defining a List : li = ["a", "b", "mpilgrim", "z", "example"] —- you define a list of five elements. Note that they retain their original order. This is not an accident. A list is an ordered set of elements enclosed in square brackets.
  • Negative List Indices is possible.
  • There many other operation like Slicing a List, Shorthanding etc is possible.

Tuples

  • A tuple is an immutable list. A tuple can not be changed in any way once it is created.
  • Defining a tuple: t = (“a”, “b”, “mpilgrim”, “z”, “example”) — A tuple is defined in the same way as a list, except that the whole set of elements is enclosed in parentheses instead of square brackets.
  • Tuples Have No Methods.
  • You can, however, use in to see if an element exists in the tuple.
Follow

Get every new post delivered to your Inbox.