Re: UI Panel With "Pointer" On One Side

2011-03-29 Thread Andy Lee
Check out Matt Gemmell's MAAttachedWindow:



--Andy

On Mar 28, 2011, at 9:24 PM, Brian Froisy wrote:

> I want to duplicate UI functionality that appears in several Apple products. 
> I have not been able to determine if there is a standard view (window, panel, 
> etc.) to do this. It is a panel with a side "arrow" such as the list seen 
> when right-click  on a dock item.  Another (similar) example is when you 
> click on a (list view) library object in the interface builder part of Xcode 
> 4.
> 
> A picture is worth 1000 words.
> 
> http://web.me.com/jbfroisy/UI_Question/UI_Question.html
> 
> Thanks


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Distribution via DMG fails

2011-03-29 Thread Gabriel Zachmann
I don't know if this is the correct forum, so please advise if there is a more 
suitable one.

I have developed a little program (a screensaver, actually).

When I send it (just the .saver bundle as-is) to some beta testers via email, 
everything seems to be fine.

But when I put it in a DMG, some testers (not all) can't install it!
They get the error message "You cannot use the screen saver on this computer. 
Contact the developer ..."

I checked and the executable in the DMG is byte-wise the same as the one in the 
bundle on my disk.

Does anyone have an idea, what might be going on?

All kinds of insights, tips, and suggestions will be highly appreciated.

Best regards,
Gabriel.

PS:
For that it's worth, here is an outline, how I create the DMG:

hdiutil create $dmg_file -megabytes $image_size -volname $volume_name -fs HFS+ 
-quiet
hdiutil attach $dmg_file -readwrite -noautoopen -mountpoint $mount_point -quiet
cp -R $binary Help_ReadMe_Changelog.rtf LICENSE.html $mount_point
.. copy background image to the DMG
.. set some window attributes, such as size, using osascript
sync
hdiutil detach $mount_point -quiet
hdiutil convert -quiet -format UDBZ -o $dmg_file2 $dmg_file




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Redeclaring property types in mutable subclasses

2011-03-29 Thread Quincey Morris
On Mar 28, 2011, at 22:54, Ken Thomases wrote:

> Do either of you really mean for that property to be read-write?
> 
> I can see making a property read-write with an immutable type, and I can see 
> (although I don't particularly like) making a read-only property return a 
> mutable type.  (Having properties of mutable type breaks encapsulation in a 
> big way.)  But it seems strange to me to make a read-write property of 
> mutable type.
> 
> Especially you, Quincey, when you've made a "sibling", mutable variant of the 
> property.  Is there really a setMutableGizmos: method?  What does it mean?

Well, no, I didn't mean that, but ultimately it doesn't make a lot of 
difference. What I've actually done in the past is either:

>> @interface MutableWidget : Widget {}
>> @property (retain, readonly) NSMutableArray *mutableGizmos;
>> @end
> 


or

>> @interface MutableWidget : Widget {}
>> @property (retain, readwrite) NSArray *gizmos; // redefined
>> @property (retain, readonly) NSMutableArray *mutableGizmos;
>> @end
> 


In the first case, the caller can set the array's contents with a 'replace...' 
or a combination of 'remove...'/'insert...' methods. In the second case, the 
caller can also replace the array's contents with a simple assignment, which is 
a convenience and nothing more.

Either way, "mutableGizmos" is just a derived property of "gizmos". I don't 
think there's any particular dangers in making it readwrite, too or instead. 
There would of course need to be a custom setter for it, since there's no 
instance variable of its own to (accidentally) use @synthesize with, and that 
setter would simply update the "gizmos" property, ensuring KVO compliance. 

In effect, the two properties are the same in the mutable subclass, except for 
return type. That's the whole point -- to get 2 different types for the same 
property. (If you choose to return the mutable proxy in the "mutableGizmo" 
case, though, they're not quite the same, but to me that's a plus.)

> Also, if you're using -mutableArrayValueForKey: without providing the 
> mutation accessors, then that's probably asking for grief. Actually, you said 
> something I didn't follow about a setter for the gizmos property, but that's 
> read-only.  

Sorry, it was a typo. I meant "getter".

> So, it's not clear to me how the proxy is supposed to mutate it (other than 
> KVC's direct instance variable access, which I always disable).  And without 
> either a proper setter or the mutation accessors, you've violated 
> encapsulation.  Clients of your class can mutate your property without you 
> being informed (unless you KVObserve your own property).

You may or may not need to know. If you don't, you haven't exactly violated 
encapsulation, since your accessors would just do the bidding of the caller 
anyway. :)

In my earlier response, I was forgetting that there doesn't seem to be a way of 
giving the mutable proxy access to your array without custom accessors, 
*except* via direct instance variable access. 

However, I never intended to address whether or not there are custom accessors. 
It's a separate point so read on ...

> Here's what makes sense to me:
> 
> @interface Widget : NSObject {}
> @property (retain, readonly) NSArray *gizmos;
> 
> // optionally, any of:
> - (NSUInteger) countOfGizmos;
> - (id) objectInGizmosAtIndex:(NSUInteger)index;
> - (NSArray*) gizmosAtIndexes:(NSIndexSet*)indexes;
> - (void) getGizmos:(Gizmo**)buffer range:(NSRange)inRange;
> 
> @end
> 
> 
> @interface MutableWidget : Widget {}
> 
> // At least one of:
> - (void) insertObject:(Gizmo*)gizmo inGizmosAtIndex:(NSUInteger)index;
> - (void) insertGizmos:(NSArray *)gizmoArray atIndexes:(NSIndexSet *)indexes;
> 
> // At least one of:
> - (void) removeObjectFromGizmosAtIndex:(NSUInteger)index;
> - (void) removeGizmosAtIndexes:(NSIndexSet *)indexes;
> 
> // optionally, either of:
> - (void) replaceObjectInGizmosAtIndex:(NSUInteger)index 
> withObject:(id)anObject;
> - (void) replaceGizmosAtIndexes:(NSIndexSet *)indexes withGizmos:(NSArray 
> *)gizmoArray;
> 
> @end

You don't *have* to make the accessors public API. When I first started doing 
this kind of thing a couple of years ago, I laboriously added the custom 
accessors (at least, the mutable ones) to the @interface, and I eventually took 
them all back out again:

-- It's a huge PITA to put these in the interface in the first place. Reams of 
boilerplate.

-- The custom accessors are significantly more keystrokes for callers to use 
than the generic NSArray/NSMutable array methods. I also found the correct 
order of the pieces to be really hard to remember.

-- Callers *still* can't use the full range of NSArray/NSMutableArray 
convenience methods (say, 'removeObjectsInRange:') without your providing a 
custom version *and* putting them in the interface *and* writing boilerplate 
code for them for *every* array property *and* updating them manually if you 
ever change a property name because Refactor certainly won

Re: Distribution via DMG fails

2011-03-29 Thread Stephane Sudre
Do you know what the testers reporting the issue have all in common?

Have you asked them to check the Console logs?


