Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-06-2009, 12:39 AM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 1
Eric_Cartman is on a distinguished road
Default What is the different between [MyClass alloc] & [MyClass new]

Hi, this is my first post here Smiley

Assuming there is a class call "MyClass" which contain a method call "HelloWorld".

I see some example doing this:
MyClass* class = [ [MyClass alloc] init ];
[class HelloWorld];
[class release];

=================================
On another book I see this:

id class = [MyClass new];
[myclass HelloWorld];

========================================
My Question is...does the both of them work equally ?
One with "*" and one does not....one contain "release" and one does not...
which one of the two should I use ?
Eric_Cartman is offline   Reply With Quote
Old 10-14-2009, 02:10 AM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Location: Bhubaneswar(INDIA)
Posts: 39
ajitbiswal is on a distinguished road
Default

Quote:
Originally Posted by Eric_Cartman View Post
Hi, this is my first post here Smiley

Assuming there is a class call "MyClass" which contain a method call "HelloWorld".

I see some example doing this:
MyClass* class = [ [MyClass alloc] init ];
[class HelloWorld];
[class release];

=================================
On another book I see this:

id class = [MyClass new];
[myclass HelloWorld];

========================================
My Question is...does the both of them work equally ?
One with "*" and one does not....one contain "release" and one does not...
which one of the two should I use ?
new=Allocates a new instance of the receiving class, sends it an init message, and returns the initialized object.This method is a combination of alloc and init.

alloc=Returns a new instance of the receiving class.
ajitbiswal is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 460
13 members and 447 guests
Domele, Duncan C, Feldspar, MacBook MH, Objective Zero, patapple, peterwilli, pipposanta, PixelInteractive, Punkjumper, SLIC, taylor202, Today's Posts
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,694
Threads: 94,137
Posts: 402,950
Top Poster: BrianSlick (7,990)
Welcome to our newest member, peterwilli
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:04 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0