Pro Multithreading and Memory Management for IOS and OS X: With ARC, Grand Central Dispatch and Blocks by Kazuki Sakamoto & Tomohiko Furumoto
Author:Kazuki Sakamoto & Tomohiko Furumoto [Sakamoto, Kazuki & Furumoto, Tomohiko]
Language: eng
Format: epub
Tags: Computers, Programming, Apple Programming, Object Oriented
ISBN: 9781430241164
Publisher: Apress
Published: 2012-04-25T04:00:00+00:00
By the C++ compiler, it is converted to a source code calling the C function as follows.
struct MyClass cls;
__ZN7MyClass6methodEi(&cls, 10);
"this" is an instance of MyClass class (struct) itself. In addition, let's check an
instance method in Objective-C.
- (void) method:(int)arg
{
NSLog(@"%p %d\n", self, arg);
}
The same as for C++ methods, the Objective-C compiler converts the method to a C
function.
void _I_MyObject_method_(struct MyObject *self, SEL _cmd, int arg)
{
NSLog(@"%p %d\n", self, arg);
}
And the same as “this” in C++, “self” is passed as the first argument. Let’s see its caller as well.
MyObject *obj = [[MyObject alloc] init];
[obj method:10];
Using “-rewrite-objc option” for clang, we can see how it is converted:
MyObject *obj = objc_msgSend(
objc_getClass("MyObject"), sel_registerName("alloc"));
obj = objc_msgSend(obj, sel_registerName("init"));
objc_msgSend(obj, sel_registerName("method:"), 10);
The objc_msgSend function searches a pointer of the _I_MyObject_method_ function by the object and the method name. After that, it calls the function pointer, and the first argument “obj” is passed to the _I_MyObject_method_ function as its first argument “self”. As in C++, “self” is the object of the MyObject class itself.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12525)
Hello! Python by Anthony Briggs(9870)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9760)
The Mikado Method by Ola Ellnestam Daniel Brolund(9751)
Dependency Injection in .NET by Mark Seemann(9296)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8261)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7744)
Grails in Action by Glen Smith Peter Ledbrook(7670)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7520)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(6754)
Microservices with Go by Alexander Shuiskov(6522)
Practical Design Patterns for Java Developers by Miroslav Wengner(6419)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6397)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6382)
Angular Projects - Third Edition by Aristeidis Bampakos(5779)
The Art of Crafting User Stories by The Art of Crafting User Stories(5308)
NetSuite for Consultants - Second Edition by Peter Ries(5251)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5070)
Kotlin in Action by Dmitry Jemerov(5022)