On Tue, Mar 29, 2011 at 9:22 AM, Gabriel Zachmann  wrote:
> I don't know if this is the correct forum, so please advise if there is a 
> more suitable one.
>
> I have developed a little program (a screensaver, actually).
>
> When I send it (just the .saver bundle as-is) to some beta testers via email, 
> everything seems to be fine.
>
> But when I put it in a DMG, some testers (not all) can't install it!
> They get the error message "You cannot use the screen saver on this computer. 
> Contact the developer ..."
>
> I checked and the executable in the DMG is byte-wise the same as the one in 
> the bundle on my disk.
>
> Does anyone have an idea, what might be going on?
>
> All kinds of insights, tips, and suggestions will be highly appreciated.
>
> Best regards,
> Gabriel.
>
> PS:
> For that it's worth, here is an outline, how I create the DMG:
>
> hdiutil create $dmg_file -megabytes $image_size -volname $volume_name -fs 
> HFS+ -quiet
> hdiutil attach $dmg_file -readwrite -noautoopen -mountpoint $mount_point 
> -quiet
> cp -R $binary Help_ReadMe_Changelog.rtf LICENSE.html $mount_point
> .. copy background image to the DMG
> .. set some window attributes, such as size, using osascript
> sync
> hdiutil detach $mount_point -quiet
> hdiutil convert -quiet -format UDBZ -o $dmg_file2 $dmg_file
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/dev.iceberg%40gmail.com
>
> This email sent to dev.iceb...@gmail.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Distribution via DMG fails

2011-03-29 Thread Gabriel Zachmann

> Do you know what the testers reporting the issue have all in common?
> 
I am afraid, no.   One of them is running 10.5, one is on 10.6.7.

G.




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Distribution via DMG fails

2011-03-29 Thread Uli Kusterer
On 29.03.2011, at 09:22, Gabriel Zachmann wrote:
> But when I put it in a DMG, some testers (not all) can't install it!
> They get the error message "You cannot use the screen saver on this computer. 
> Contact the developer ..."

 If you didn't say it works when you distribute as a ZIP, I'd expect this to be 
a case where you have built only a 32-bit screen saver, and these testers have 
64-bit Macs (Screensavers are plug-ins, and the system runs a 64-bit screen 
saver engine, so screen savers must be 64-bit or can't be loaded into the 
engine).

 Are you sure you're building the application the same way for both cases? If 
one's a debug build and the other is a release build, then that could explain 
that you're not getting all architectures in one case.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UI Panel With "Pointer" On One Side

2011-03-29 Thread Graham Cox
There isn't right now, but there could be within a couple of months ;-)

--Graham


On 29/03/2011, at 12:24 PM, Brian Froisy wrote:

> I want to duplicate UI functionality that appears in several Apple products. 
> I have not been able to determine if there is a standard view (window, panel, 
> etc.) to do this. It is a panel with a side "arrow" such as the list seen 
> when right-click  on a dock item.  Another (similar) example is when you 
> click on a (list view) library object in the interface builder part of Xcode 
> 4.
> 
> A picture is worth 1000 words.
> 
> http://web.me.com/jbfroisy/UI_Question/UI_Question.html

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Distribution via DMG fails

2011-03-29 Thread Andy Lee

On Mar 29, 2011, at 05:49 AM, Uli Kusterer  wrote:

On 29.03.2011, at 09:22, Gabriel Zachmann wrote:

But when I put it in a DMG, some testers (not all) can't install it!
They get the error message "You cannot use the screen saver on this computer. 
Contact the developer ..."


If you didn't say it works when you distribute as a ZIP, I'd expect this to be 
a case where you have built only a 32-bit screen saver, and these testers have 
64-bit Macs (Screensavers are plug-ins, and the system runs a 64-bit screen 
saver engine, so screen savers must be 64-bit or can't be loaded into the 
engine).
 
I found more info on this here 
 and here 
. But yeah, it's odd that the same bundle, 
bitwise identical, does work.

Are you sure you're building the application the same way for both cases? If 
one's a debug build and the other is a release build, then that could explain 
that you're not getting all architectures in one case.
 
Also, is there any commonality in how the users with problems are doing the 
install? For example, are they double-clicking the bundle? What if they try 
dragging it to ~/Library/Screen Savers?

When you send the bundle directly, do you tar it or zip it? I wonder if there's 
something about the default permissions when you unzip something that matters.

Admittedly I'm flailing, just wondering what the common element is.

--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Weird NSSearchField text layout bug

2011-03-29 Thread Indragie Karunaratne
Will do, thanks.

On 2011-03-28, at 1:15 PM, Aki Inoue wrote:

> Looks like an issue with us.
> 
> Please file a bug with the reproducing steps.
> 
> Thanks,
> 
> Aki
> 
> On 2011/03/25, at 21:50, Indragie Karunaratne wrote:
> 
>> I'm having a really weird issue with NSSearchField at the moment. Whenever 
>> the search field ends editing, this happens:
>> 
>> http://d.indragie.com/bRDS
>> 
>> I did some tests and it _seems_ that the reason that's happening is because 
>> this particular search field has been placed as a subview of the window 
>> frame ([[window contentView] superview]). I'm not sure how that would really 
>> affect the way in which text is laid out in the view.
>> 
>> Any pointers are appreciated.___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/aki%40apple.com
>> 
>> This email sent to a...@apple.com
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


OCTET_STRING_t -> NSString?

2011-03-29 Thread Todd Heberlein
I'm working my way through Apple's "Validating App Store Receipts", and I can 
extract all the data, compute the digest and compare it against the hash. But 
now I am stuck converting the OCTET_STRING_t for the bundle_id in the Receipt 
to an NSString so I can compare it against my applications Bundle Identifier.

In particular, the beginning of the OCTET_STRING_t's buffer begins with two 
bytes (decimal values 12 and 21). Am I supposed to skip these? For example, the 
following code where I skip these first two bytes seems to work, but it seems 
like a big hack:

OCTET_STRING_t *bundle_id;
...
NSString *string = [[NSString alloc] initWithBytes:(bundle_id->buf + 2)
length:(NSUInteger)(bundle_id->size - 2)
encoding:NSUTF8StringEncoding];

What is the right way?

Thanks,

Todd

PS. Here is the OCTET_STRING_t's buffer for the sample receipt Apple provides. 
One line for each byte. The number is the decimal value for each byte, and the 
corresponding character (if printable) is in the brackets.

 12  [ ]
 21  [ ]
 99  [c]
111  [o]
109  [m]
 46  [.]
101  [e]
120  [x]
 97  [a]
109  [m]
112  [p]
108  [l]
101  [e]
 46  [.]
 83  [S]
 97  [a]
109  [m]
112  [p]
108  [l]
101  [e]
 65  [A]
112  [p]
112  [p]

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Distribution via DMG fails

2011-03-29 Thread Laurent Daudelin
On Mar 29, 2011, at 10:15, Andy Lee wrote:

