Use of mutableArrayValueForKey

2010-12-17 Thread Giannandrea Castaldi
Hi, I have a class with a NSMutableArray as readonly property and I need to execute an action when a new item is added to the array. I would like: - to use key-value observing on my NSMutableArray with the collection accessor pattern - to preserve the information hiding of my objects and then to ch

Re: Use of blocks

2010-07-12 Thread Giannandrea Castaldi
Yes, as already suggested by Preston, key path operators are very expressive. Thanks for the suggestions. Jean On Mon, Jul 12, 2010 at 4:31 PM, Keith Duncan wrote: >> overkill. You can get less, faster code by using a for/in loop: >> >> float minValue = INFINITY; >> for(id obj in someTrips) >>  

Re: Use of blocks

2010-07-12 Thread Giannandrea Castaldi
On Mon, Jul 12, 2010 at 9:43 AM, vincent habchi wrote: > Buongiorno :) > > Le 12 juil. 2010 à 09:34, Giannandrea Castaldi a écrit : > >> I want to use blocks to extract the min price and the max price from >> an NSArray of trips. I've found the following way:

Use of blocks

2010-07-12 Thread Giannandrea Castaldi
Hi, I want to use blocks to extract the min price and the max price from an NSArray of trips. I've found the following way: float minValue = 0.0; [someTrips enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { if (minValue == 0.0 || [[obj adultFinalPrice] floatValue] <

Problem with a singleton that manages a CoreData context

2010-02-26 Thread Giannandrea Castaldi
Hi, I'm developing an application for iPhone where the persistence is managed with CoreData. I've introduced a singleton to initialize and manage the NSManagedObjectContext, this is how I've defined the singleton: static Persistence *singletonPersistence = nil; @implementation Persistence + (voi

NSFetchRequest with NSPredicate not fetches the expected objects (iPhone)

2010-02-24 Thread Giannandrea Castaldi
Hi, I'm developing an atom feed reader for iPhone and I'm trying to execute a NSFetchRequest with a NSPredicate in a test where the result should be an array with two objects but instead is emtpy. There are two entities: Feed (Atom feed) and Entry. In the model Entry has a relationship with one Fee

Is a good practice to alloc an object and defer the initialization to another object?

2010-02-10 Thread Giannandrea Castaldi
Hi, I would like to alloc an object and defer the initialization to another object, is a good practice? The reason is that I can alloc several types of objects but the init method have the same signature. Thanks. Jean ___ Cocoa-dev mailing list (Cocoa-de