Tag: objective c

How do I create a Cocoa window programmatically?

My Cocoa app needs some small dynamically generated windows. How can I programmatically create Cocoa windows at runtime? This is my non-working attempt so far. I see no result whatsoever. NSRect frame = NSMakeRect(0, 0, 200, 200); NSUInteger styleMask = NSBorderlessWindowMask; NSRect rect = [NSWindow contentRectForFrameRect:frame styleMask:styleMask]; NSWindow * window = [[NSWindow alloc] initWithContentRect:rect styleMask:styleMask […]

UIProgressView and Custom Track and Progress Images (iOS 5 properties)

I am experimenting with some new properties in iOS 5 regarding UIProgressView. They are: @property(nonatomic, retain) UIImage *progressImage; @property(nonatomic, retain) UIImage *trackImage; These new properties enable the customisation of the “progress” and the “track” image, so that you can make fancy progress bars without having to roll-your-own. I however cannot understand how Apple “stretches” the […]

Storing Blocks in an Array

In Objective-C, I know that blocks are considered objects, so I was wondering if it was possible to store them in an array. This begs the question, are blocks first class objects or are they just treated like objects for the sake of passing them between objects? If they are first class objects, then shouldn’t […]

What happens to SDWebImage Cached Images in my app when the image file on the server changes?

I am using the SDWebImage library to cache web images in my app: https://github.com/rs/SDWebImage/blob/master/README.md Current Usage: [imageView setImageWithURL:[NSURL URLWithString:profilePictureUrl] placeholderImage:[UIImage imageNamed:@”placeholder.png”]]; My question is what happens once the image has been cached and then a couple of days later that image file on the server has been updated with a new image? At the moment […]

NSPredicate case-insensitive matching on to-many relationship

I am implementing a search field where the user can type in a string to filter the items displayed in a view. Each object being displayed has a keywords to-many relationship, and I would like to be able to filter the objects based on their keywords. Each keyword object has a name property, so I’ve […]

Make a two-digit string from a single-digit integer

How can I have a two-digit integer in a a string, even if the integer is less than 10? [NSString stringWithFormat:@”%d”, 1] //should be @”01″

Objective-C: init vs initialize

In Objective-C, what is the difference between the init method (i.e. the designated initializer for a class) and the initialize method? What initialization code should be put in each?

Objective-C: Asynchronously populate UITableView – how to do this?

I can’t seem to find any info on this question, so I thought I’d ask the community. Basically, I have a UITableView and I want to show an activity indicator while its data is loading from my server. Here is some example code of what I’m trying to do (I’m using ASIHttpRequest). //self.listData = [[NSArray […]

Fast blur on iOS

I’m running into trouble trying to blur part of the screen in my iOS app. See image for better idea of what I’m trying to do. Only the content of the “BlurBox” needs to be blurry but the rest can be clear. So if you were looking at table view, only the content underneath the […]

How to store blocks in properties in Objective-C?

I’d like to store objective-c block in a property for later use. I wasn’t sure how to do it so I googled a bit and there is very little info about the subject. But I’ve managed to find the solution eventually and I’ve thought that it might be worth sharing for other newbies like me. […]