Questions tagged [objective-c-runtime]

The Objective-C runtime is a runtime support library provided with an implementation of the Objective-C language. Its API allows dynamically creating and configuring classes at runtime, as well as introspecting existing classes, methods, properties, and method implementations.

Use this tag for questions that involve interacting with the Objective-C runtime. This includes fundamental methods of NSObject, <NSObject>, and NSProxy, as well as the API exposed by the files in <objc/> such as <objc/objc-runtime.h>.

Very few Objective-C development tasks require interacting with the runtime:

  • Introspecting the runtime environment, for example to produce a live class browser or graph the relationships between classes or objects at runtime.
  • Creating a proxy object to interact with the message forwarding machinery.
  • Dynamically creating classes and methods at runtime, for example, to support a scripting interface.
  • Optimization hacks for repeated message sends, such as hoisting the method lookup out of the loop and calling the implementing function directly.
  • Writing an application without using objective-c, such as C or C++

Many of these topics have been thoroughly addressed in blog form by Mike Ash in his Friday Q&A series of blog posts.

Related tags that might be more appropriate for your question:

  • Use for questions about the language rather than its runtime, including problems with reference counting.
  • Use or for problems with the Xcode IDE.
  • Use or for problems with these collections of Objective-C APIs.
626 questions
0
votes
1 answer

Destroying self from within self

I have an Objective-C class whose instances can detect when they are no longer needed and destroy themselves, but I am looking for a safe way to trigger an object's self-destruction from within the object itself, without somehow "destroying the…
Ephemera
  • 8,672
  • 8
  • 44
  • 84
0
votes
1 answer

Find release/debug mode in runtime?

Possible Duplicate: Different code / config in Release & Debug build (Obj-C) Is there a way to find whether application is running in release or debug mode in objetive-c?
Salil
  • 375
  • 1
  • 5
  • 14
0
votes
1 answer

Legacy runtime and re-compiling inherited classes upon changing ivar layout

While reading the Objective-C Runtime Guide, I came across the following statements: In the legacy runtime, if you change the layout of instance variables in a class, you must recompile classes that inherit from it. In the modern runtime, if you…
Whoami
  • 13,930
  • 19
  • 84
  • 140
0
votes
2 answers

What is the need for selectors?

Possible Duplicate: Are selectors in Objective-C just another way to send a message to an object? I've read Apple's documentation about selectors, but I still don't understand why there is a need for them. As far as I can understand, selectors…
mskw
  • 10,063
  • 9
  • 42
  • 64
0
votes
2 answers

Does a setter also "reset" an associated object?

While getting into a nice long argument over memory locations vs pointers vs associated objects, we stumbled across a little bit of a headache: While setters may set the memory address of passed objects equal to each other, does said passed object,…
CodaFi
  • 43,043
  • 8
  • 107
  • 153
0
votes
1 answer

Objective-C runtime issue setting object for NSMutableDictionary

I am coding a fairly complex system that uses a lot of metadata to manage dynamic objects. I am using various objective-c runtime features. I want to add stuff to mutable dictionaries which are properties within various classes. I want to do this…
whatdoesitallmean
  • 1,586
  • 3
  • 18
  • 40
0
votes
2 answers

getting return value type of an instance method in runtime

I want get the return value class of an instance in runtime. The thing it's that I have a SEL type var where I store a selector. I have a variable named id _instance that points to an instance that I know it performs the selector. Before perform the…
Jpellat
  • 907
  • 7
  • 29
0
votes
1 answer

If a reference is not pointing to any instance, why can the instance method still be invoked?

Possible Duplicate: Sending a message to nil? If a reference to NSMutableArray is not pointing to any object at all, because none was instantiated, why can the instance method still be invoked without any run-time error? NSMutableArray *foo =…
Jeremy L
  • 3,770
  • 6
  • 41
  • 62
-1
votes
2 answers

Why should I not use object_setIvar to set properties

I have a dictionary containing data for user from a REST endpoint. Here is my user class #import @interface User : NSObject @property (strong, nonatomic) NSString *uid; @property (strong, nonatomic) NSString…
mmohiudd
  • 310
  • 2
  • 10
-1
votes
2 answers

Is there a way to get the factory instance of a class?

I would like to use the Objective-C runtime to call objc_msgSend() on a factory object and I need to build its arguments. I would like to specify its first argument using the factory instance as a compiler would. Is there a way to obtain the…
ctpenrose
  • 1,467
  • 2
  • 18
  • 28
-1
votes
2 answers

OC @property with block in category

excuse me. I want to use block as my property in category to change my code style as follows, but there is something wrong and I don't know why. Here is my code : ``` typedef NSString* (^MethodreplacingRangeWithString)(NSRange range,NSString *…
-1
votes
2 answers

Objective C - Method Definition not in @implementation context

My Code: #import -(NSString *) Fibonacci:(int) number{ //Fibonacci Calculations } int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Fibonacci Output: %@",…
-1
votes
1 answer

Unity Project Convert in iOS

I want to convert my iOS project to Unity. Kudan Framework is used in Unity project. It is displaying two errors in XCode: Error verifying license key for bundleID: com.bundleid.app error: (null) API key not valid
-1
votes
2 answers

Is it possible to get the declaration object name using runtime(objective-c)?

guys I am just interested in to get the declaration object name; what I mean: NSString *myObjectString = @"some string"; //some code //and in the end I want to get something like that: NSString *myOName = @"myobjectstring"; Thanks in advance;
O.Daniel
  • 123
  • 12
-1
votes
1 answer

How can I call a method on and Ivar

I have some code which gives me an Ivar. // written some code so now I have the following Ivar Ivar ivar = i_have_an_ivar; I can get the type of this Ivar by calling ivar_getTypeEncoding method so I know what type is this Ivar. Now I want to call a…
g.revolution
  • 11,962
  • 23
  • 81
  • 107
1 2 3
41
42