> On Mar 29, 2011, at 05:49 AM, Uli Kusterer  
> wrote:
> 
> On 29.03.2011, at 09:22, Gabriel Zachmann wrote:
>> But when I put it in a DMG, some testers (not all) can't install it!
>> They get the error message "You cannot use the screen saver on this 
>> computer. Contact the developer ..."
> 
> If you didn't say it works when you distribute as a ZIP, I'd expect this to 
> be a case where you have built only a 32-bit screen saver, and these testers 
> have 64-bit Macs (Screensavers are plug-ins, and the system runs a 64-bit 
> screen saver engine, so screen savers must be 64-bit or can't be loaded into 
> the engine).
>  
> I found more info on this here 
>  and here 
> . But yeah, it's odd that the same 
> bundle, bitwise identical, does work.
> 
> Are you sure you're building the application the same way for both cases? If 
> one's a debug build and the other is a release build, then that could explain 
> that you're not getting all architectures in one case.
>  
> Also, is there any commonality in how the users with problems are doing the 
> install? For example, are they double-clicking the bundle? What if they try 
> dragging it to ~/Library/Screen Savers?
> 
> When you send the bundle directly, do you tar it or zip it? I wonder if 
> there's something about the default permissions when you unzip something that 
> matters.
> 
> Admittedly I'm flailing, just wondering what the common element is.

You can also do a 'lipo  -info' to check which 
architectures are in the binary.

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laurent@nemesys-soft.com___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Todd Heberlein
> In particular, the beginning of the OCTET_STRING_t's buffer begins with two 
> bytes (decimal values 12 and 21). Am I supposed to skip these? For example, 
> the following code where I skip these first two bytes seems to work, but it 
> seems like a big hack:

OK, it seems that the second byte (21 in this case) is the number of characters 
encoded (I haven't tried non-ASCII characters). The OCTET_STRING_t for 
bundle_version begins 12, 5 (where the string resolves to "1.0.2", five 
characters). I still don't know what the 12 means. And does this mean that an 
OCTET_STRING can encode at most 256 bytes?

Any thoughts?

Todd

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Stephen J. Butler
On Tue, Mar 29, 2011 at 12:24 PM, Todd Heberlein  wrote:
> In particular, the beginning of the OCTET_STRING_t's buffer begins with two 
> bytes (decimal values 12 and 21). Am I supposed to skip these? For example, 
> the following code where I skip these first two bytes seems to work, but it 
> seems like a big hack:

I'm not familiar with validating app store bundles, as I'm not
(currently) a paid developer. But what is this, ANS.1 BER encoding?
Then the first byte is the tag (the type of data to follow), the
second byte the length (21), and then the next 21 bytes the data.

Indeed, Wikipedia (http://en.wikipedia.org/wiki/Basic_Encoding_Rules)
says that tag 12 is UTF8String. I'd recommend using liblber (man
lber-decode) if you have to do anything other than basic work with
this format.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Todd Heberlein
Ka ching!  Yes, this answer is what I am looking for.  Thanks!!!

Todd

On Mar 29, 2011, at 10:50 AM, Stephen J. Butler wrote:

> On Tue, Mar 29, 2011 at 12:24 PM, Todd Heberlein  
> wrote:
>> In particular, the beginning of the OCTET_STRING_t's buffer begins with two 
>> bytes (decimal values 12 and 21). Am I supposed to skip these? For example, 
>> the following code where I skip these first two bytes seems to work, but it 
>> seems like a big hack:
> 
> I'm not familiar with validating app store bundles, as I'm not
> (currently) a paid developer. But what is this, ANS.1 BER encoding?
> Then the first byte is the tag (the type of data to follow), the
> second byte the length (21), and then the next 21 bytes the data.
> 
> Indeed, Wikipedia (http://en.wikipedia.org/wiki/Basic_Encoding_Rules)
> says that tag 12 is UTF8String. I'd recommend using liblber (man
> lber-decode) if you have to do anything other than basic work with
> this format.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Stephen J. Butler
On Tue, Mar 29, 2011 at 12:48 PM, Todd Heberlein  wrote:
>> In particular, the beginning of the OCTET_STRING_t's buffer begins with two 
>> bytes (decimal values 12 and 21). Am I supposed to skip these? For example, 
>> the following code where I skip these first two bytes seems to work, but it 
>> seems like a big hack:
>
> OK, it seems that the second byte (21 in this case) is the number of 
> characters encoded (I haven't tried non-ASCII characters). The OCTET_STRING_t 
> for bundle_version begins 12, 5 (where the string resolves to "1.0.2", five 
> characters). I still don't know what the 12 means. And does this mean that an 
> OCTET_STRING can encode at most 256 bytes?

You've probably already figured this out, but no, OCTET_STRING can
have as many bytes as it wants. You can store up to 127 bytes using
the simple, single byte length field. But if the highest order bit is
1 then the length field is either a "length-of-length" field or
"indeterminate length" field (depending on the particular "length"
value) where the data is terminated by a end-of-content sequence.

Again, I think using lber is the best way to handle this data :) I
can't remember why, but once upon a time I wrote an encoder/decoder
and had to learn all the subtitles.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Cocoa alternative for method aliasing?

2011-03-29 Thread Lou Zell
Mornin' Devs,

Is there a recommended pattern for passing events up the responder chain
without subclassing a class and overriding the methods I'm interested in?
 Here is an explanation of what I'm trying to do:

I have a subclass of UIButton, call it MyButton, that I would like to
function as a vanilla UIButton but also pass touch events to the next
responder (I'm interested in eventually getting the events in
UIViewController).  I can do something like this in MyButton:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  [[self nextResponder] touchesBegan:touches withEvent:event];
}

But then I lose the touch handling that makes a UIButton different from just
a plain old UIView (e.g. highlight states).  I could use [self
setHighlighted:YES], for example, to fix that problem.  What I really want
to do, though, is something like this:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
  [self originalTouchesBegan:touches withEvent:event];
  [[self nextResponder] touchesBegan:touches withEvent:event];
}

Something analogous to ruby's alias.  I haven't found anything built in for
method aliasing, which leads me to believe there is another way to approach
this.  Does anyone have a good approach?

Thanks,
Lou
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa alternative for method aliasing?

2011-03-29 Thread David Duncan
On Mar 29, 2011, at 11:20 AM, Lou Zell wrote:

> Mornin' Devs,
> 
> Is there a recommended pattern for passing events up the responder chain
> without subclassing a class and overriding the methods I'm interested in?
> Here is an explanation of what I'm trying to do:


There is a certain question of "why?" in this, but I think the answer is that 
you should use the various control events that are exposed for 
-addTarget:action:forControlEvents:. By doing so you can get action messages 
for basically every touch interaction without needing to subclass to forward 
messages.
--
David Duncan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Font Height and -[NSString sizeWithAttributes:]

2011-03-29 Thread Thomas Clement
Right I think NSLayoutManager will solve my problem.
Lots of things in that class.

Thanks all!
Thomas

On 28 mars 2011, at 21:17, Aki Inoue wrote:

> The default line height used by the Cocoa Text System is based on various 
> layout time configurations.  So, the differences you're seeing is coming from 
> the differences in layout context.
> 
> The settings are all encapsulated in NSLayoutManager; hence, the method 
> -[NSLayoutManager defaultLineHeightForFont:] gives you the information used 
> by the layout context.
> 
> Aki
> 
> On 2011/03/28, at 12:06, Quincey Morris wrote:
> 
>> On Mar 28, 2011, at 09:45, Thomas Clément wrote:
>> 
 NSFont *font = [NSFont fontWithName:@"Menlo" size:11.0];
 [@"Hello World" sizeWithAttributes:[NSDictionary 
 dictionaryWithObjectsAndKeys:font, NSFontAttributeName, nil]];
