Tagged Questions
3
votes
2answers
87 views
Unused parameter warning
I am getting "unused parameter 'testString'" warning from following code. But I am using testString to log. So how come it is unused ?
- (void)getString:(NSString *)testString {
...
0
votes
0answers
22 views
static library - check flag
I am not sure if there is a solution for this. Most likely there is I just don't know about it.
I have a static library that I use for many projects. Most of the time I am in DEV mode but once in a ...
0
votes
5answers
119 views
how to call a variable of another class without using objects or class methods?
In my app, there is a constant in a common class which defined as
#define IMG_INIT_URL @"http://www.xxxx/index.php"
Now i have a requirement of change it as a variable.But my problem is that i ...
0
votes
3answers
176 views
iOS Writing Macro detect 3.5 inch or 4 inch display [duplicate]
I am trying to write a macro to determine the device is 3.5 inch or 4 inch. Some thing similar below.
#define IOS_OLDER_THAN_6 ( [ [ [ UIDevice currentDevice ] systemVersion ] floatValue ] < ...
0
votes
0answers
52 views
Macro called in header generating “ Expected identifier or '(' ”
When the CGRectDivideWithPadding macro is called like this in the .h file:
CG_INLINE
void CGRectDivideWithPadding(CGRect rect, CGRect *slicePtr, CGRect *remainderPtr, CGFloat sliceAmount, CGFloat ...
1
vote
0answers
68 views
Preprocessor target checking
I wanna use preprocessor commands to test which target i'm compiling for.
Every egs i read told to do that :
-Add a preprocessor macro in my target.
-Do this :
#ifdef TARGET_NAME_MACRO
...
1
vote
1answer
62 views
Objective-C accessor template
I've been working on a rewrite of my model layer to use across several existing apps. The existing codebase is dated and I'd like to generalize my approach to lend to easier extension in the future ...
0
votes
2answers
66 views
How to pass the result of a function as a Macro variable?
Say I've set up a macro expansion as follows...
#define WARN_START @"DANGER"
#define WARN_RESET @"THE COAST IS CLEAR"
#define WARN(x) WARN_START x WARN_RESET
INPUT WARN(@"*** Your boss is coming. ...
0
votes
1answer
52 views
objective c macro not working [duplicate]
The following macro is giving me a parse error. cant see whats wrong here.
#define adjust(tag, x, y) if (self.tag==tag) { origin.x += x; origin.y += y; return origin; }
....
adjust(20, 28, 265)
...
2
votes
3answers
93 views
Creating a macro to perform default init
I have a lot of methods that repeat this simple boilerplate:
- (id)myObject {
if(!_myObject) {
self.myObject = [_myObject.class new];
}
return _myObject;
}
So I want to replace ...
0
votes
2answers
80 views
An Xcode macro for creating property setters
I have a class with a number of properties. When each property is set I need to update the UI of my application. The setters look something like this:
@synthesize trackHighlightColour = ...
0
votes
4answers
210 views
Objective c macro that checks the device [duplicate]
I need a macro that determines whether the device is an iPhone 4, or an iPhone 5. I was told that there is a macro that can do this. Does anyone know what it is or where I can find it? Thanks for the ...
1
vote
2answers
189 views
define a macro to replace code
I'm using TestFlight and I've got this macro to replace NSLog the the TestFlight remote logging equivalent.
#define NSLog(__FORMAT__, ...) TFLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, ...
0
votes
1answer
91 views
Weird issue with Macros and ARC
OK, so here's my issue...
My Macro definitions
#define DRK_INIT(X) -(id)init \
{ \
self = [super init]; \
if (self) { \
X \
} \
return self; \
}
#define DRK_DEALLOC(X) -(void)dealloc \
{ \
X \
...
0
votes
5answers
274 views
How can I write a 'clamp' / 'clip' / 'bound' macro for returning a value in a given range? [closed]
I often find myself writing some thing like
int computedValue = ...;
return MAX(0, MIN(5, computedValue));
I'm sure there is some better way to write this in regards to readability and pitfalls ...