On Jan 22, 2013, at 8:12 PM, Jens Alfke j...@mooseyard.com wrote:
@interface SomeFictionalClassName
- (id) initWithManager: (Foo*)manager;
@end
That feels a bit dirty to me. I'd recommend using a protocol instead. As long
as the compiler has seen the method *somewhere*, it will consider it
On Jan 22, 2013, at 8:28 PM, Andy Lee ag...@mac.com wrote:
To be extra fail-safe, you might want to perform a cast to be sure the right
initWithManager: gets called:
if ([myClass conformsToProtocol:@protocol(MyProtocol)])
myObj = [(id MyProtocol)[myClass alloc] initWithManager:self];
On Jan 23, 2013, at 8:22 AM, Uli Kusterer witness.of.teacht...@gmx.net wrote:
@protocol UKCanInitWithManagerProtocol
-(id) initWithManager: (Foo*)inManager;
@end
...
if( [myClass respondsToSelector: @selector(initWithManager:)] )
myObj = [(idUKCanInitWithManagerProtocol)[myClass
to avoid the warning or otherwise fix it?
You need to #import a header file with an @interface declaration
for the 'initWithManager:' method.
The rule is that when the compiler sees a message send to a
receiver of type 'id' (which is the return type of 'alloc'), it
needs to have seen *some
on the initWithManager: statement (Obviously), how
to avoid the warning or otherwise fix it?
You could try declaring initWithManager: in a category on the class
visible only to your implementation code. (i.e. at the top of
your .m file)
The class name is passed in as a string and the class is formed from
On 21 Jan 2013, at 22:12, Jens Alfke wrote:
On Jan 21, 2013, at 10:14 AM, Dave d...@looktowindward.com wrote:
if (class_RespondsToSelector(myClass,@selector(initWithManager:)
== NO)
Off-topic: instead of using the Obj-C runtime’s C API, you can
express this as
if ([myClass
myObj = [[myClass alloc] performSelector(@selector(initWithManager:)
withObject:self];
Would this work?
You could do :
id myObj =[myClass alloc];
myObj = [myObj performSelector(@selector(initWithManager:) withObject:myObj];
___
Cocoa-dev
On 22 janv. 2013, at 18:34, Jean Suisse jean.li...@gmail.com wrote:
myObj = [[myClass alloc] performSelector(@selector(initWithManager:)
withObject:self];
Would this work?
You could do :
id myObj =[myClass alloc];
myObj = [myObj performSelector(@selector(initWithManager:)
]];
I get a warning on the initWithManager: statement (Obviously), how to avoid
the warning or otherwise fix it?
You could try declaring initWithManager: in a category on the class visible
only to your implementation code. (i.e. at the top of your .m file)
The class name is passed
On 22 Jan 2013, at 17:34, Jean Suisse wrote:
myObj = [[myClass alloc] performSelector(@selector
(initWithManager:) withObject:self];
Would this work?
You could do :
id myObj =[myClass alloc];
myObj = [myObj performSelector(@selector(initWithManager:)
withObject:myObj];
Thanks for
];
else
myObj = [[myClass alloc] initWithManager:sel]];
I get a warning on the initWithManager: statement (Obviously),
how to avoid the warning or otherwise fix it?
You could try declaring initWithManager: in a category on the
class visible only to your implementation code. (i.e. at the top
On Jan 22, 2013, at 9:24 AM, Dave d...@looktowindward.com wrote:
Ok, cool, thanks for that, I still have the same problem though when I call
the initWithManager.
Others answered this already. To recap: The compiler needs to see a declaration
of an -initWithManager: method before it parses
On 22 Jan 2013, at 18:26, Jens Alfke wrote:
On Jan 22, 2013, at 9:24 AM, Dave d...@looktowindward.com wrote:
Ok, cool, thanks for that, I still have the same problem though
when I call the initWithManager.
Others answered this already. To recap: The compiler needs to see a
declaration
On Jan 22, 2013, at 9:23 AM, Dave d...@looktowindward.com wrote:
That's wont help because myClass is a variable created from a String.
But it will help, because Quincey's suggestion is not contingent on the type of
the object that you send the message to. The compiler is merely asking that
On Jan 22, 2013, at 1:26 PM, Jens Alfke j...@mooseyard.com wrote:
On Jan 22, 2013, at 9:24 AM, Dave d...@looktowindward.com wrote:
Ok, cool, thanks for that, I still have the same problem though when I call
the initWithManager.
Others answered this already. To recap: The compiler needs
On Jan 22, 2013, at 9:23 AM, Dave d...@looktowindward.com wrote:
You could try declaring initWithManager: in a category on the class visible
only to your implementation code. (i.e. at the top of your .m file)
The class name is passed in as a string and the class is formed from that, so
I
On Jan 22, 2013, at 12:58 PM, Andy Lee ag...@mac.com wrote:
// Or this also works (protocol).
@protocol AvoidCompilerWarning
- (id)initWithArg:(id)arg;
@end
Really, a protocol is what you ought to be doing. Make a protocol with
-initWithManager: in it, and then make all the classes that
On Jan 22, 2013, at 2:19 PM, Charles Srstka cocoa...@charlessoft.com wrote:
On Jan 22, 2013, at 12:58 PM, Andy Lee ag...@mac.com wrote:
// Or this also works (protocol).
@protocol AvoidCompilerWarning
- (id)initWithArg:(id)arg;
@end
Really, a protocol is what you ought to be doing. Make
On Jan 22, 2013, at 1:28 PM, Andy Lee ag...@mac.com wrote:
On Jan 22, 2013, at 2:19 PM, Charles Srstka cocoa...@charlessoft.com wrote:
On Jan 22, 2013, at 12:58 PM, Andy Lee ag...@mac.com wrote:
// Or this also works (protocol).
@protocol AvoidCompilerWarning
- (id)initWithArg:(id)arg;
On Jan 22, 2013, at 10:15 AM, Dave d...@looktowindward.com wrote:
This has to work with classes that exist already as well as classes that
don't. If initWithManager is defined in the class in question knows what it
is being called like this, if not then it defaults to the regular NSObject
On 22 Jan 2013, at 21:27, Jens Alfke wrote:
On Jan 22, 2013, at 10:15 AM, Dave d...@looktowindward.com wrote:
This has to work with classes that exist already as well as
classes that don't. If initWithManager is defined in the class in
question knows what it is being called like this, if
Hi All,
I have the following code:
if (class_RespondsToSelector(myClass,@selector(initWithManager:) == NO)
myObj = [[myClass alloc] init];
else
myObj = [[myClass alloc] initWithManager:sel]];
I get a warning on the initWithManager: statement (Obviously), how to
avoid
a warning on the initWithManager: statement (Obviously), how to avoid
the warning or otherwise fix it?
What warning do you get? (Its not obvious from context).
--
David Duncan
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post
on the initWithManager: statement (Obviously), how to avoid
the warning or otherwise fix it?
Simple,
Write better code where you know the types you're dealing with ;).
Bob
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post
];
else
myObj = [[myClass alloc] initWithManager:sel]];
I get a warning on the initWithManager: statement (Obviously), how to avoid
the warning or otherwise fix it?
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post
On Jan 21, 2013, at 10:14 , Dave d...@looktowindward.com wrote:
myObj = [[myClass alloc] initWithManager:sel]];
I get a warning on the initWithManager: statement (Obviously), how to avoid
the warning or otherwise fix it?
You need to #import a header file with an @interface
At 6:14 PM + 1/21/13, Dave wrote:
if (class_RespondsToSelector(myClass,@selector(initWithManager:) == NO)
myObj = [[myClass alloc] init];
else
myObj = [[myClass alloc] initWithManager:sel]];
I get a warning on the initWithManager: statement (Obviously), how
to avoid
On Jan 21, 2013, at 10:14 AM, Dave d...@looktowindward.com wrote:
if (class_RespondsToSelector(myClass,@selector(initWithManager:) == NO)
Off-topic: instead of using the Obj-C runtime’s C API, you can express this as
if ([myClass instancesRespondToSelector: @selector(initWithManager:)]
28 matches
Mail list logo