How to manually create icns files using iconutil?

Here’s a script to convert a 1024×1024 png (named “Icon1024.png”) to the required icns file. Save it to a file called “CreateICNS.src” in the folder where your png file is then in terminal “cd” to the same folder and type “source CreateICNS.src” to call it: mkdir MyIcon.iconset sips -z 16 16 Icon1024.png –out MyIcon.iconset/icon_16x16.png sips … Read more

Changing my CALayer’s anchorPoint moves the view

I had the same problem. Brad Larson’s solution worked great even when the view is rotated. Here is his solution translated into code. -(void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view { CGPoint newPoint = CGPointMake(view.bounds.size.width * anchorPoint.x, view.bounds.size.height * anchorPoint.y); CGPoint oldPoint = CGPointMake(view.bounds.size.width * view.layer.anchorPoint.x, view.bounds.size.height * view.layer.anchorPoint.y); newPoint = CGPointApplyAffineTransform(newPoint, view.transform); oldPoint = CGPointApplyAffineTransform(oldPoint, view.transform); CGPoint position … Read more

Remove all whitespaces from NSString

stringByTrimmingCharactersInSet only removes characters from the beginning and the end of the string, not the ones in the middle. 1) If you need to remove only a given character (say the space character) from your string, use: [yourString stringByReplacingOccurrencesOfString:@” ” withString:@””] 2) If you really need to remove a set of characters (namely not only … Read more

Getting a list of files in a directory with a glob

You can achieve this pretty easily with the help of NSPredicate, like so: NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; NSFileManager *fm = [NSFileManager defaultManager]; NSArray *dirContents = [fm contentsOfDirectoryAtPath:bundleRoot error:nil]; NSPredicate *fltr = [NSPredicate predicateWithFormat:@”self ENDSWITH ‘.jpg'”]; NSArray *onlyJPGs = [dirContents filteredArrayUsingPredicate:fltr]; If you need to do it with NSURL instead it looks like this: … Read more

NSInvocation for Dummies?

According to Apple’s NSInvocation class reference: An NSInvocation is an Objective-C message rendered static, that is, it is an action turned into an object. And, in a little more detail: The concept of messages is central to the objective-c philosophy. Any time you call a method, or access a variable of some object, you are … Read more

Fix warning “Capturing [an object] strongly in this block is likely to lead to a retain cycle” in ARC-enabled code

Replying to myself: My understanding of the documentation says that using keyword block and setting the variable to nil after using it inside the block should be ok, but it still shows the warning. __block ASIHTTPRequest *request = [[ASIHTTPRequest alloc] initWithURL:… [request setCompletionBlock:^{ NSDictionary *jsonDictionary = [[CJSONDeserializer deserializer] deserialize:request.responseData error:nil]; request = nil; // …. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)