>>> 
>>> This returns a height of 17.0. However when using this font (Menlo 11.0) in 
>>> TextEdit (plain text document), I'm seeing a line height of 13.0.
>>> 
>>> Monaco 10.0 returns a height of 14.0 which is also what I'm seeing in 
>>> TextEdit.
>>> Helvetica 12.0 returns a height of 15.0 but I'm seeing 14.0 in TextEdit.
>>> 
>>> Why these differences?
>> 
>> 'sizeWithAttributes:' returns the bounding box, in points, of the glyphs 
>> representing the characters in the string you passed.
>> 
>>> How do I get programmatically the value I'm seeing in TextEdit?
>> 
>> There's no absolute typographic standard for the inter-baseline distance, 
>> but it's almost always derived from font metrics, not from glyph bounding 
>> boxes. Here are some of the possibilities:
>> 
>> -- The font size multiplied by a standard factor, like 120%. This is (or 
>> used to be, at least) what apps like Adobe Illustrator used to use, because 
>> it doesn't depend on the specific font metrics, and therefore the line 
>> spacing of a line doesn't depend on what fonts are on it, only on their 
>> sizes.
>> 
>> -- The font's ascender + descender + "leading". These are metrics built into 
>> the font itself, independent of the actual glyph bounds. This is probably 
>> what TextEdit is using. (What Apple calls "leading" is really called "extra 
>> leading" in the typographic world. Typographically, leading *is* the 
>> inter-baseline distance: the whole thing.) IIRC, changing fonts in TextEdit 
>> can affect the inter-baseline distance on a line-by-line basis.
>> 
>> -- The glyph bounding box, either of the particular line, or of all the 
>> characters in the font. You'd only use this if you can't tolerate glyph 
>> images overlapping, ever.
>> 
>> -- Any weird calculation that someone thought was a good idea at the time.
>> 
>> There's no right answer, unfortunately.
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/aki%40apple.com
>> 
>> This email sent to a...@apple.com
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa alternative for method aliasing?

2011-03-29 Thread Matt Neuburg
On Tue, 29 Mar 2011 11:20:31 -0700, Lou Zell  said:
>I have a subclass of UIButton, call it MyButton, that I would like to
>function as a vanilla UIButton but also pass touch events to the next
>responder (I'm interested in eventually getting the events in
>UIViewController).  I can do something like this in MyButton:
>
>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
>{
>  [[self nextResponder] touchesBegan:touches withEvent:event];
>}

Don't do that. The way to pass touches up the responder chain is by calling 
super. This will do exactly what you're after, I think.

However, as already implied, you might be better off with a different 
architecture. It isn't at all clear why you'd do what you're describing. Let 
the button act as a button. If you need further information about what's going 
on, consider a gesture recognizer, perhaps, or just use the button's control 
events. In any case there should be no need to interfere at the very low level 
of the touches... responder methods. There are *many* ways to interfere with 
aspects of touch delivery; they are quite interesting, but be careful or you'll 
break something.

m.

--
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Chris Ridd

On 29 Mar 2011, at 19:00, Stephen J. Butler wrote:

> Again, I think using lber is the best way to handle this data :) I
> can't remember why, but once upon a time I wrote an encoder/decoder
> and had to learn all the subtitles.

liblber can only decode the restricted BER defined for use with LDAP. In 
particular, no indefinite length encoding, strings can't be constructed, etc. 
The lber-decode man page mentions this at the top.

Given this is all likely to be part of security data, I'd say use the crypto 
libraries and/or OpenSSL to crack it apart.

Chris
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Wim Lewis

On 29 Mar 2011, at 12:26 PM, Chris Ridd wrote:
> liblber can only decode the restricted BER defined for use with LDAP. In 
> particular, no indefinite length encoding, strings can't be constructed, etc. 
> The lber-decode man page mentions this at the top.
> 
> Given this is all likely to be part of security data, I'd say use the crypto 
> libraries and/or OpenSSL to crack it apart.

If the security data is in DER, then lber's restricted subset of BER might 
still suffice. (I haven't looked.)

But yes, linking openssl and using d2i_ASN1_type_bytes() and either 
ASN1_STRING_to_UTF8() or mapping the ASN.1 string types to (Core)Foundation 
string encodings seems like an easy(ish) way to get correct behavior.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Todd Heberlein

On Mar 29, 2011, at 12:54 PM, Wim Lewis wrote:

> If the security data is in DER, then lber's restricted subset of BER might 
> still suffice. (I haven't looked.)
> 
> But yes, linking openssl and using d2i_ASN1_type_bytes() and either 
> ASN1_STRING_to_UTF8() or mapping the ASN.1 string types to (Core)Foundation 
> string encodings seems like an easy(ish) way to get correct behavior.

I thought my Mac Cocoa program was pretty much done, and that all I needed to 
do was check off a box in Xcode's packaging or Apple's iTunes Connect web site 
saying "I want copy protection".

I didn't realize this was going to be a 2.5 day excursion.

Todd

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Hash Values in Custom Classes

2011-03-29 Thread Peter Lübke


Am 28.03.2011 um 20:06 schrieb Sean McBride:



Are you aware that starting in 10.6, the OS provides 'file reference
URLs' which are much like FSRefs.  See:




Good to know. I'm very interested in your experience related to:
	- Under which circumstances will fileReferenceURL break when decoded  
from an archive? (Item moved, overwritten ...)
	- What about performance? I often find that NSFileManger is a lot  
slower than my custom classes - would I have to expect the same with  
fileReferenceURL?


For right now, I'm happy with my wrapper classes - they are highly  
reusable, I'm using them in several apps which all are backward  
compatible back to 10.4, and they have initializers for about  
anything that can possibly be used to get a file reference.


Cheers,

Peter
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Quincey Morris
On Mar 29, 2011, at 13:03, Todd Heberlein wrote:

> I thought my Mac Cocoa program was pretty much done, and that all I needed to 
> do was check off a box in Xcode's packaging or Apple's iTunes Connect web 
> site saying "I want copy protection".

FWIW, my understanding of the reason it doesn't work that way is this:

A standard implementation of the receipt checking code could would permit a 
single hacking tool to hack away the protection from *every* Mac App Store 
download. If you implement this yourself, a hacker has to target your 
application specifically. Chances are, that won't be worth any hacker's time 
unless your app is incredibly successful.

As a consequence, once you have your code working, you should probably try to 
rearrange it a bit (reorder functions, obfuscate names, etc) to make it less 
like the sample code you're following along with, so that it's slightly more 
work for a hacker to crack your application. A hacker who have to spend a 
couple of hours at it, rather than a couple of minutes, might just not bother, 
and move on to some other unfortunate target.

As I said, FWIW.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OCTET_STRING_t -> NSString?

2011-03-29 Thread Todd Heberlein

On Mar 29, 2011, at 1:24 PM, Quincey Morris wrote:

> FWIW, my understanding of the reason it doesn't work that way is this:
> ...

That is pretty much what the Apple documentation says. I felt that they were 
saying, "This is left as an exercise for the reader."  :)

The hacker community has had automated obfuscation tools for years. Some worms 
implement this internally so each new instance is different than the previous 
one. In these cases, instead of avoiding a hacker who wants to break copy 
protection, they want to prevent AntiVirus vendors from coming up with a 
signature to detect the malware.

It seems that a great service to the Mac programming community would be to 
repurpose one of these tools to randomly obfuscate a base receipt validation 
code base and produce source code you can paste into your program. Then each 
person gets a unique version but doesn't have to code it themselves.

Maybe after I get version 1.1 of my software released I will take a look at 
this.

Todd

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Weird NSSearchField text layout bug

2011-03-29 Thread Indragie Karunaratne
Filed as rdar://9202933.

On 2011-03-29, at 11:21 AM, Indragie Karunaratne wrote:

> Will do, thanks.
> 
> On 2011-03-28, at 1:15 PM, Aki Inoue wrote:
> 
>> Looks like an issue with us.
>> 
>> Please file a bug with the reproducing steps.
>> 
>> Thanks,
>> 
>> Aki
>> 
>> On 2011/03/25, at 21:50, Indragie Karunaratne wrote:
>> 
>>> I'm having a really weird issue with NSSearchField at the moment. Whenever 
>>> the search field ends editing, this happens:
>>> 
>>> http://d.indragie.com/bRDS
>>> 
>>> I did some tests and it _seems_ that the reason that's happening is because 
>>> this particular search field has been placed as a subview of the window 
>>> frame ([[window contentView] superview]). I'm not sure how that would 
>>> really affect the way in which text is laid out in the view.
>>> 
>>> Any pointers are appreciated.___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/cocoa-dev/aki%40apple.com
>>> 
>>> This email sent to a...@apple.com
>> 
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa alternative for method aliasing?

2011-03-29 Thread Lou Zell
David, Matt,

Thanks for the responses and pointing me towards UIControlEvents.


> >-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
> >{
> >  [[self nextResponder] touchesBegan:touches withEvent:event];
> >}
>
> Don't do that. The way to pass touches up the responder chain is by calling
> super. This will do exactly what you're after, I think.
>
>
Using super will call -touchesBegan:withEvent of UIButton.  Which, in my
experiments, does not continue to pass the event up the responder chain --
i.e. I never see the touch events reach my UIViewController (where I want
them to end up).  My understanding is that once an object is found that
responds to -touchesBegan:withEvent, the event propagation ends unless
explicitly forwarded.  Calling super will get the event to my superclass
(UIButton), but not beyond that.

Lou
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Automatic graphics switching...

2011-03-29 Thread Jason Harris
Hi All,

Some users are complaining that my application (MacHg) is causing their 
MacBooks to switch from using the integrated Intel (lower power) card to the 
NVIDIA (higher power) graphics card. 

Eg some related articles I dug up:
http://appletoolbox.com/2010/05/macbook-pro-mid-2010-graphics-switching-which-apps-trigger-how-to-monitor/
http://www.cocoabuilder.com/archive/cocoa/293116-i5-i7-auto-graphics-switching.html
http://support.apple.com/kb/HT3207

However, my application doesn't appear on the surface to make heavy use of 
graphics. (It does make heavy use of GCD though).  Is there a general cause for 
this switching of the graphics card?.  How can I find out when such a switch 
occurs in my code and for what reasons?  Is there some technical article which 
explains the details of what's going on here?

Thanks!
   Jas___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Hash Values in Custom Classes

2011-03-29 Thread Jean-Daniel Dupas

Le 29 mars 2011 à 22:04, Peter Lübke a écrit :

> 
> Am 28.03.2011 um 20:06 schrieb Sean McBride:
> 
>> 
>> Are you aware that starting in 10.6, the OS provides 'file reference
>> URLs' which are much like FSRefs.  See:
>> 
>> 
> 
> Good to know. I'm very interested in your experience related to:
>   - Under which circumstances will fileReferenceURL break when decoded 
> from an archive? (Item moved, overwritten ...)

File reference should not be archived. They are valid only for the application 
lifetime. Use Bookmark (provided by NSURL class too) for archiving.

>   - What about performance? I often find that NSFileManger is a lot 
> slower than my custom classes - would I have to expect the same with 
> fileReferenceURL?
> 
> For right now, I'm happy with my wrapper classes - they are highly reusable, 
> I'm using them in several apps which all are backward compatible back to 
> 10.4, and they have initializers for about anything that can possibly be used 
> to get a file reference.
> 
> Cheers,
> 
> Peter
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org
> 
> This email sent to devli...@shadowlab.org

-- Jean-Daniel




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: UI Panel With "Pointer" On One Side

2011-03-29 Thread Sean McBride
On Mon, 28 Mar 2011 20:24:59 -0500, Brian Froisy said:

>I want to duplicate UI functionality that appears in several Apple
>products. I have not been able to determine if there is a standard view
>(window, panel, etc.) to do this. It is a panel with a side "arrow" such
>as the list seen when right-click  on a dock item.  Another (similar)
>example is when you click on a (list view) library object in the
>interface builder part of Xcode 4.
>
> A picture is worth 1000 words.
>
>http://web.me.com/jbfroisy/UI_Question/UI_Question.html

Apple Sample code here:


--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Automatic graphics switching...

2011-03-29 Thread Nick Zitzmann

On Mar 29, 2011, at 3:16 PM, Jason Harris wrote:

> Hi All,
> 
> Some users are complaining that my application (MacHg) is causing their 
> MacBooks to switch from using the integrated Intel (lower power) card to the 
> NVIDIA (higher power) graphics card. 
> 
> Eg some related articles I dug up:
> http://appletoolbox.com/2010/05/macbook-pro-mid-2010-graphics-switching-which-apps-trigger-how-to-monitor/
> http://www.cocoabuilder.com/archive/cocoa/293116-i5-i7-auto-graphics-switching.html
> http://support.apple.com/kb/HT3207
> 
> However, my application doesn't appear on the surface to make heavy use of 
> graphics. (It does make heavy use of GCD though).  Is there a general cause 
> for this switching of the graphics card?.  

There are a few of them I know about:
1. Your application starts CoreAnimation by calling -setWantsLayer: on a view 
with a layer, or adding a layer in IB
2. Your application initializes an NSOpenGLView using a pixel format that works 
best using the discrete GPU
3. Your application initializes a QTCaptureView, QTMovieView, or QCView
4. The user plugged in an external display (external displays must use the 
discrete GPU)

There might be more, but those are the ones I know about.

> How can I find out when such a switch occurs in my code and for what reasons? 
>  

If you have a dual-GPU Mac, then try breaking on IOServiceOpen and look at the 
stack trace when it breaks. If you don't, then you can't.

Nick Zitzmann


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Binding tablecolumn to attribute of specific object in to-many relationship?

2011-03-29 Thread Sean McBride
Hi all,

Consider a Core Data app, with Employee and Department entities.  The
Employee entity has 'name' and 'number' attributes.  Department has a to-
many relationship to Employees.

I need a tableview of departments, where one column should show the
'name' of the employee who's 'number' is 0.  The table needs to update
when an employee's 'name' or 'number' changes, or when employees are
added/removed from a department's employees relationship.

What's the best way to do this?

I've considered adding a optional transient to-one relationship to
Department named 'employeeId0' and binding the tablecolumn to
departmentsArrayController>arrangedObjects>employeeId0>name, but maybe
I'm barking up the wrong tree

Thanks,

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa alternative for method aliasing?

2011-03-29 Thread WT
On Mar 29, 2011, at 4:25 PM, Matt Neuburg wrote:

> On Tue, 29 Mar 2011 11:20:31 -0700, Lou Zell  said:
>> I have a subclass of UIButton, call it MyButton, that I would like to
>> function as a vanilla UIButton but also pass touch events to the next
>> responder (I'm interested in eventually getting the events in
>> UIViewController).  I can do something like this in MyButton:
>> 
>> -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
>> {
>> [[self nextResponder] touchesBegan:touches withEvent:event];
>> }
> 
> Don't do that. The way to pass touches up the responder chain is by calling 
> super. This will do exactly what you're after, I think.
> 
> However, as already implied, you might be better off with a different 
> architecture. It isn't at all clear why you'd do what you're describing. Let 
> the button act as a button. If you need further information about what's 
> going on, consider a gesture recognizer, perhaps, or just use the button's 
> control events. In any case there should be no need to interfere at the very 
> low level of the touches... responder methods. There are *many* ways to 
> interfere with aspects of touch delivery; they are quite interesting, but be 
> careful or you'll break something.
> 
> m.

Moreover, according to the Event Handling Guide for iOS,

http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MultitouchEvents/MultitouchEvents.html

"Important: If your custom responder class is a subclass of UIView or 
UIViewController, you should implement all of the methods described in “The 
Event-Handling Methods.” If your class is a subclass of any other UIKit 
responder class, you do not need to override all of the event-handling methods; 
however, in those methods that you do override, be sure to call the superclass 
implementation of the method (for example, super touchesBegan:touches 
withEvent:theEvent];). The reason for this guideline is simple: All views that 
process touches, including your own, expect (or should expect) to receive a 
full touch-event stream. If you prevent a UIKit responder object from receiving 
touches for a certain phase of an event, the resulting behavior may be 
undefined and probably undesirable."

