Tuesday, November 8, 2011
dyld: Symbol not found: __NSConcreteGlobalBlock
This error occurs in Xcode 4.2 when building for pre iOS 4.0. The fix: Add '-weak_library /usr/lib/libSystem.B.dylib' to Build Settings->Linking->Other Link Flags.
Wednesday, February 23, 2011
NSStringToUIColor with alpha
+(UIColor*)toUIColor:(NSString*)hexColorString {
unsigned int c;
if ([hexColorString characterAtIndex:0] == '#') {
[[NSScanner scannerWithString:[hexColorString substringFromIndex:1]] scanHexInt:&c];
} else {
[[NSScanner scannerWithString:hexColorString] scanHexInt:&c];
}
if([hexColorString length] > 7) {
return [UIColor colorWithRed:((c & 0xff000000) >> 24)/255.0 green:((c & 0xff0000) >> 16)/255.0 blue:((c & 0xff00) >> 8)/255.0 alpha:(c & 0xff)/255.0];
}
return [UIColor colorWithRed:((c & 0xff0000) >> 16)/255.0 green:((c & 0xff00) >> 8)/255.0 blue:(c & 0xff)/255.0 alpha:1.0];
}
[Color toUIColor:#001122];
[Color toUIColor:#001122aa];
Elapsed time
NSDate *startTime = [NSDate date];
...
NSLog(@"Elapsed time: %f", -[startTime timeIntervalSinceNow]);
Saturday, February 19, 2011
Recursively removing XCode build directories before SVN import, commit, or add
In Terminal, cd to the repository directory to be checked into SVN
rm -rf `find . -type d -name build`
This will remove all the build directories in all the sub directories e.g. when trunk contains multiple projects.
rm -rf `find . -type d -name build`
This will remove all the build directories in all the sub directories e.g. when trunk contains multiple projects.
Checking iOS version at runtime
@interface DeviceUtil : NSObject {
}
+(BOOL)osVersionSupported:(NSString*)version;
@end
#import "DeviceUtil.h"
@implementation DeviceUtil
// e.g. [DeviceUtil osVersionSupported:@"4.1"]
+(BOOL)osVersionSupported:(NSString*)version {
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
BOOL osVersionSupported = ([currSysVer
compare:version
options:NSNumericSearch] != NSOrderedAscending);
return osVersionSupported;
}
@end
#warning #error
#warning
The directive #warning is similar to #error, however the preprocessor doesn’t stop when it finds this directive, it simply displays the message to the console and keeps on with the task at hand. One common use of #warning is to display information regarding deprecated code:
#warning : This method is deprecated, use someNewMethod instead
#error
When the preprocessor runs into the #error directive, it will write an error to the console and generate a compile time error. You can also include a text string which is displayed as an error message.
#error : Change this value to your Flickr key
NSString* const FlickrAPIKey = @"your-key-here";
See full article
The directive #warning is similar to #error, however the preprocessor doesn’t stop when it finds this directive, it simply displays the message to the console and keeps on with the task at hand. One common use of #warning is to display information regarding deprecated code:
#warning : This method is deprecated, use someNewMethod instead
#error
When the preprocessor runs into the #error directive, it will write an error to the console and generate a compile time error. You can also include a text string which is displayed as an error message.
#error : Change this value to your Flickr key
NSString* const FlickrAPIKey = @"your-key-here";
See full article
Sunday, November 7, 2010
Linking .a library with XCode
Open the Info page for your Target (right-click on the target's node and choose Get Info) and locate the Library Search Path option. It (possibly amongst other folders) contains a reference to the folder you just dragged the libRemObjectsSDK.a from, such as "/Developer/RemObjects Software/Bin/iOS/Debug-iphoneos". To make switching between different platforms and configurations easier, select Configuration: All Configurations at the top of the dialog, and adjust the Library Search Path to replace "Debug-iphoneos" (or whatever other configuration/combination it currently shows) with "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)", so that the full folder name looks something like:
/Developer/RemObjects Software/Bin/iOS/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
This way, Xcode will automatically pick the right version of libRemObjectsSDK.a or libDataAbstract.a, regardless of whether you build Debug or Release, or whether you are working with the Simulator or on the real device.
See full article
/Developer/RemObjects Software/Bin/iOS/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
This way, Xcode will automatically pick the right version of libRemObjectsSDK.a or libDataAbstract.a, regardless of whether you build Debug or Release, or whether you are working with the Simulator or on the real device.
See full article
Subscribe to:
Posts (Atom)