Tag: objective c

Can multiple (two) persistent stores be used with one object model, while maintaining relations from one to the other?

Introduction My iOS project ships with a Core Data persistent store weighing some 160MB in SQLite format. There is a ton of grouped information in there, in which users should be able to mark favorites. For this, I need (at least part of) the database to have write capabilities. But of course persistent stores that […]

How to detect “IAP crackers”?

I found out that many users use so-called “IAP crackers” instead of purchasing the items in in-app purchase (IAP). I also learned that Zynga Poker and Pokerist already detect IAP crackers and prevent the fake IAP. I would like to detect which phone is using IAP cracker. For Cydia hacking tool, I could find it […]

What does isa mean in objective-c?

I would like to know the meaning of the below written lines with an example. I’m unable to understand what the lines actually mean. The lines are from google’s objective-c coding guidelines. Initialization Don’t initialize variables to 0 or nil in the init method; it’s redundant. All memory for a newly allocated object is initialized […]

How do I define constant values of UIColor?

I want to do something like this, but I cannot get a cooperative syntax. static const UIColor *colorNavbar = [UIColor colorWithRed: 197.0/255.0 green: 169.0/255.0 blue: 140.0/255.0 alpha: 1.0]; I suppose that I could define macros, but they are ugly.

Generate a UUID string with ARC enabled

I need to generate a UUID string in some code with ARC enabled. After doing some research, this is what I came up with: CFUUIDRef uuid = CFUUIDCreate(NULL); NSString *uuidStr = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, uuid); CFRelease(uuid); Am I correctly using __bridge_transfer to avoid leaking any objects under ARC?

Can you manually implement Cocoa bindings?

I’ve had a crack at implementing bindings for my own NSView subclass. It works, but there are problems with retain cycles when binding to File’s Owner from a nib file. After reading into it a little, I discovered that Apple had the same problem a few years back but have fixed it with some magic […]

Where can I find a good tutorial on iPhone/Objective-C multithreading?

I’m just starting to use multithreading and was looking for a good explanation. I’m not sure if there are differences in how multithreading works on Macs and iPhones. What is a good link to tutorials with example code?

How to extend protocols / delegates in Objective-C

If i want to extend a class like AVAudioPlayer, whats the best way to also add another method to AVAudioPlayerDelegate ?. Do I make a category for it, do I extend it? If I extend it do I then also have to make sure to overwrite the actual delegate getter/setter ? How would I extend […]

Best practice when implementing copyWithZone:

I am trying to clear up a few things in my head about implementing copyWithZone:, can anyone comment on the following … // 001: Crime is a subclass of NSObject. – (id)copyWithZone:(NSZone *)zone { Crime *newCrime = [[[self class] allocWithZone:zone] init]; if(newCrime) { [newCrime setMonth:[self month]]; [newCrime setCategory:[self category]]; [newCrime setCoordinate:[self coordinate]]; [newCrime setLocationName:[self locationName]]; […]

Programmatically fire button click event?

Is there a way to programmatically fire a button click event? I have a button placed there in an UIView, and in a particular scenario i want to click the button via code, not manually as a user. Is it possible in iOS development? Please provide your suggestions and guide me how to do that. […]