Say I have the following:
@interface MyClass : NSObject { NSString* _foobar; }
@property (nonatomic, retain) NSString* foobar;
@end
@implementation MyClass
@dynamic foobar;
- (void) setFoobar:(NSString*)fbSet; { [_foobar release]; _foobar = [fbSet retain]; }
- (NSString*) foobar; { return _foobar; }
@end
Then:
MyClass* mcInst = [[[M...
I've seen a number of strategies for declaring semi-private methods in Objective-C, but there does not seem to be a way to make a truly private method. I accept that. But, why is this so? Every explanation I've essentially says, "you can't do it, but here's a close approximation."
There are a number of keywords applied to ivars (memb...
I'm trying to implement a basic object-oriented ANSI C runtime and using Objective-C as a guide.
They're seems to be three parts. A Class Description, Class Interface, and Class Implementation. In order for the Class Interface to be instantiated, the familiar method of using the Class object to instantiate one's object can only happen i...
Since class_poseAs(..) is deprecated in Objective-C 2.0, I need to find another way to change the class of an object at runtime. I've found I can change an object's class using object_setClass(..). My problem now is finding all the current instances of a given class in order to update them.
A solution would be to maintain a global dicti...
Looking at the definition for "initialize":
+ (void)initialize
Discussion
The runtime sends initialize to each class in a program exactly one time just before the class, or any class that inherits from it, is sent its first message from within the program. (Thus the method may never be invoked if the class is not used.) The runtime s...
I am trying to get a string name of a class from the class object itself.
// For instance
[NSArray className]; // @"NSArray"
I have found object_getClassName(id obj) but that requires an instance be passed to it, and in my case that is needless work.
So how can I get a string from a class object, and not an instance?
...
Example: I have a view controller and get rid of it. But there's still an variable holding it's memory address. Accessing that results in EXEC_BAD_ACCESS. Of course. But: Is there any way to check if that variable is still valid? i.e. if it's still pointing to something that exists in memory?
...
I was wondering if anyone knew how iSimulate automatically registers/hooks itself into a debugged iDevice application? It's as simple as including the static library (and a couple of frameworks) and it just works. There are no methods or functions to call. How is this possible?
...
Hi there,
I want to add at-runtime some behaviour to some controls:
Suppose we have a UISwitch. The next thing I want to do, is reading an UIML file and add some action to the UISwitch. This action is described in the UIML document. UIML is an XML document.
Suppose we have an interface with 1 switch and 1 textfield. When changing the ...
I'm a somewhat competent ruby programmer. Yesterday I decided to finally try my hand with Apple's Cocoa frameworks. Help me see things the ObjC way?
I'm trying to get my head around objc_allocateClassPair and objc_registerClassPair. My goal is to dynamically generate a few classes and then be able to use them as I would any other class....
I know that I can forward messages to instances of a class using -forwardInvocation:. Can I do the same for messages sent to a class object (as in +forwardInvocation:)?
...
I have specific formulas that I'd like to write (in Objective-C perhaps) and integrate with Numbers'09 of Apple's iWork suite in iPad and wonder if there is such a way to do so?
...
Hi,
First of all, I want to be clear that I'm not talking about defining a protocol, and that I understand the concept of
@protocol someprotocol
- (void)method;
@end
I know that the Obj-C runtime allows creation of classes at RUNTIME, as well as its ivars and methods. Also available for creation are SEL-s. I think I'm just missing s...
I'd like to have a reusable logging method or function that spits out the name of the method it's called from. Example:
- (void)exampleMethod {
CustomLog(); //Outputs "exampleMethod"
}
...
Is there anyway to load an objective c script at runtime, and run it against the classes/methods/objects/functions in the current iPhone app?
MAJOR NOTE: The major reason I'd like to do this is to allow me to rapidly prototype an application, and then, after I'm done a major prototyping phase, take the scripts I was writing and compile...
I am trying to compile a library originally written for Cocoa. Things are good until it looks for the function marg_setValue(). It says there is a syntax error before char in
marg_setValue(argumentList,argumentOffset,char,(char)lua_toboolean(state,luaArgument));
(it's talking about the third argument, not (char) )
I am trying to port...
I have the following method:
(void)makeString:(NSString *)str1,... {
va_list strings;
NSString *innerText = [[NSString alloc] init];
NSString *tmpStr = [[NSString alloc] init];
if (str1) {
va_start(strings, str1);
while (tmpStr = va_arg(strings, id)) {
innerText = [innerText stringByAppend...
Can I, in the GNU Objective-C runtime, attach semi-arbitrary pieces of data to instance variables?
Challenge:
I'm currently working on a kind of Cocoa workalike for Linux, as a sort of pet project. (Please, let's not get sidetracked by all the "use GNUStep" stuff. I know about it, but it doesn't suit my needs. Moving on…) For this purp...
As far as I know, it's a pointer to the superclass. It's hard-wired with the superclass, and not dynamically figured out at runtime. Would like to know it more in detail...
Anyone?
...
I am changing the class of some objects using object_setClass(id object, Class cls). I am changing the class to a subclass of the original class. Then I set some properties that are only defined on the subclass, and things seem to work fine.
I was a bit surprised that this worked, because object_setClass, as far as I understand, doesn't...