and, further down,

"Handling Events in Subclasses of UIKit Views and Controls
If you subclass a view or control class of the UIKit framework (for example, 
UIImageView or UISwitch) for the purpose of altering or extending 
event-handling behavior, you should keep the following points in mind:

- Unlike in a custom view, it is not necessary to override each event-handling 
method.
- Always invoke the superclass implementation of each event-handling method 
that you do override.
- Do not forward events to UIKit framework objects."

W.___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Hash Values in Custom Classes

2011-03-29 Thread Peter Lübke


Am 29.03.2011 um 23:26 schrieb Jean-Daniel Dupas:



Am 28.03.2011 um 20:06 schrieb Sean McBride:



Are you aware that starting in 10.6, the OS provides 'file reference
URLs' which are much like FSRefs.  See:




Good to know. I'm very interested in your experience related to:
	- Under which circumstances will fileReferenceURL break when  
decoded from an archive? (Item moved, overwritten ...)


File reference should not be archived. They are valid only for the  
application lifetime.


Obviously. This makes me think that somewhere inside fileReferenceURL  
there is an FSRef in use.



Use Bookmark (provided by NSURL class too) for archiving.



I was referring to this statement in the Release Note:
" When asked to perform keyed archiving, file reference URLs will  
encode their minimal bookmark data and when decoded will resolve to a  
file path URL (if you wish to receive a file 	reference URL from  
this, please call -[NSURL fileReferenceURL] on the resulting item). "


...so it seems we are talking about the same point.

But right, my question was obsolete because I overlooked that fact  
that bookmarks are alias files - so this will give me what I can  
expect from Alias Manager.


Thank you for pointing me to this,

Peter
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Binding tablecolumn to attribute of specific object in to-many relationship?

2011-03-29 Thread Quincey Morris
On Mar 29, 2011, at 14:57, Sean McBride wrote:

> I've considered adding a optional transient to-one relationship to
> Department named 'employeeId0' and binding the tablecolumn to
> departmentsArrayController>arrangedObjects>employeeId0>name, but maybe
> I'm barking up the wrong tree

There's no obvious reason from your description why employee ID 0 needs to be a 
Core Data property. Surely it can just be a normal derived property.

Also, if it has no particular significance other than for populating the list, 
there's no real reason to implement the property in the data model itself. It 
seems more natural to implement it in your window controller.

But I don't see anything actually wrong with your original suggestion, if you 
have a compelling reason to go that way.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Automatic graphics switching...

2011-03-29 Thread Jason Harris

On Mar 29, 2011, at 11:36 PM, Nick Zitzmann wrote:

> 
> On Mar 29, 2011, at 3:16 PM, Jason Harris wrote:
> 
>> Hi All,
>> 
>> Some users are complaining that my application (MacHg) is causing their 
>> MacBooks to switch from using the integrated Intel (lower power) card to the 
>> NVIDIA (higher power) graphics card. 
>> 
>> Eg some related articles I dug up:
>> http://appletoolbox.com/2010/05/macbook-pro-mid-2010-graphics-switching-which-apps-trigger-how-to-monitor/
>> http://www.cocoabuilder.com/archive/cocoa/293116-i5-i7-auto-graphics-switching.html
>> http://support.apple.com/kb/HT3207
>> 
>> However, my application doesn't appear on the surface to make heavy use of 
>> graphics. (It does make heavy use of GCD though).  Is there a general cause 
>> for this switching of the graphics card?.  
> 
> There are a few of them I know about:
> 1. Your application starts CoreAnimation by calling -setWantsLayer: on a view 
> with a layer, or adding a layer in IB

Ahhh... yes I use core animation, but just very very lightly... some simple 
static stuff like:

CIColor* black   = [CIColor colorWithRed:  0.0/255.0 green:  0.0/255.0 
blue:  0.0/255.0 alpha:1.0];
CIColor* color0  = [CIColor colorWithRed: 77.0/255.0 green: 78.0/255.0 
blue: 87.0/255.0 alpha:0.8];
CIColor* color1  = [CIColor colorWithRed: 39.0/255.0 green: 40.0/255.0 
blue: 52.0/255.0 alpha:0.5];
CIVector* center = [self recomputePosition];
NSNumber* radius = radius_ ? radius_ : [NSNumber numberWithFloat:450.0];

CIFilter* gradiantFilter = [CIFilter 
filterWithName:@"CIGaussianGradient"];
[gradiantFilter setValue:color0 forKey:@"inputColor0"];
[gradiantFilter setValue:color1 forKey:@"inputColor1"];
[gradiantFilter setValue:center forKey:@"inputCenter"];
[gradiantFilter setValue:radius forKey:@"inputRadius"];

CIFilter* constantFilter = [CIFilter 
filterWithName:@"CIConstantColorGenerator"];
[constantFilter setValue:black forKey:@"inputColor"];

foregroundFilters_ = [NSArray arrayWithObject:gradiantFilter];
backgroundFilters_ = [NSArray arrayWithObject:constantFilter];

[[self layer] setFilters: foregroundFilters_];
[[self layer] setBackgroundFilters:backgroundFilters_];

Not much more... Ohh well at least I know where its coming from then!

Thanks!
   Jas

> 2. Your application initializes an NSOpenGLView using a pixel format that 
> works best using the discrete GPU
> 3. Your application initializes a QTCaptureView, QTMovieView, or QCView
> 4. The user plugged in an external display (external displays must use the 
> discrete GPU)
> 
> There might be more, but those are the ones I know about.
> 
>> How can I find out when such a switch occurs in my code and for what 
>> reasons?  
> 
> If you have a dual-GPU Mac, then try breaking on IOServiceOpen and look at 
> the stack trace when it breaks. If you don't, then you can't.
> 
> Nick Zitzmann
> 
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Distribution via DMG fails

2011-03-29 Thread Gabriel Zachmann
> Are you sure you're building the application the same way for both cases? If 
> one's a debug build and the other is a release build, then that could explain 
> that you're not getting all architectures in one case.

Yes, I am sure about that.
I built the screensaver, then put this very screensaver into a DMG.
I then sent both the screensaver and the DMG to the tester.

Here is what he tried:
"""
I just double click on the screensaver in the the DMG.
The double click on DMG still cause error I sent you.
Double clicking on the .saver file from email works fine.
Moving the .saver in the DMG to desktop before double click does not work 
either.
However, moving the .saver from DMG to "/Library/Screen Saver/" manually and 
then opening the System Preference works.
"""

Any ideas, what might be going on?

Best regards,
Gabriel.



smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

why I got wrong arguments from command-line

2011-03-29 Thread Haibin Liu
1.double click to start my application (no additional command-line
arguments).

2.and start application from command-line with additional arguments.

3.i got wrong arguments
NSArray * argvs = [[NSProcessInfo processInfo] arguments];
argvs = (
"/Users/sara/studio/client/bin/Debug/Test.app/Contents/MacOS/Test",
"-psn_0_2392648"
)
"psn_0_2392648" is not expected.

i will got perfect result without step 1.

it make me confused.



-- 
刘海滨
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Customize Views Created Within Interface Builder

2011-03-29 Thread Dominic Dauer
Hi,
in IB I placed a horizontal line (NSBox) into my window. Now I want to change 
the appearance of this line in my code.
In my delegate class I defined an IBOutlet NSBox *line and linked it in IB with 
the correspondending horizontal line. 
In the applicationDidFinishLaunching: method I change the border width and 
color but nothing happens.
What do I have to do to get access to that line?

- DD
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Big Core Data, countForFetchRequest, and GCD

2011-03-29 Thread Steve Mykytyn
countForFetchRequest seems to bog down on really big collections of
entities.  For approx 170K entities it takes around 10 seconds on an iPhone
3GS to count them, which is a problem in a UITableView where you are trying
to display a list of entities and associated counts.

A GCD based solution, that queues up countForFetchRequest on a concurrent
queue for each entity, and then updates the corresponding cell when
finished, seems to work pretty well, although one or two big entity counts
essentially bog down all the requests behind them.  Counts are cached so
that countForFetchRequest is only called once for any entity.

Code below, can anyone suggest any further optimization or different
approaches that might be more effective?

(I'm aware of the danger of multi-threading core data - this particular
managed object context never changes and nothing is happening to it on other
threads when this read is going on)

- (void) countEntitiesNamed:(NSString *)entityName
inContext:(NSManagedObjectContext *)context forIndexPath:(NSIndexPath
*)indexPath {

NSNumber *rowCountObject = [self.rowCountMD valueForKey:entityName];

if (rowCountObject) return;

//
http://www.mikeash.com/pyblog/friday-qa-2009-08-28-intro-to-grand-central-dispatch-part-i-basics-and-dispatch-queues.html

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
0), ^{

 NSEntityDescription *ed;
 NSFetchRequest  *frq;

 frq = [[[NSFetchRequest alloc] init] autorelease];
 ed = [NSEntityDescription entityForName:entityName
inManagedObjectContext:context];
 [frq setEntity:ed];
 NSDate *startDate = [NSDate date];
 NSUInteger rowCount = [context countForFetchRequest:frq error:nil];
 NSTimeInterval timeInterval = -[startDate timeIntervalSinceNow];
 DLog(@"%0.2lf seconds for %d %@ ",timeInterval,rowCount,entityName);

  dispatch_async(dispatch_get_main_queue(), ^{
 [rowCountMD setValue:[NSNumber numberWithInteger:rowCount]
forKey:entityName];
 UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
 cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ objects",
  [NSNumberFormatter localizedStringFromNumber:[NSNumber
numberWithInteger:rowCount]
   numberStyle:NSNumberFormatterDecimalStyle]];

   });
  });


}
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSObject Category Issue on iOS

2011-03-29 Thread Nik Heger
I am new to Objective-C so please forgive me if this is obvious.

I come from Ruby, where extending built in classes is straight forward - you
do it, and it works. I expected the same in Obj-C but got a confusing
result: It works sometimes, but not others.

Here is what I did:

1 - Created a Category on NSObject, this is the header, implementation was
working and tested too (and pretty simple)

@interface NSObject (Logger)

- (void) LOGx1: (id) first, ...;// support for simple logging of multiple
string

@end

So now, I expected to be able to call LOGx1 on any object

2 - Tried this out on a String object and on my UIViewController subclass
which gets loaded from a nib file

// FirstViewController.m - subclass of UIViewController, loaded from a nib

#import "NSObject-Logger.h"
...

- (void)sample

{

NSString *test = @"A TEST";

[test LOGx1: @"Testing NSString!",nil]; // working

[self LOGx1: @"foobar ",nil]; // throwing exception

}

The first invocation works as expected. Seems like NSString knows about the
Logger category. The second one crashes with an unknown selector. The stack
trace seems to indicate that my FirstViewController class inherits from
NSObject(NSObject) instead of NSObject(Logger). Output and stack trace in
[1].

That's as far as I got. Question is, why?

I tried the -ObjC and the -all_load linking flags after Googling for the
issue - didn't make a difference.

The thing I don't understand is: If I define a category on a built-in
object, I expect it to work under all circumstances. If it doesn't work for
some, it would be rather pointless to have this facility, no? Is there
anything obvious I am missing? Does it have to do with the NIB/XIB loading?

thanks, sorry for the length...

~Nik

PS: I later realized logging as a Category makes no sense and moved it into
its own Logger class where it's a class method; but I still want to
understand categories.

[1]
Here is what I get for the stack trace:

*2011-03-30 09:18:52.802 xxx[23245:207] Testing NSString!*

*2011-03-30 09:18:52.803 xxx[23245:207] -[FirstViewController LOGx1:]:
unrecognized selector sent to instance 0x4d37f30*

*2011-03-30 09:18:52.805 xxx[23245:207] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[FirstViewController
LOGx1:]: unrecognized selector sent to instance 0x4d37f30'*

 Call stack at first throw:*

