4_Passing and returning pointers with functions

Passing pointers

Passing an argument by reference or by address both enable the passed argument to be changed in the calling function by the called function.

Objective-C programming language allows you to pass a pointer to a function.

To do so, simply declare the function parameter as a pointer type.

in the prefuse example we pass an unsigned long pointer to a function and change the value inside the function which reflects back in the calling function:

Returning pointers

Objective-C allows a function to return a pointer to local variable, static variable and dynamically allocated memory as well.

Example Returning pointers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: