Changing NSSliderCell's knob thickness

2009-08-16 Thread Brandon Walkin
I'm trying to make a vertical slider with a knob that's 1 pt tall. I  
can't quite figure out how to do this without rewriting NSSliderCell.


Overriding -knobThickness and returning a particular thickness doesn't  
seem to have any effect on the thickness of the knob. The - 
setKnobThickness: method is deprecated, but it too seems to have no  
effect on the knob size.


I could fake it by drawing a 1 pt tall line in the center of the large  
knob rect I'm provided and drawing the slider track with an inset on  
both sides so the 1 pt tall knob can reach both ends of the slider.  
The issue with that is when the area on the track near the knob is  
clicked, the knob won't move to that position. And when that area on  
the track is dragged, the knob moves as though it's being dragged.  
Since NSSliderCell thinks the knob is thicker, it thinks the click is  
on the knob instead of the track.


I've made a basic sample app that you can play with: 
http://www.box.net/shared/ylqm2uck5o

Any help would be appreciated. Thanks.

Brandon
___

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


Stymied by NSCollectionView

2009-08-16 Thread Andrew McClain
I've been reading docs and looking at IconCollection for the last week and I
still can't really figure this out.
Here's the behavior I want to model: pretend I'm making poker dice game. I
have a visual representation of the dice, and I want to select a certain
number of them each round.

Right now I'm using NSCollectionView with a prototype view that has a text
field (for a representation of the dice) and a button (for toggling
selection). Eventually I'll just use an image representation, but I'm just
trying to get this to work now.

When the user clicks the button in a view, the corresponding die will be
added into a "diceinhand" array in my AppController.
I can't figure out how, though, to connect the button in a way that
allows the AppController to understand which die has been selected
-- that is, I can't find any way to pass the representedObject associated
with my replicated view to any controller (but perhaps I'm thinking about
that incorrectly).

1. Can I call a selector on the representedObject itself from the view?
Where would I set that up that programmatically (I'm assuming you can't do
that with IB)?
2. Do I abandon the "selection buttons" and try and use the selection code
of NSCollectionView? Does that mean the user needs to shift-click to select
multiple dice? Do I then somehow listen to the selection changes on the
ArrayController via Key-Value observers? Since I'm just adding a reference
to the selected dice in another array, isn't there a way to bind my
DiceInHand array to the selection of my ArrayController?

I'm happy to read docs, it just seems that everything I've been reading
deals mostly with binding simple values in a prototype view.

Thank you,
Andrew
___

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: Printing Multiple-Pages Issue

2009-08-16 Thread Renzil D'Souza
Hi,

No, I want control over how many pages I'm dividing my view into, and
precisely how I divide my image into those pages. I'm writing a function for
someone to print N images from 1 large image, and the user of the function
may want to supply the ratios at which to divide the image (vertically
only). I found out what my problem was - in my call to CGContextDrawImage(),
I was passing the CGRect I used to get the sub-image which was wrong. That,
combined with some transformation stuff in my code, messed it up.

So if I print a really large view, it will print on multiple pages - is this
what is meant by 'Collated' ?

Thanks,
Renzil


2009/8/17 Graham Cox 

>
> On 17/08/2009, at 3:56 AM, Renzil D'Souza wrote:
>
>  I'm trying to print a really large image into 'N' pages. So I over-rode
>> 'knowsPageRange' and 'rectForPage'.
>>
>
>
> If you're simply trying to tile a large view over 'n' pages, you don't need
> to do this - that's what it will do by default with no intervention on your
> part. Try that first and see if it does what you want.
>
> --Graham
>
>
>
___

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: iPhone: detect if docked?

2009-08-16 Thread David Duncan
More than likely yes. But I'm not certain you can use the EA framework  
to detect such a situation anyway (if someone knows for certain I'm  
happy to be wrong here). And in absence of further data as to the  
nature of the power source, it would be difficult for a developer to  
recognize this situation.


Caveat implementor.

On Aug 15, 2009, at 2:19 PM, Jack Carbaugh wrote:

ah but wouldn't this be a FAIL if say, the user was using a battery  
extender for a quick recharge ?


On Aug 15, 2009, at 3:40 AM, David Duncan wrote:


On Aug 14, 2009, at 4:29 AM, Sean Kline wrote:


Is another option to use the External Accessory framework?


I don't think so. A simple charger may not appear as any kind of  
accessory at all (consider the wall-outlet charger) so EA wouldn't  
track it. If you want to know if the device is on external power  
(which in this particular case would likely be a false positive on  
one of those external battery packs) then you want to know if the  
battery status is "charging".


--
David Duncan
Apple DTS Animation and Printing

___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Jerry Krinock

To Squ:

I read through all your posts today and, although several people have  
asked you, I still don't see where you've confirmed that this garbage/ 
cleanup is indeed a performance issue.  My recommendation remains that  
you confirm this first, especially now that multithreading Core Data  
has been put on the table as a "solution"...


On 2009 Aug 16, at 20:22, BJ Homer wrote:


you may be able to simply put
the cleanup logic into a background thread and fire it off  
immediately.


BJ, I would omit the word "simply"

I'm not a Core Data expert (yet), but you will need to give the  
background

thread a separate NSManagedObjectContext...

That's how I'd do it, anyway.


Well, not me.  One last time, Squ: I'd step back and confirm that I  
really need to do this.  I find both of your assertions (1) that  
leaving the garbage around for awhile is a performance hit and (2)  
that cleaning it up in the main thread immediately is a performance  
hit -- to be surprising.


___

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: NSProgressIndicator not animating when part of NSAnimation

2009-08-16 Thread Michael Vannorsdel
I had this problem once when I had accidentally called  
makeKeyAndOrderFront: on the window from a secondary thread.  Animated  
system controls and tracking rects would work.



On Aug 15, 2009, at 7:45 PM, Thomas Bauer wrote:


Thanks for your response.
I am not quite sure if I understand you correctly but here is what I  
tried:


- Calling the whole code (starting the NSAnimation and the  
ProgressIndicator animation) using a performSelectorOnMainThread  
does not fix it.
- Calling the whole code using performSelector delayed does not fix  
it.
- Calling the NSProgressIndicator startanimation alone on the main  
thread does not fix it either.


However your response triggered an idea and this works:

[myViewNSAnimation startAnimation];
[myindicator performSelector:@selector(startAnimation:)  
withObject:nil afterDelay:1.1];


Does the trick, but only if the delay is greater than the duration  
of the NSAnimation.
In short, if I call the selector (even on the main thread) during  
the NSAnimation is running, it does not work.
That would make some sense - but why the same thing works without  
those tricks in awakefromnib does not make sense to me...
Because I would think that running it in awakefromnib and running it  
using performSelectorOnMainThread should be somewhat identical?


While it is great that I have a workaround ... I would appreciate  
any explaination on why it behaves that way.

Technically this does not make sense to me.


___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread BJ Homer
On Sun, Aug 16, 2009 at 10:35 AM, Squ Aire  wrote:

>
> I am not *explicitly* marking anything as garbage. Whenever a user decides
> to remove a ValidKeys managed object, corresponding key-value pairs in all
> the userInfo dictionaries are *conceptually* marked as garbage. This is
> because I do not want to show the beach ball to the user while things are
> getting cleaned up. I want to postpone the cleaning up until later when it
> will not bother the user.


If the goal is to avoid beachballing the user, you may be able to simply put
the cleanup logic into a background thread and fire it off immediately.
 Beachballs only happen when the main thread is blocked.  Now, if this is
data that is displayed and manipulated in the UI, you may need to do some
synchronization to avoid race conditions.  But in general, avoiding
beachballs is a matter of doing things in the background instead of delaying
it until later; if you wait to clean up garbage, you'll just postpone your
beachball until later.  Now, there may still be merit to batching the
deletions; you could make a background thread that runs cleanup every 1.0
seconds on any object in a "deletion queue" or something.

I'm not a Core Data expert (yet), but you will need to give the background
thread a separate NSManagedObjectContext.  As you mentioned, you'll need to
notify the main thread's MOC of the changes.  Luckily, in 10.5 there's
-[NSManagedObjectContext
mergeChangesFromContextDidSaveNotification:],
which takes care of that.  Register an observer on
the NSManagedObjectContextDidSaveNotification notification with the
background MOC as the object and the main MOC as the target, and whenever
the background thread performs a save, the main thread's MOC will be
updated.

That's how I'd do it, anyway.

-BJ
___

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


Displaying an animated graph (= nodes and edges)

2009-08-16 Thread Kaspar Fischer

Dear list,

After some hours of research I realise that I need some advice on how  
to tackle this: My goal is to render a graph [1] consisting of at most  
100 nodes and 300 edges (most of the time the graph will be much  
smaller, though). I have an algorithm to position the nodes and the  
algorithm works in iterations so that I can use intermediate positions  
to animate the placement of the nodes. Ultimately, I want a scrolling  
view that allows the user to view the graph and pinch-zoom or double- 
tap zoom into it. When zooming in and when the user scrolls, it's okay  
if the parts that become visible are initially blurry and will get  
redrawn a little later. I need to be able to catch touch events on the  
nodes.


I have played around with a UIScrollView and an associated  
UIViewController; the scroll view contains a  
custom view that draws the complete graph in its -(void)drawRect: 
(CGRect)rect method. I have two problems with this approach: On the  
one hand, when the user zoomed in, even though drawRect: is called  
again, it draws a blurry graph [2]. On the other hand, I am not sure  
how to animate the graph with this approach: I have no layers so I  
basically have to do the animation myself and I fear this does not  
leverage any of the iPhone's hardware capabilities (layer composition,  
etc).


I plan to have a background thread that runs the algorithm and at the  
end of each iteration tells the main (UI) thread the new positions of  
the nodes.


The questions I have:

1. Would you implement each graph node as a CALayer so that it can  
easily be animated, or will that result in too many layers for the  
iPhone's Core Animation framework?


2. Should I use UIScrollView? It already provides the scrollbars, the  
zooming and panning but I could not remove the blurriness/unsharpness.


I have also come across CATiledLayer but I am not sure whether they  
were intended to have sublayers (representing the nodes and edges).


Thanks in advance for any advice on any of these questions!
Kaspar

--
[1] a drawing as you can see on http://en.wikipedia.org/wiki/Graph_(mathematics)
[2] http://halmueller.wordpress.com/2008/10/08/a-very-simple-uiscrollview-demo/
___

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


Stymied by NSCollectionView

2009-08-16 Thread Andrew McClain
I've been reading docs and looking at IconCollection for the last week and I
still can't really figure this out.
Here's the behavior I want to model: pretend I'm making poker dice game. I
have a visual representation of the dice, and I want to select a certain
number of them each round.

Right now I'm using NSCollectionView with a prototype view that has a text
field (for a representation of the dice) and a button (for toggling
selection). Eventually I'll just use an image representation, but I'm just
trying to get this to work now.

When the user clicks the button in a view, the corresponding die will be
added into a "diceinhand" array in my AppController.
I can't figure out how, though, to connect the button in a way that
allows the AppController to understand which die has been selected
-- that is, I can't find any way to pass the representedObject associated
with my replicated view to any controller (but perhaps I'm thinking about
that incorrectly).

1. Can I call a selector on the representedObject itself from the view?
Where would I set that up that programmatically (I'm assuming you can't do
that with IB)?
2. Do I abandon the "selection buttons" and try and use the selection code
of NSCollectionView? Does that mean the user needs to shift-click to select
multiple dice? Do I programmatically bind the DiceInHand array in my
AppController to the selectedObjects key of my array controller or do I need
another array controller to manage that?

