I've written a custom struct in a separate header file. It looks something like this
typedef struct RequestSpecifics {
BOOL includeMetaData;
BOOL includeVerboseData;
} RequestSpecifics;
Now I want to make a custom 'make' method, similar to the CoreLocation struct CLLocationCoordinate2 CLLocationCoordinate2DMake
method.
I've tried two different ways. While both ways give no errors in the .h file, I do get errors when I want to use the make method.
Method 1:
extern RequestSpecifics RequestSpecificsMake(BOOL includeMetaData, BOOL includeVerboseData);
Throws:
Apple Mach-O Linker
"_RequestSpecificsMake", referenced from:
Error Linker command failed with exit code 1 (use -v to see invocation)
Method 2:
extern RequestSpecifics RequestSpecificsMake(BOOL includeMetaData, BOOL includeVerboseData) {
RequestSpecifics specifics;
specifics.includeMetaData = includeMetaData;
specifics.includeVerboseData = includeVerboseData;
return specifics;
}
Throws:
Apple Mach-O Linker
Error Linker command failed with exit code 1 (use -v to see invocation)
Usage example:
RequestSpecificsMake(NO, NO)
I've checked all common solutions for the Apple Macho-Linker error but nothing seems to work or the solutions are not relevant.
So how do I correctly implement the 'make' method for a struct?