*(*

* 0   CoreFoundation  0x00e935a9 __exceptionPreprocess +
185*

* 1   libobjc.A.dylib 0x00fe7313 objc_exception_throw +
44*

* 2   CoreFoundation  0x00e950bb -[NSObject(NSObject)
doesNotRecognizeSelector:] + 187*
*
*
*
*
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: why I got wrong arguments from command-line

2011-03-29 Thread Stephen J. Butler
On Tue, Mar 29, 2011 at 9:55 AM, Haibin Liu  wrote:
> NSArray * argvs = [[NSProcessInfo processInfo] arguments];
>    argvs = (
>    "/Users/sara/studio/client/bin/Debug/Test.app/Contents/MacOS/Test",
>    "-psn_0_2392648"
> )

The -psn_* argument is added by launch services. You'll have to code
your app to ignore it.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Automatic graphics switching...

2011-03-29 Thread Kyle Sluder
On Tue, Mar 29, 2011 at 6:16 PM, Jason Harris  wrote:
> Ahhh... yes I use core animation, but just very very lightly... some simple 
> static stuff like:

You might want to consider eschewing Core Animation. DVCSes are
particularly well-suited to use cases such as a laptop on a plane, and
preserving battery by avoiding the discrete GPU might be appreciated.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Customize Views Created Within Interface Builder

2011-03-29 Thread Quincey Morris
On Mar 29, 2011, at 12:37, Dominic Dauer wrote:

> in IB I placed a horizontal line (NSBox) into my window. Now I want to change 
> the appearance of this line in my code.
> In my delegate class I defined an IBOutlet NSBox *line and linked it in IB 
> with the correspondending horizontal line. 
> In the applicationDidFinishLaunching: method I change the border width and 
> color but nothing happens.
> What do I have to do to get access to that line?

You're trying to do this too soon. There's nothing that guarantees the window 
nib has been loaded at 'applicationDidFinishLaunching:'. The nib file's owner 
will get an 'awakeFromNib' message after the nib is actually loaded. That's 
where you would configure items in the nib.

Note that some objects used as nib file owners (window controllers, for 
example) have an alternate method that you should override instead of 
'awakeFromNib' -- it's 'windowDidLoad' in the case of a window controller. You 
should consult the appropriate class reference to find out if the class has 
such a method.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Cocoa alternative for method aliasing?

2011-03-29 Thread Lou Zell
On Tue, Mar 29, 2011 at 5:16 PM, WT  wrote:

> On Mar 29, 2011, at 4:25 PM, Matt Neuburg wrote:
>
> > On Tue, 29 Mar 2011 11:20:31 -0700, Lou Zell  said:
> >> I have a subclass of UIButton, call it MyButton, that I would like to
> >> function as a vanilla UIButton but also pass touch events to the next
> >> responder (I'm interested in eventually getting the events in
> >> UIViewController).  I can do something like this in MyButton:
> >>
> >> -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
> >> {
> >> [[self nextResponder] touchesBegan:touches withEvent:event];
> >> }
> >
> > Don't do that. The way to pass touches up the responder chain is by
> calling super. This will do exactly what you're after, I think.
> >
> > However, as already implied, you might be better off with a different
> architecture. It isn't at all clear why you'd do what you're describing. Let
> the button act as a button. If you need further information about what's
> going on, consider a gesture recognizer, perhaps, or just use the button's
> control events. In any case there should be no need to interfere at the very
> low level of the touches... responder methods. There are *many* ways to
> interfere with aspects of touch delivery; they are quite interesting, but be
> careful or you'll break something.
> >
> > m.
>
> Moreover, according to the Event Handling Guide for iOS,
>
>
> http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MultitouchEvents/MultitouchEvents.html
>
> "Important: If your custom responder class is a subclass of UIView or
> UIViewController, you should implement all of the methods described in “The
> Event-Handling Methods.” If your class is a subclass of any other UIKit
> responder class, you do not need to override all of the event-handling
> methods; however, in those methods that you do override, be sure to call the
> superclass implementation of the method (for example, super
> touchesBegan:touches withEvent:theEvent];). The reason for this guideline is
> simple: All views that process touches, including your own, expect (or
> should expect) to receive a full touch-event stream. If you prevent a UIKit
> responder object from receiving touches for a certain phase of an event, the
> resulting behavior may be undefined and probably undesirable."
>
> and, further down,
>
> "Handling Events in Subclasses of UIKit Views and Controls
> If you subclass a view or control class of the UIKit framework (for
> example, UIImageView or UISwitch) for the purpose of altering or extending
> event-handling behavior, you should keep the following points in mind:
>
> - Unlike in a custom view, it is not necessary to override each
> event-handling method.
> - Always invoke the superclass implementation of each event-handling method
> that you do override.
> - Do not forward events to UIKit framework objects."
>
> W.


Yikes, thanks for pointing that out!
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Big Core Data, countForFetchRequest, and GCD

2011-03-29 Thread Heath Borders
For thread-safety's sake why don't you just create a separate
NSManagedObjectContext for your asyncTask?  They are cheap.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Tue, Mar 29, 2011 at 4:38 PM, Steve Mykytyn  wrote:
> countForFetchRequest seems to bog down on really big collections of
> entities.  For approx 170K entities it takes around 10 seconds on an iPhone
> 3GS to count them, which is a problem in a UITableView where you are trying
> to display a list of entities and associated counts.
>
> A GCD based solution, that queues up countForFetchRequest on a concurrent
> queue for each entity, and then updates the corresponding cell when
> finished, seems to work pretty well, although one or two big entity counts
> essentially bog down all the requests behind them.  Counts are cached so
> that countForFetchRequest is only called once for any entity.
>
> Code below, can anyone suggest any further optimization or different
> approaches that might be more effective?
>
> (I'm aware of the danger of multi-threading core data - this particular
> managed object context never changes and nothing is happening to it on other
> threads when this read is going on)
>
> - (void) countEntitiesNamed:(NSString *)entityName
> inContext:(NSManagedObjectContext *)context forIndexPath:(NSIndexPath
> *)indexPath {
>
> NSNumber *rowCountObject = [self.rowCountMD valueForKey:entityName];
>
> if (rowCountObject) return;
>
> //
> http://www.mikeash.com/pyblog/friday-qa-2009-08-28-intro-to-grand-central-dispatch-part-i-basics-and-dispatch-queues.html
>
> dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
> 0), ^{
>
>  NSEntityDescription *ed;
>  NSFetchRequest  *frq;
>
>  frq = [[[NSFetchRequest alloc] init] autorelease];
>  ed = [NSEntityDescription entityForName:entityName
> inManagedObjectContext:context];
>  [frq setEntity:ed];
>  NSDate *startDate = [NSDate date];
>  NSUInteger rowCount = [context countForFetchRequest:frq error:nil];
>  NSTimeInterval timeInterval = -[startDate timeIntervalSinceNow];
>  DLog(@"%0.2lf seconds for %d %@ ",timeInterval,rowCount,entityName);
>
>      dispatch_async(dispatch_get_main_queue(), ^{
>  [rowCountMD setValue:[NSNumber numberWithInteger:rowCount]
> forKey:entityName];
>  UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
>  cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ objects",
>      [NSNumberFormatter localizedStringFromNumber:[NSNumber
> numberWithInteger:rowCount]
>       numberStyle:NSNumberFormatterDecimalStyle]];
>
>       });
>  });
>
>
> }
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com
>
> This email sent to heath.bord...@gmail.com
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com