I'm happy to read docs, it just seems that everything I've been reading
deals mostly with binding values in a prototype view.

Thank you,
Andrew
___

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: Turn off menu highlight in outline view?

2009-08-16 Thread Jerry Krinock


On 2009 Aug 16, at 17:21, Graham Cox wrote:


I have an outline view using source list style.

When I right-click on the view, the item under the mouse highlights  
with a blue outline independent of the current selection. This gives  
the impression that the menu command applies to that item, not the  
real selected item. In my case my menu commands pertain to the list  
as a whole, and therefore the current normal selection, so I'd like  
to turn off this additional highlight.


How? I couldn't find any means to do this, using a delegate method  
or otherwise.


Once upon a time, I wrote a class which disabled highlighting of cells  
which were not editable.  However, I see that I'm not using it at this  
time and recall that there were some issues with it.  Here it is.  The  
comments and hyperlink references will definitely be more useful to  
you than the code :)



#import 


/*!
 @briefA subclass of NSTableView that does not highlight cells
 which are not editable.

 @details  From: http://www.cocoabuilder.com/archive/message/cocoa/2006/6/1/164789 
:
 The "secret" is that you need to override the highlighting in two  
places:


 - The NSCell used in the table
 - The NSTableView itself

 I've done the second one, but I'm not sure how to do the first one  
without

 screwing up all the cells that I've set in Interface Builder.

 With the code below, it works perfectly in Tiger but in Leopard the
 first column of the clicked row is flashed in the highlight color  
whenever you click
 in a different column of that row.  If I ever wanted to fix that,  
and get

 rid of the hacks, supposedly the
 following method in all relevant NSCell subclasses would do it:

 If I ever figure that out, this should be done in the NSCell subclass:
 - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame
 inView:(NSView*)controlView {
 return nil;
 }

*/
@interface SSYSmartHiliTableView : NSTableView {
}

@end


#import "SSYSmartHiliTableView.h"
#import "NSColor+Tweak.h"
#import "NSView+ActiveControl.h"


/* Interesting References on this topic and related topics:
http://stoneship.org/journal/2005/using-a-nsoutlineview-as-a-source-list/
 http://chanson.livejournal.com/176310.html
 http://www.cocoadev.com/index.pl?IconAndTextInTableCell
 http://mattgemmell.com/source

 The blue-highlight color that NSTableView uses is this:

 + (NSColor *)alternateSelectedControlColor;// Similar to  
selectedControlColor; for use in lists and tables


 Note: for custom cells, you may want to simply return nil from this  
method to avoid having the NSCell do any background highlight color  
drawing:


 - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView: 
(NSView *)controlView;


 That only works in NSTableViews; it won't work with cells in  
NSBrowsers, which actually rely on this method to draw the  
highlighting (since it is a matrix of cells).


 corbin

 */


@interface SmartHiliTextCell : NSTextFieldCell {
}
@end

@implementation SmartHiliTextCell

- (void)drawInteriorWithFrame:(NSRect)cellFrame
   inView:(NSView *)controlView {
// Note: When a cell if "highlighted", this is the same as when its
// row or column are "selected".  "Highlighted" <==> "Selected".

// ARG!!! I set the cell to be not editable below, in  
awakeFromNib,

// but SOMETHING comes by and later sets it to be editable!

if(![self isHighlighted]) {
// Cell is not selected --> Let super draw text in black
[super drawInteriorWithFrame:cellFrame
  inView:controlView] ;
}
else if ([self isEditable]) {
// Cell is selected and editable --> Draw text in white
NSRect inset = cellFrame;
inset.origin.x += 2;
NSDictionary* oldAttrs = [[self attributedStringValue]  
attributesAtIndex:0
 
effectiveRange:NULL] ;

NSMutableDictionary* newAttrs = [oldAttrs mutableCopy] ;
[newAttrs setValue:[NSColor whiteColor]
forKey:@"NSColor"] ;
[[self stringValue] drawInRect:inset
withAttributes:newAttrs] ;
[newAttrs release] ;
}
else {
// Cell is selected but not editable --> Draw nothing
// The editable controls (popup button, date picker)
// will be drawn in our rect.
}
}


@end

@implementation SSYSmartHiliTableView

- (void)highlightSelectionInClipRect:(NSRect)clipRect {

int selectedRow = [self selectedRow];
if(selectedRow != -1) {
// A row is selected

[self lockFocus];

// Get the appropriate color for the selected row
NSColor* color ;
if([self isTheActiveControl]) {
color = [NSColor selectedTextBackgroundColor] ;
// This is what is set in System Preferences
//   > Appearance > Highlight Color (for selected text)
color = [color colorTweakBrightness:-.20] ;
 

Re: Printing Multiple-Pages Issue

2009-08-16 Thread Graham Cox


On 17/08/2009, at 3:56 AM, Renzil D'Souza wrote:

I'm trying to print a really large image into 'N' pages. So I over- 
rode

'knowsPageRange' and 'rectForPage'.



If you're simply trying to tile a large view over 'n' pages, you don't  
need to do this - that's what it will do by default with no  
intervention on your part. Try that first and see if it does what you  
want.


--Graham


___

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


Turn off menu highlight in outline view?

2009-08-16 Thread Graham Cox

I have an outline view using source list style.

When I right-click on the view, the item under the mouse highlights  
with a blue outline independent of the current selection. This gives  
the impression that the menu command applies to that item, not the  
real selected item. In my case my menu commands pertain to the list as  
a whole, and therefore the current normal selection, so I'd like to  
turn off this additional highlight.


How? I couldn't find any means to do this, using a delegate method or  
otherwise.


--Graham


___

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: Problem with Float type variable

2009-08-16 Thread Scott Ribe
> I mean there is only 1 digit after the decimal. It should not have the range
> problem with a value this small.

Because you're translating from a decimal representation to a binary one,
and back again. Consider a very simple case: 0.1. What sum of powers of two
equals 0.1? (Hint, it's an infinite series, and thus not representable in
any fixed number of binary digits.)


-- 
Scott Ribe
scott_r...@killerbytes.com
http://www.killerbytes.com/
(303) 722-0567 voice


___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Caleb Strockbine

On Aug 16, 2009, at 3:02 PM, Graham Cox  wrote:


On 17/08/2009, at 1:47 AM, Squ Aire wrote:


Key-value pairs in the userInfo dictionaries are "marked as garbage"
as the app is running and depending on various factors.


Don't "mark as garbage" - delete them. Problem solved. If you need
them to stick around in the garbage state, they're not garbage!


My guess (and what more can we do, really?) is that Squ is generating  
these keys automatically, maybe based on the date or some user  
preferences or something, and storing values for those keys for each  
user. At some point later on, due to passage of time, changing  
conditions, whatever, some of the keys become invalid. I think that  
even though he(?) says the key/value pairs are marked as garbage, he  
probably means that the keys are removed from some list of valid keys.


Squ, if this is all correct, some things to consider:

- Rather than removing invalid key/value pairs from the userInfo  
dictionary, it may be faster to copy the valid keys to a new  
dictionary and dump the old one.


- Have you profiled your code? There are a few things in your proposed  
operation which sound like they might take up a lot of time, but it's  
impossible to know for sure without profiling. Implement the simplest  
solution you can think of and then do some measuring.


- Depending on the results of the profiling, you might want to rethink  
the data structure you're using, or how you're using that structure.  
For example, if you keep a dictionary for each of the attributes that  
are currently represented by your userInfo keys, and use Employee name  
or ID or whatever as the keys into each of those dictionaries, then  
removing all the data for a garbage key is just a matter of deleting  
the corresponding dictionary. (Of course, you still have to solve the  
same problem you have now, but you only have to do it when an Employee  
is removed from the system.) The point is: let your performance data  
and operational requirements be your guide.


There are a lot of smart people on this list, and they'd be happy to  
help them if you give them something concrete to work with. Sometimes  
there are reasons that you can't reveal exactly what you're doing, but  
if that's the case you ought to work up some sample code that  
illustrates the problem you're having.


-Caleb
___

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: Adding string encodings CoCoa

2009-08-16 Thread Alastair Houghton

On 16 Aug 2009, at 20:46, tim lindner wrote:


Is it possible to add an encoding to CoCoa?

I have some text data from a legacy system which is ASCII for 0-127,  
but

128-255 is unique to the system. I'd like to load it into a text view
and "just have it work".


Hi Tim,

It's worth checking whether the character set is *really* unique to  
that system.  Even if Cocoa and Core Foundation don't support a given  
encoding, it's possible that iconv (see man 3 iconv_open) will support  
it (actually the latter even supports a couple of encodings that *are*  
unique, give or take).


And if you can't find it in any of those places, it's also worth  
checking the Unicode website, as there are predefined mappings for  
various character encodings; you can find those here:


  

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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: Adding string encodings CoCoa

2009-08-16 Thread Steve Christensen
Well, certainly one way would be to preprocess the text buffer,  
converting the custom characters into a standard encoding like UTF-8,  
then passing the processed buffer into +[NSString  
stringWithUTF8String:]. At that point it would "just work" since it's  
in a known encoding.


Depending on what your legacy encoding looks like, the conversion may  
be as simple as creating a 256-byte table if it turns out that the  
legacy characters map to single-byte UTF-8 sequences or a 256xn table  
if there are multi-byte sequences, and then using it to map legacy- 
>UTF-8.


steve


On Aug 16, 2009, at 12:46 PM, tim lindner wrote:


Is it possible to add an encoding to CoCoa?

I have some text data from a legacy system which is ASCII for  
0-127, but

128-255 is unique to the system. I'd like to load it into a text view
and "just have it work".

What options do I have?


___

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


Adding string encodings CoCoa

2009-08-16 Thread tim lindner
Is it possible to add an encoding to CoCoa?

I have some text data from a legacy system which is ASCII for 0-127, but
128-255 is unique to the system. I'd like to load it into a text view
and "just have it work".

What options do I have?

-- 
tim lindner
tlind...@macmess.org  Bright
___

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


Printing Multiple-Pages Issue

2009-08-16 Thread Renzil D'Souza
Hi,

I'm trying to print a really large image into 'N' pages. So I over-rode
'knowsPageRange' and 'rectForPage'. Since I was able to successfully draw on
a single page, my rectForPage function returns the entire 'print view frame'
itself, and I draw a sub-image in this frame. My understanding is that
rectForPage simply returns an NSRect in the print view to which all drawing
operations are clipped. So I don't want to clip anything, but I do it myself
by creating a sub-image (using CGImageCreateWithImageInRect) and drawing it
like any other image on the entire view. But this doesn't seem to work, I'm
getting just a single line on my 2nd page, and from my 3rd page onwards I
don't get any output. My first page appears fine. What could be wrong? Here
is the basic skeleton of the code I'm using:

// BEGIN CODE

void OnPrint()
{
PrintView *printView = [[PrintView alloc] initWithFrame:printViewFrame];
NSPrintOperation *printOp = [NSPrintOperation
printOperationWithView:printView];
[printOp runOperation];
}

Class print view functions over-ridden:

- (BOOL) knowsPageRange: (NSRangePointer) aRange
{
aRange->location = 1;
aRange->length = totalPages;
return YES;
}

- (NSRect) rectForPage: (int) page
{
mCurrentPage = page;
return [self frame];
}

- (void) drawRect: (NSRect) rect
{
// assume a CGImageRef 'sourceImage', its width and height as
'imageWidth' and 'imageHeight'
CGRect imageRect = {{0, imageHeight*((float)(numPages-1)/totalPages)},
{imageWidth, imageHeight / totalPages} };
CGImageRef subImage = CGImageCreateWithImageInRect(sourceImage,
imageRect);

NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
CGContextRef context = (CGContext*)[currentContext graphicsPort];

CGContextDrawImage(context, imageRect, subImage);
}

// END CODE

Thanks,
Renzil
___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Squ Aire


> Don't "mark as garbage" - delete them. Problem solved. If you need
> them to stick around in the garbage state, they're not garbage!


I am not *explicitly* marking anything as garbage. Whenever a user decides to 
remove a ValidKeys managed object, corresponding key-value pairs in all the 
userInfo dictionaries are *conceptually* marked as garbage. This is because I 
do not want to show the beach ball to the user while things are getting cleaned 
up. I want to postpone the cleaning up until later when it will not bother the 
user.
_
Share your memories online with anyone you want.
http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1___

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


[OT] Re: Running otest in Instruments

2009-08-16 Thread Alastair Houghton

On 16 Aug 2009, at 17:11, Gideon King wrote:

I have some tests that are working fine in xcode, but I am having  
difficulty getting them running in Instruments. Would appreciate  
help to sort out the args.


Perhaps xcode-users would be a better list to ask this question on?

Kind regards,

Alastair.

--
http://alastairs-place.net



___

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


Running otest in Instruments

2009-08-16 Thread Gideon King
I have some tests that are working fine in xcode, but I am having  
difficulty getting them running in Instruments. Would appreciate help  
to sort out the args.


Currently I am using

Executable: /Developer/Tools/otest
Environment: NSZombieEnabled YES
Args: -SenTest Self /whatever/Whatever.octest

Output is as follows:

17/08/09 1:44:42 AM otest[7582] Error loading /whatever.octest/ 
Contents/MacOS/Whatever:  dlopen(/whatever.octest/Contents/MacOS/ 
Whatever, 265): no suitable image found.  Did find:
 /whatever.octest/Contents/MacOS/Whatever: mach-o, but wrong  
architecture
17/08/09 1:44:42 AM otest[7582] The test bundle at /whatever.octest  
could not be loaded because it is built for a different architecture  
than the currently-running test rig (which is running as unknown).
17/08/09 1:44:42 AM [0x0-0xf00f0].com.apple.Instruments[7554]  
2009-08-17 01:44:42.582 otest[7582:807] Error loading /whatever.octest/ 
Contents/MacOS/Whatever:  dlopen(/whatever.octest/Contents/MacOS/ 
Whatever, 265): no suitable image found.  Did find:
17/08/09 1:44:42 AM [0x0-0xf00f0].com.apple.Instruments[7554]  / 
whatever.octest/Contents/MacOS/Whatever: mach-o, but wrong architecture
17/08/09 1:44:42 AM [0x0-0xf00f0].com.apple.Instruments[7554]  
2009-08-17 01:44:42.627 otest[7582:807] The test bundle at / 
whatever.octest could not be loaded because it is built for a  
different architecture than the currently-running test rig (which is  
running as unknown).
17/08/09 1:44:42 AM otest[7583] *** NSTask: Task create for path '/ 
whatever.octest/Contents/MacOS/Whatever' failed: 8, "Exec format  
error".  Terminating temporary process.
17/08/09 1:44:42 AM [0x0-0xf00f0].com.apple.Instruments[7554]  
2009-08-17 01:44:42.645 otest[7583:203] *** NSTask: Task create for  
path '/whatever.octest/Contents/MacOS/Whatever' failed: 8, "Exec  
format error".  Terminating temporary process.


This seems to suggest that the otest will not run my tests because  
their is an architecture mismatch...but it works fine inside xcode.


Any suggestions?


Gideon

___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Graham Cox


On 17/08/2009, at 1:47 AM, Squ Aire wrote:

Key-value pairs in the userInfo dictionaries are "marked as garbage"  
as the app is running and depending on various factors.



Don't "mark as garbage" - delete them. Problem solved. If you need  
them to stick around in the garbage state, they're not garbage!


--Graham


___

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: Loading an AS dict that defines 'point' also causes 'points' to be defined??

2009-08-16 Thread Matt Neuburg
On Wed, 5 Aug 2009 10:31:35 -0600, David Springer
 said:
>Folks,
>
>I recently switched to using an .sdef in my Cocoa app for defining AS event
>handlers.  The problem is that suddenly it looks like my app defines the
>property 'points' and this breaks other apps which send AS events to mine.
>
>In my .sdef, I do not define a 'point' or 'points' property, nor do I do
>this in code.  When I use Script Editor, it shows that 'point' is a keyword
>but 'points' is not, unless my app is running.
>
>Any clues as to what is going on here?  Is there a way I can "undefine"
>'points' in my .sdef, or in code?  Is there a way to debug this, either via
>Cocoa APIs or some tool that shows me what properties are being set by which
>script/script addition?

"Doctor, doctor, it hurts when I go like this!"

"So don't go like that!"

(1) The term "point" is already defined by AppleScript. That means that so
is "points". You've created a terminology conflict.

(2) When you use the sdef format, generation of plurals is automatic. So
switching to sdef probably uncovered this problem whereas previously it was
masked.

(3) I wrote a book that might help you. It tells you why it's important to
avoid terminology conflicts, how to learn that "point" is already a defined
term, etc.

m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread I. Savant

On Aug 16, 2009, at 11:47 AM, Squ Aire wrote:

So, just imagine that I am dealing with this situation, have this  
garbage and need to clean it up :)


  [ FACE-PALM ]

  Unspecific question? Unspecific answer:

Memory Management Using Core Data
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdMemory.html#//apple_ref/doc/uid/TP40001860

Non-Standard Persistent Attributes
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdNSAttributes.html#//apple_ref/doc/uid/TP40001919

Multi-Threading with Core Data
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdMultiThreading.html#//apple_ref/doc/uid/TP40003385

Core Data Performance
http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468

--
I.S.




___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Squ Aire


> Seems to me that the source of the problem is the mixing of transient
> and persistent key-value pairs within the same dictionary. If you
> store the transient pairs in a dictionary of their own, that whole
> dictionary could be transient.

It's not like that. I don't decide beforehand what is valid and what is 
garbage. Key-value pairs in the userInfo dictionaries are "marked as garbage" 
as the app is running and depending on various factors. It is not known 
beforehand. So I cannot tell what is transient and what is not.


So, just imagine that I am dealing with this situation, have this garbage and 
need to clean it up :)
_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread I. Savant

On Aug 16, 2009, at 11:34 AM, Squ Aire wrote:



For now, just imagine that a set of valid (non-garbage) keys are  
stored in a ValidKeys entity (with a single attribute called 'key'  
of type string). Or just imagine some global array storing those  
keys if you like that better.



...
Surely it is much more efficient to do this with a bunch of  
employees at once, rather then doing it for a single employee one by  
one during didTurnIntoFault, wouldn't you agree?


  No, we wouldn't. We CAN'T rightly agree without a lot more  
information than you've given because there's no way to know for sure.  
None.


  You're asking how best to solve something but are stubbornly  
refusing to answer specific requests for clarification while limiting  
our possible answers to the scope of some half-baked solution you  
think might be right. That's very annoying.


  Do you *really* want to spend your time pursuing a half-assed, ill- 
informed answer? Help us help you - BE SPECIFIC.


--
I.S.




___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread I. Savant

On Aug 16, 2009, at 11:22 AM, Squ Aire wrote:

Just to make it clear: The whole userInfo dictionary will tend to  
NOT be "garbage". Only a subset of key-value pairs within the  
userInfo dictionaries for the employees will be "garbage". I want to  
get rid of this subset without bothering the user in any way.


Therefore, the attribute must persist and transient properties will  
not work in this case. I hope my problem is clearer now.


  About as clear as mud, but slightly clearer mud. ;-)

Read:
http://catb.org/~esr/faqs/smart-questions.html

  You're going to have to "come clean" as it were. If you want  
suggestions for a good way to handle this, there's no way to get good  
ones unless you describe exactly what this user info is for, what kind  
of information it is, how it's used, what causes some of its values to  
become "garbage", etc. Also, how many "Employee"s will have their  
userInfo modified in a session? Have you specifically tested the  
performance? Again, how exactly is this deletion/cleanup implemented?  
What persistent store type are you using (this makes a HUGE  
difference)? Just to demonstrate the significance of this question,  
I'll ask it for the third time in this thread (and the second in this  
message): HAVE YOU TESTED PERFORMANCE? If so, where's the data?


  The answers to these questions (and I'm sure a few more) directly  
dictate the answer(s) to *your* question. This is not something for  
which a general answer will suffice, so you need to *be specific*.


  Seriously, if you're not going to answer the specific, pointed  
questions about performance, implementation, and your data access  
patterns, nobody can (or will continue trying to) help you. Nobody  
likes repeating themselves when taking the time to help someone for  
free ... ;-)


--
I.S.


___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Squ Aire

For now, just imagine that a set of valid (non-garbage) keys are stored in a 
ValidKeys entity (with a single attribute called 'key' of type string). Or just 
imagine some global array storing those keys if you like that better.

Now, imagine that we have chosen a bunch of employees to "clean up" (say using 
that possibly bad randomness approach I suggested). What we have to do first is 
fetch all ValidKeys managed objects. Then, we will want to loop through the 
chosen employees, and for each employee loop through its userInfo dictionary 
and get rid of all key-value pairs having keys that are not within the fetched 
ValidKeys managed objects.

Surely it is much more efficient to do this with a bunch of employees at once, 
rather then doing it for a single employee one by one during didTurnIntoFault, 
wouldn't you agree?


> I believe many of us would be interested to know how you determined
> that cleaning it up "on the go/before persisting" degrades
> performance. Seems surprising to me.



--.
_
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Sherm Pendley
On Sun, Aug 16, 2009 at 11:22 AM, Squ Aire wrote:
>
> Just to make it clear: The whole userInfo dictionary will tend to NOT be 
> "garbage". Only a subset of key-value pairs within the userInfo dictionaries 
> for the employees will be "garbage". I want to get rid of this subset without 
> bothering the user in any way.
>
> Therefore, the attribute must persist and transient properties will not work 
> in this case. I hope my problem is clearer now.

Seems to me that the source of the problem is the mixing of transient
and persistent key-value pairs within the same dictionary. If you
store the transient pairs in a dictionary of their own, that whole
dictionary could be transient.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Graham Cox


On 17/08/2009, at 1:22 AM, Squ Aire wrote:

Just to make it clear: The whole userInfo dictionary will tend to  
NOT be "garbage". Only a subset of key-value pairs within the  
userInfo dictionaries for the employees will be "garbage". I want to  
get rid of this subset without bothering the user in any way.



How are you going to tell garbage from non-garbage? You'd need to flag  
it - and doing that is just as much (if not more) work than simply  
deleting the item (which isn't expensive, whatever you might think).


--Graham


___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Squ Aire

Thanks for the reply.

Just to make it clear: The whole userInfo dictionary will tend to NOT be 
"garbage". Only a subset of key-value pairs within the userInfo dictionaries 
for the employees will be "garbage". I want to get rid of this subset without 
bothering the user in any way.

Therefore, the attribute must persist and transient properties will not work in 
this case. I hope my problem is clearer now.


> This is where the confusion exists ... you say
> "temporary" (transient), then you say "save" (persistent). Which is it?



--.
_
With Windows Live, you can organize, edit, and share your photos.
http://www.microsoft.com/middleeast/windows/windowslive/products/photo-gallery-edit.aspx___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread Jerry Krinock


On 2009 Aug 16, at 05:00, Squ Aire wrote:

I really don't want to clean the garbage "on the go/before  
persisting" because I don't want to let the user wait unnecessarily.  
The purpose of this garbage buildup is the benefit of more  
responsive app, at the cost of little more temporary storage.


I believe many of us would be interested to know how you determined  
that cleaning it up "on the go/before persisting" degrades  
performance.  Seems surprising to me.


___

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: Cleaning "garbage" in Core Data

2009-08-16 Thread I. Savant

On Aug 16, 2009, at 8:00 AM, Squ Aire wrote:

I have an Employee entity with the attribute userInfo, which is a  
binary data type that stores some NSDictionary of key-value pairs.


  Sounds reasonable.

With time, as the user uses the app, "garbage" will pile up (albeit  
gradually) in these dictionaries that are associated with the  
employees. And by "garbage", I mean key-value pairs that are not  
needed any more.


  ... so you don't want the "userInfo" attribute to persist? In this  
case, make sure you understand transient attributes and don't persist  
the "userInfo" attribute.



I really don't want to clean the garbage "on the go/before  
persisting" because I don't want to let the user wait unnecessarily.  
The purpose of this garbage buildup is the benefit of more  
responsive app, at the cost of little more temporary storage. I need  
your advice on how to actually make it temporary.


  *Temporary* storage == transient attribute. This should suffice for  
most cases.


  If, on the other hand, there's so much data that you need to clean  
it up before the app quits, you really need to ask yourself this  
question: Why aren't you cleaning it up immediately as soon as it's no  
longer needed?


  Continued below:


How would you clean up this garbage in such a way the user will not  
notice it? I have thought of two ways. Which would work? Which are  
impossible? Which is better? Do you recommend any others?


1.
When the app is idle, keep selecting random employees to clean up  
key-value pairs within them ...[snip]... Will Apple's "Treading  
Programming Guide" help me with it?


  First, I realize you mistyped and left out the "h", but "Treading  
Programming" sounds like one of those methodology books whose title  
reflects the thing to avoid. ;-)


  Second, sure, you could have a background cleanup thread, but the  
net result of this approach is roughly the same as your second ...




2.
...[snip]... would I be able to create threads for this task, create  
MOCs for each of them, do the cleaning on those threads, and hand  
those threads to GCD?


  I believe (hope) this is public knowledge, but GCD is essentially  
"easier concurrency" without worrying about thread management.


  "Six of one, half-dozen of the the other."



It sounds fancy and cool, but is this even a realistic solution?


  Sure it is, but your suspicions are correct:


The problem I can think of is that when actually saving the "main  
MOC", the main MOC will still contain the garbage and wouldn't be  
able to figure out whether to persist the garbage or not.




  I really think you need to (re)read the Core Data Programming  
Guide. You will of course need to manage the merging of the different  
contexts yourself and that will require you to think this through long  
and hard.


  Of course if your "userInfo" attribute does not require  
persistence, none of this should even be necessary.



Finally, note that I cannot use willTurnIntoFault, and clean up the  
garbage there, because it is very inefficient in my case to do the  
clean up for the managed objects one by one.


  Okay, this is what it comes down to: You need to tell us the exact  
nature of this attribute. Does it need to persist or not?


  Also, your assertion that -willTurnIntoFault is highly suspect.  
Where's your performance testing data to back it up? How have you  
implemented it? If the entity instance was faulted and the "userInfo"  
data is transient, isn't this the perfect time to let the "userInfo"  
data go? As it's no longer needed on an instance-by-instance basis?



And again, the user would have to wait while saving, which is a bad  
solution.


  This is where the confusion exists ... you say  
"temporary" (transient), then you say "save" (persistent). Which is it?


--
I.S.




___

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


Obtain MobileMe username

2009-08-16 Thread David Kocher
What is the current best practice to obtain the MobileMe username as  
configured in the MobileMe Preference pane? Previously, the  
DotMacKit.framework allowed but this is no longer maintained with no  
64bit version available. One could search the Keychain for passwords  
of Kind ".Mac" but it doesn't sound very robust to rely on that  
arbitrary naming which could change anytime.


Thanks for any input.
~David

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

Cleaning "garbage" in Core Data

2009-08-16 Thread Squ Aire

I have an Employee entity with the attribute userInfo, which is a binary data 
type that stores some NSDictionary of key-value pairs.

With time, as the user uses the app, "garbage" will pile up (albeit gradually) 
in these dictionaries that are associated with the employees. And by "garbage", 
I mean key-value pairs that are not needed any more.

I really don't want to clean the garbage "on the go/before persisting" because 
I don't want to let the user wait unnecessarily. The purpose of this garbage 
buildup is the benefit of more responsive app, at the cost of little more 
temporary storage. I need your advice on how to actually make it temporary.

How would you clean up this garbage in such a way the user will not notice it? 
I have thought of two ways. Which would work? Which are impossible? Which is 
better? Do you recommend any others?


1.
When the app is idle, keep selecting random employees to clean up key-value 
pairs within them. Stop this process as soon as the app is not idle any more. 
Over time, this will tend to keep the app "clean", and the user won't notice 
anything. How could I do this? How can I figure out whether an app is idle? 
Will Apple's "Treading Programming Guide" help me with it?

2.
Judging from ONLY (yes, ONLY; do NOT break the NDA) the information already 
available on apple.com's GCD intro page and the nice PDF intro brochure they 
made for everyone, would I be able to create threads for this task, create MOCs 
for each of them, do the cleaning on those threads, and hand those threads to 
GCD? It sounds fancy and cool, but is this even a realistic solution? The 
problem I can think of is that when actually saving the "main MOC", the main 
MOC will still contain the garbage and wouldn't be able to figure out whether 
to persist the garbage or not.


Finally, note that I cannot use willTurnIntoFault, and clean up the garbage 
there, because it is very inefficient in my case to do the clean up for the 
managed objects one by one. And again, the user would have to wait while 
saving, which is a bad solution. I really have to do them in batches, in such a 
way that the user will not notice it.



--.
_
With Windows Live, you can organize, edit, and share your photos.
http://www.microsoft.com/middleeast/windows/windowslive/products/photo-gallery-edit.aspx___

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: Trying to track down error in NSPersistentDocument when saving

2009-08-16 Thread Gideon King
Cool - haven't used conditional breakpoints before, and didn't realize  
about objc_exception_throw...


That gives me completely different information, but much more useful:

#4  0x97578cba in -[NSAtomicStore(_NSInternalMethods)  
_insertNodeIntoMainCache:] ()
#5  0x97578c51 in -[NSAtomicStore(_NSInternalMethods)  
_registerCacheNode:] ()

#6  0x9757a51d in -[NSAtomicStore(_NSInternalMethods) _addObject:] ()
#7  0x9757a1a1 in -[NSAtomicStore(_NSInternalMethods)  
executeSaveChangesRequest:withContext:] ()
#8  0x9751d4c6 in -[NSPersistentStoreCoordinator(_NSInternalMethods)  
executeRequest:withContext:] ()


I guess that means that I'm returning a nil cache node for a managed  
object somewhere or something like that, which wouldn't surprise me at  
this stage of my coding. With this info, I have a much better idea  
what to look for, and where to dig next. Thanks for the quick response.



Gideon
___

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: Trying to track down error in NSPersistentDocument when saving

2009-08-16 Thread Graham Cox


On 16/08/2009, at 9:26 PM, Gideon King wrote:

Any suggestions as to where to look for a solution to this would be  
very welcome.



How about setting a conditional breakpoint on [NSDictionary  
setObject:forKey] with the condition object == nil?


Also, set a breakpoint on objc_exception_throw to trap exceptions at  
their source.


--Graham


___

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


Trying to track down error in NSPersistentDocument when saving

2009-08-16 Thread Gideon King
Hi, I'm hoping someone may have encountered something like this  
before, or have knowledge of the internals of NSPersistentStore...


I am getting an exception on NSDictionary setObject:forKey: (attempt  
to insert nil key), and although I am not getting any stacktrace, it  
appears when I step through it that the problem occurs in  
NSPersistentDocument  
writeToURL:ofType:forSaveOperation:originalContentsURL:error: I have  
also tried breaking on NSException raise, and that didn't help, and  
did a print and continue breakpoint on setObject:forKey:, but that  
didn't turn up anything (except for showing me that this method is  
called a lot!


Any suggestions as to where to look for a solution to this would be  
very welcome.


Thanks


Gideon
___

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: Is it possible to detour a drag and drop operation?

2009-08-16 Thread Graham Cox


On 16/08/2009, at 5:51 AM, Iceberg-Dev wrote:

When the drop is validated in the right window (type of item  
accepted), I would like to either display a window above the right  
window or change the right window content to give the user a list of  
more detailed possible drop locations.


Something like this:

+---++---+
+---+++--+
|   |||  |
|  +-+  |||  |
|  |  A  |  ||  Left  |   Right  |
|  +-+  |||  |
|   |||  |
+---+++--+

There's something like this in Final Cut Pro (http://www.geniusdv.com/news_and_tutorials/assets_c/2009/04/superimpose3-thumb-394x397-2264.gif 
).


Question:
-

How could this be achieved in Cocoa?


I have tried with a window but the target of the drop does not get  
changed.



Firstly I'd advise you to think whether a more straightforward design  
is possible. Drag/Drop is inherently a mouse-targeted operation, where  
there is a distinct end point to act as a drag target. If you haven't  
got that, maybe drag/drop isn't an appropriate way to handle the  
desired operation. In addition, regardless of FCP doing it, the user  
isn't expecting a jack-in-the-box to leap out at the last second and  
present a whole bunch of options - the target should be there from the  
start.


Nevertheless, if you did insist on ploughing this furrow, I can think  
of ways it can be done.


Design your target window/views so that they can be quickly switched  
between the 'normal' and 'drop target' modes. How you do this is up to  
you, for example with a split pane that opens to reveal the additional  
'drop targets' section. Design, Build and Test this separately from  
the drag/drop code. Once working to your satisfaction, integrate it  
with the NSDraggingDestination protocol. Rather than reveal the  
targets at drop time, it would be better to reveal them on drag enter,  
so that the user can see the targets available while they're dragging,  
and have plenty of time to a) choose a destination simply by dragging  
to it, and b) giving them a chance to choose nothing after all, by  
backing off (and thus drag leaving should close the drop targets pane).


I wouldn't try opening a window underneath the drop - it's kludgey,  
unlikely to work and is not a nice behaviour for the user.


--Graham


___

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: Is it possible to detour a drag and drop operation?

2009-08-16 Thread Iceberg-Dev


On Aug 16, 2009, at 2:03 AM, Jerry Krinock wrote:


On 2009 Aug 15, at 12:51, Iceberg-Dev wrote:

When the drop is validated in the right window (type of item  
accepted), I would like to either display a window above the right  
window or change the right window content to give the user a list  
of more detailed possible drop locations.


Seems like a "sheet" would be appropriate.

http://developer.apple.com/documentation/Cocoa/Conceptual/Sheets/ 
Sheets.html


It's not appropriate in this case and it would make the operation  
less transparent to the user. The sheet solution would require these  
additional things:


- showing the sheet

- clicking at least one

- hiding the sheet

The solution I'm looking into just requires moving the mouse.

I have tried with a window but the target of the drop does not get  
changed.


Probably no one understands what you mean by that.  I don't.


When the drop is validated, if you display a new window under the  
current position of the mouse, the target of the drop is not moved to  
the new window even if you move the mouse.



___

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