Re: clean up code (sorry for being stupid)
Re: clean up code (sorry for being stupid)
- Subject: Re: clean up code (sorry for being stupid)
- From: Ondra Cada <email@hidden>
- Date: Wed, 22 Aug 2001 10:09:41 +0200
planetexpress,
>
>>>>> email@hidden (p) wrote at Wed, 22 Aug 2001 09:08:31 +0200:
p> Controller.m is using a single construct like (is it a class or method or
p> something?) This is wired to a button, of course.
p>
p> @implementation
This begins implementation of a class
p> - (IBAction)click:(id) sender
p> {
This is a method.
p> .... (about 500 lines of Objective-C)
500? Some cleaning up seems to be in order ;)
p> }
Here the method ends.
p> @end
End of the class implementation.
p> The program is running fine, howevever I'd like to clean up my code a
p> little to avoid redundancy. So I want to declare some functions with
p> arguments and return values. Unfortunately all my tries to declare a
p> function here is driving the preprocessor nuts... :-/ Is it possible to
p> declare a function inside the construct above? Or do I need to declare
p> functions externally? Could someone post a little snippet to show me the
p> right syntax?
As I guess the syntax cleanly indicates, the methods
-anything { ... }
+anything { ... }
are more or less functions (they are, in fact, quite plain functions, which
are stored into some tables automatically and with some invisible arguments
added). Therefore
-method {
...
void fnc(void) { ... }
...
}
would be the very same nonsense as
void fnca(void) {
...
void fncb(void) { ... }
...
}
OTOH, the following pattern works quite well:
static void fnca(void) { ... }
@implementation ...
-internal_method { ... }
static void fncb(void) { ... }
-method {
...
fnca();
[self internalMethod];
fncb();
...
}
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc