Re: Exception when entering too big value in text field (with number formatter)

2011-10-21 Thread Antonio Nunes
On 21 Oct 2011, at 17:23, Nick Zitzmann wrote:

>> 2011-10-21 11:49:49.520 AwesomeApp[35994:707] -[NSPopoverFrame 
>> titlebarRect]: unrecognized selector sent to instance 0x1050e7a30
> 
> …often happens when an object was deallocated, and then some other object was 
> allocated in its place, and then the original object was addressed after it 
> was deallocated & something else took its place. Try running your code using 
> Instruments' zombies template and then reproducing the problem. If it stops 
> due to a zombie access, and the trace shows the problem happened completely 
> within the AppKit, then it is a framework bug. Otherwise, your code most 
> likely over-released something.

Thanks Nick,

I fired up Zombies and it did not catch anything. I also had a close look at my 
code and, not only am I not deallocating anything, the whole view controller 
code doesn't even allocate any objects.

Then I had a search on "titlebarRect" and found a cocoa-dev message from August 
where the author wrote:

> I'm playing with popover too and noticed a problem when using formatters. If 
> there's a validation error, my application crashes when the framework try to 
> present a sheet displaying the error.
> 
> -[NSPopoverFrame titlebarRect]: unrecognized selector sent to instance 
> 0x102075780
> 
> Of course, popovers don't have titlebars…

Time to fire up the bug reporter I guess…

-António

---
And you would accept the seasons of your
heart, even as you have always accepted
the seasons that pass over your field.

--Kahlil Gibran
---



___

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


CAShapeLayer as a mask for CALayer: rounded corners are stretched

2011-10-21 Thread Anton Sotkov
Hi!

I want to mask a CALayer with CAShapeLayer, because changes to the shape can be 
animated.

When I use the CAShapeLayer as a mask, its rounded corners are stretched. 
However, if I take the same shape, create an image with it, and use the image 
to mask my CALayer, the rounded corners are perfectly fine.

Here's a screenshot of this behavior: http://pxl.fi/0t3Z0e2R2n1l2N2t2c3J 
(image-based mask on the left, shape-based on the right).

Here's the code I'm using to mask the layers (and you can download the whole 
example project at http://pxl.fi/1A2D2z0F1I030e1x1z1c).

CALayer *imageBasedMaskLayer = [CALayer layer];
[imageBasedMaskLayer setContents:(id)[[self maskWithSize:NSMakeSize(50, 50)] 
CGImageForProposedRect:NULL context:nil hints:nil]];
[imageBasedMaskLayer setFrame:CGRectMake(0, 0, 50, 50)];

CALayer *layerWithImageBasedMaskLayer = [CALayer layer];
[layerWithImageBasedMaskLayer setBackgroundColor:backgroundColor];
[layerWithImageBasedMaskLayer setMask:imageBasedMaskLayer];


CAShapeLayer *shapeBasedMaskLayer = [CAShapeLayer layer];
CGPathRef maskShape = [self newMaskPathWithFrame:NSMakeRect(0, 0, 50, 50)];
[shapeBasedMaskLayer setPath:maskShape];
[shapeBasedMaskLayer setFillRule:kCAFillRuleEvenOdd];
CGPathRelease(maskShape);
[shapeBasedMaskLayer setFrame:CGRectMake(0, 0, 50, 50)];

CALayer *layerWithShapeBasedMaskLayer = [CALayer layer];
[layerWithShapeBasedMaskLayer setBackgroundColor:backgroundColor];
[layerWithShapeBasedMaskLayer setMask:nil];
[layerWithShapeBasedMaskLayer setMask:shapeBasedMaskLayer];

And the two methods I'm creating NSImage and CGPathRef with.

- (NSImage *)maskWithSize:(CGSize)size;
{
NSImage *maskImage = [[NSImage alloc] initWithSize:size];

[maskImage lockFocus];
[[NSColor blackColor] setFill];

CGPathRef mask = [self newMaskPathWithFrame:CGRectMake(0, 0, 
size.width, size.height)];
CGContextRef context = [[NSGraphicsContext currentContext] 
graphicsPort];
CGContextAddPath(context, mask);
CGContextFillPath(context);
CGPathRelease(mask);

[maskImage unlockFocus];

return [maskImage autorelease];
}

- (CGPathRef)newMaskPathWithFrame:(CGRect)frame;
{
CGFloat cornerRadius = 3;

CGFloat height = CGRectGetMaxY(frame);
CGFloat width = CGRectGetMaxX(frame);

CGMutablePathRef maskPath = CGPathCreateMutable();

CGPathMoveToPoint(maskPath, NULL, 0, height-cornerRadius);
CGPathAddArcToPoint(maskPath, NULL, 0, height, cornerRadius, height, 
cornerRadius);
CGPathAddLineToPoint(maskPath, NULL, width-cornerRadius, height);
CGPathAddArcToPoint(maskPath, NULL, width, height, width, 
height-cornerRadius, cornerRadius);
CGPathAddLineToPoint(maskPath, NULL, width, cornerRadius);
CGPathAddArcToPoint(maskPath, NULL, width, 0, width-cornerRadius, 0, 
cornerRadius);
CGPathAddLineToPoint(maskPath, NULL, cornerRadius, 0);
CGPathAddArcToPoint(maskPath, NULL, 0, 0, 0, cornerRadius, 
cornerRadius);

CGPathCloseSubpath(maskPath);

return maskPath;
}

Please note that the actual mask I want to create is more complicated than a 
rounded rect, otherwise I would've used some of the simpler drawing techniques. 
I've tried various CGPath drawing functions, but nothing changed. I've tried 
masking the layer on iOS and observed the same problem. There must be a mistake 
in my code, I just don't see where it is.

What am I missing here?

Thank you,
Anton.___

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: Core Data: Determine if managed object is deleted

2011-10-21 Thread Jerry Krinock

On 2011 Oct 21, at 08:57, David Riggle wrote:

> - (BOOL)retainedObjectHasBeenDeleted
> {
>   // if object has been deleted, then it no longer exists
>   if ([self isDeleted]) return YES;   
>   // otherwise, see if object with this ID exists in the database
>   NSManagedObjectContext *context = [self managedObjectContext];
>   if (context == nil) return YES;
>   NSManagedObjectID *objectID = [self objectID];
>   if (objectID == nil) return YES;
>   NSManagedObject *obj = [context objectRegisteredForID:objectID];
>   return obj == nil;
> }

Interesting, David.

Why do you check for the object ID?  Have you ever seen an object which passed 
the first two tests (not isDeleted, has MOC), but then didn't have an objectID? 
 How could that happen?

> I'm currently experimenting with the following to see if it's as safe and 
> perhaps faster…

Are you having performance issues with your original 
-retainedObjectHasBeenDeleted?  

In my world, -retainedObjectHasBeenDeleted is only going to be invoked in 
corner cases, but documentation states that -prepareForDeletion is invoked 
"when the receiver is about to be deleted".  That may be quite often in some 
use cases.  Also, there is another definition trap there – what does "when the 
receiver is about to be deleted" mean?  How will that be interpreted by an 
Apple engineer who adds some new object-deleting method to support iCloud 2.0 
in Mac OS 10.8?  Plus, what Dave Fernandes noted.

I think that your original -retainedObjectHasBeenDeleted is fine and I wouldn't 
mess with it if I were you.

___

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: Can I jsut use @2x images without supplying a @1x image?

2011-10-21 Thread Kyle Sluder
On Fri, Oct 21, 2011 at 12:42 PM, David Hoerl  wrote:
> So, is this really acceptable? In virtually every image I have, the 1x image
> is just a scaled down 2x image. By dropping the 1x images I can greatly
> reduce the number of images stuffed into my app.

Except that iOS can just memory-map the 1x versions of your icons and
potentially blit them straight into VRAM. If you only include 2x
versions, you'll force the phone to do a lot of scaling, especially if
it needs to rasterize the image for certain effects.

--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: Can I jsut use @2x images without supplying a @1x image?

2011-10-21 Thread Jeff Kelley
Can you? Sure. Keep in mind, though, that the iPhones and iPod Touches without 
Retina Displays also have less memory, so loading double-scaled images will 
cause your app to use much more memory than necessary. This may not affect your 
application, but it may cause other applications to be unloaded from memory 
earlier, causing your users’ experience to suffer. So to be a good iOS citizen, 
you ought to include the 1x versions as well.

Jeff Kelley

On Oct 21, 2011, at 3:42 PM, David Hoerl wrote:

> I noticed by accident that everything seems to work just fine if I supply a 
> im...@2x.png in my iOS code, reference as normal [UIImage 
> imageNamed:@"image.png"], even if I'm targetting code at a non-retina iPhone.
> 
> So, is this really acceptable? In virtually every image I have, the 1x image 
> is just a scaled down 2x image. By dropping the 1x images I can greatly 
> reduce the number of images stuffed into my app.
> 
> Thanks,
> 
> David
___

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


Can I jsut use @2x images without supplying a @1x image?

2011-10-21 Thread David Hoerl
I noticed by accident that everything seems to work just fine if I 
supply a im...@2x.png in my iOS code, reference as normal [UIImage 
imageNamed:@"image.png"], even if I'm targetting code at a non-retina 
iPhone.


So, is this really acceptable? In virtually every image I have, the 1x 
image is just a scaled down 2x image. By dropping the 1x images I can 
greatly reduce the number of images stuffed into my app.


Thanks,

David
___

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 problem: iOS5 NSString's sizeWithFont returns integral values unlike drawAtPoint

2011-10-21 Thread David Duncan
On Oct 21, 2011, at 6:07 AM, David Hoerl wrote:

> I was having this bizarre issue with some odd text alignments. In the end I 
> tracked it down to sizeWithFont returning different CGSizes than did 
> drawAtPoint. The latter returns widths (using Courier 19pt bold) of around 
> 12.002 while sizeWithFont says 13.00. Its like sizeWithFont is using "ceilf" 
> on the values...
> 
> Is this a documentation issue or system problem?
> 
> In the end I just use a clearColor to draw the text, but boy was I surprised 
> at this.


Are you seeing this on iOS 5.0 only or on previous versions of iOS? There were 
some text changes that (for a time) leaked out non-integral values, but we 
thought we caught them – if you have a new one please file a bug with a simple 
example of what you've found.
--
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: Using version number in code

2011-10-21 Thread Andy Lee
And you might want to use the constants defined for this purpose where 
possible. See the "Constants" section in the "CFBundle Reference" docs.



--Andy

On Oct 21, 2011, at 12:26 PM, glenn andreas wrote:

> Or better use [[NSBundle mainBundle] objectForInfoDictionaryKey: ] since 
> that will localize it if possible, which is important if you are presenting 
> it to the user (unlikely that the short version will be localized, but the 
> long one might be)
> 
> On Oct 21, 2011, at 10:59 AM, Martin Hewitson wrote:
> 
>> Chris,
>> 
>> You can get those values like this:
>> 
>> NSDictionary *infodict = [[NSBundle mainBundle] infoDictionary];
>> NSString *bundleVersion = [dict valueForKey:@"CFBundleVersion"];
>> NSString *shortVersion = [dict valueForKey:@"CFBundleShortVersionString"];
>> CGFloat ver = [shortVersion floatValue];
>> 
>> Cheers,
>> 
>> Martin
>> 
>> On Oct 21, 2011, at 04:54 PM, Chris Paveglio wrote:
>> 
>>> In an app's Info.plist there are the 2 values for Bundle Version. Is there 
>>> a way to use those directly in a class, in code? For example, I often like 
>>> to put the version number of an app in the title bar or in part of the 
>>> window (I mostly develop in-house for my company so UI standards can suit 
>>> our needs, users can see immediately if it's the newest version). So far 
>>> I've simply made a variable or set the version number directly (as a 
>>> string) in my AppDelegate class, but if I could somehow use the Bundle 
>>> Version or Bundle Version String Short that would be great. Any suggestions?
>>> 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: 2nd table array linked to 1st table selection, updating

2011-10-21 Thread Keary Suska
On Oct 21, 2011, at 10:16 AM, Chris Paveglio wrote:

> My app watches several folders (and subfolders) on our file servers, and 
> counts and displays the files in those folders.
> I have a class for the folder data that contains the count from 3 subfolders 
> (ints) and then an array of file names of the files from one of the 
> subfolders.
> There are 8 folders that are watched, and those 8 items are in an array. I 
> have a table view that has columns for the integer values from the class 
> object. Then there is a second table where I show the file names when the 
> user selects a row from the first table.
> I have both these tables set up using bindings and array controllers. The 
> first table is straight forward setup. The second one's content array is 
> bound to the first array controller. The controller key is "selection" and 
> the model key path is the name of the array in the class object.
> The second table shows up fine, and it's content changes when I change the 
> selection on my first table.
> But when the contents of the folder changes and the app recalculates the 
> data, I get an error that *** -[NSCFArray objectAtIndex:]: index (3) beyond 
> bounds (3)
> This only occurs when the first table has a selection, and I understand 
> (probably) that it's because the second table is based on the first, and that 
> the data for the 2nd table is changing in a non-KVC compliant kind of way. 
> I'm not telling the 2nd array controller to remove or reset the values in the 
> class object's array, I am just directly removing all the objects from class 
> object array, then re-adding the newly scanned file names into the array.
> My workaround is, in code, the first table is deselected, the values are all 
> updated, and then the originally selected row is reselected. This makes the 
> display function and update properly.

As you think, you need to update the "primary" array in a KVC/KVO compliant 
way. That is always the  best way to update objects that are observed/bound. 
The simplest way is to first get the mutable proxy using -[object 
mutableArrayValueForKey:]. Any changes you make to the returned array will be 
propagated appropriately.

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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


Custom NSView drawing

2011-10-21 Thread Livio Isaia
I'm building an IB plugin with XCode 3.2.6.
I have a NSBox subclass that add a custom NSView into itself.
When the custom box is displayed in the Library Object Window it draws 
correctly, but if I drag it into a new nib file window the drag operation is 
also drawn correctly, but releasing the mouse inside the window the inner view 
is not drawn or drawn in the lower left corner of the window (outside the NSBox 
subclass).

Can anyone tell me why?

Best regards,
thank you in advance,
livio.___

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: Core Data: Determine if managed object is deleted

2011-10-21 Thread Dave Fernandes

On 2011-10-21, at 11:57 AM, David Riggle wrote:

> I'm currently experimenting with the following to see if it's as safe and 
> perhaps faster:
> 
> - (void)prepareForDeletion
> {
>   // track object deletion for faster testing below
>   NSString *objIDStr = [[[self objectID] URIRepresentation] 
> resourceSpecifier];
>   [_deletedObjectIDs addObject:objIDStr];
> }
> 
> - (BOOL)retainedObjectHasBeenDeleted
> {
>   NSString *objIDStr = [[[self objectID] URIRepresentation] 
> resourceSpecifier];
>   return [_deletedObjectIDs containsObject:objIDStr];
> }
> 
> Unfortunately _deletedObjectIDs grows without bound. So you wouldn't want to 
> use this approach if you are expecting a lot of deletions.

This also wouldn't work if you can undo 
deletions.___

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: Using version number in code

2011-10-21 Thread Chris Paveglio
Cool, Thanks everyone!


- Original Message -
Subject: Re: Using version number in code

Chris,

You can get those values like this:

NSDictionary *infodict = [[NSBundle mainBundle] infoDictionary];
NSString *bundleVersion = [dict valueForKey:@"CFBundleVersion"];
NSString *shortVersion = [dict valueForKey:@"CFBundleShortVersionString"];
CGFloat ver = [shortVersion floatValue];

Cheers,

Martin
___

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: Using version number in code

2011-10-21 Thread glenn andreas
Or better use [[NSBundle mainBundle] objectForInfoDictionaryKey: ] since 
that will localize it if possible, which is important if you are presenting it 
to the user (unlikely that the short version will be localized, but the long 
one might be)

On Oct 21, 2011, at 10:59 AM, Martin Hewitson wrote:

> Chris,
> 
> You can get those values like this:
> 
> NSDictionary *infodict = [[NSBundle mainBundle] infoDictionary];
> NSString *bundleVersion = [dict valueForKey:@"CFBundleVersion"];
> NSString *shortVersion = [dict valueForKey:@"CFBundleShortVersionString"];
> CGFloat ver = [shortVersion floatValue];
> 
> Cheers,
> 
> Martin
> 
> On Oct 21, 2011, at 04:54 PM, Chris Paveglio wrote:
> 
>> In an app's Info.plist there are the 2 values for Bundle Version. Is there a 
>> way to use those directly in a class, in code? For example, I often like to 
>> put the version number of an app in the title bar or in part of the window 
>> (I mostly develop in-house for my company so UI standards can suit our 
>> needs, users can see immediately if it's the newest version). So far I've 
>> simply made a variable or set the version number directly (as a string) in 
>> my AppDelegate class, but if I could somehow use the Bundle Version or 
>> Bundle Version String Short that would be great. Any suggestions?
>> 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/martin.hewitson%40aei.mpg.de
>> 
>> This email sent to martin.hewit...@aei.mpg.de
> 
> 
> Martin Hewitson
> Albert-Einstein-Institut
> Max-Planck-Institut fuer 
>Gravitationsphysik und Universitaet Hannover
> Callinstr. 38, 30167 Hannover, Germany
> Tel: +49-511-762-17121, Fax: +49-511-762-5861
> E-Mail: martin.hewit...@aei.mpg.de
> WWW: http://www.aei.mpg.de/~hewitson
> 
> 
> 
> 
> 
> 
> ___
> 
> 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/gandreas%40mac.com
> 
> This email sent to gandr...@mac.com

Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

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: Prevent table sorting

2011-10-21 Thread Kyle Sluder
On Oct 21, 2011, at 8:19 AM, Chris Paveglio  wrote:

> I have a tableview, that's populated via bindings to an array controller. Is 
> there a way to prevent selecting the table column headers, so that the 
> content can't be rearranged at all? I've looked through everything in IB for 
> the array controller, the table, its columns, etc and don't see a box to 
> prevent/allow selection reordering. I could hide the table headers and make 
> my own text labels, but I thought there'd be a simple on/off checkbox for 
> this.

Turn off "Creates Sort Descriptor" in the Bindings inspector.

--Kyle Slude

___

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


2nd table array linked to 1st table selection, updating

2011-10-21 Thread Chris Paveglio
If this sort of thing has be discussed before I'm sorry. Shoot me a link to the 
other discussion or sample code.

My app watches several folders (and subfolders) on our file servers, and counts 
and displays the files in those folders.
I have a class for the folder data that contains the count from 3 subfolders 
(ints) and then an array of file names of the files from one of the subfolders.
There are 8 folders that are watched, and those 8 items are in an array. I have 
a table view that has columns for the integer values from the class object. 
Then there is a second table where I show the file names when the user selects 
a row from the first table.
I have both these tables set up using bindings and array controllers. The first 
table is straight forward setup. The second one's content array is bound to the 
first array controller. The controller key is "selection" and the model key 
path is the name of the array in the class object.
The second table shows up fine, and it's content changes when I change the 
selection on my first table.
But when the contents of the folder changes and the app recalculates the data, 
I get an error that *** -[NSCFArray objectAtIndex:]: index (3) beyond bounds (3)
This only occurs when the first table has a selection, and I understand 
(probably) that it's because the second table is based on the first, and that 
the data for the 2nd table is changing in a non-KVC compliant kind of way. I'm 
not telling the 2nd array controller to remove or reset the values in the class 
object's array, I am just directly removing all the objects from class object 
array, then re-adding the newly scanned file names into the array.
My workaround is, in code, the first table is deselected, the values are all 
updated, and then the originally selected row is reselected. This makes the 
display function and update properly.

So my question is, is there a more elegant sort of way to do this kind of 
multi-table display, using bindings and selections?
Thanks,
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: Prevent table sorting

2011-10-21 Thread Keary Suska
On Oct 21, 2011, at 9:19 AM, Chris Paveglio wrote:

> I have a tableview, that's populated via bindings to an array controller. Is 
> there a way to prevent selecting the table column headers, so that the 
> content can't be rearranged at all? I've looked through everything in IB for 
> the array controller, the table, its columns, etc and don't see a box to 
> prevent/allow selection reordering. I could hide the table headers and make 
> my own text labels, but I thought there'd be a simple on/off checkbox for 
> this.

It's in the column value binding. Look for "Creates Sort Descriptor".

Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

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: Using version number in code

2011-10-21 Thread Martin Hewitson
Chris,

You can get those values like this:

NSDictionary *infodict = [[NSBundle mainBundle] infoDictionary];
NSString *bundleVersion = [dict valueForKey:@"CFBundleVersion"];
NSString *shortVersion = [dict valueForKey:@"CFBundleShortVersionString"];
CGFloat ver = [shortVersion floatValue];

Cheers,

Martin

On Oct 21, 2011, at 04:54 PM, Chris Paveglio wrote:

> In an app's Info.plist there are the 2 values for Bundle Version. Is there a 
> way to use those directly in a class, in code? For example, I often like to 
> put the version number of an app in the title bar or in part of the window (I 
> mostly develop in-house for my company so UI standards can suit our needs, 
> users can see immediately if it's the newest version). So far I've simply 
> made a variable or set the version number directly (as a string) in my 
> AppDelegate class, but if I could somehow use the Bundle Version or Bundle 
> Version String Short that would be great. Any suggestions?
> 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/martin.hewitson%40aei.mpg.de
> 
> This email sent to martin.hewit...@aei.mpg.de


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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: Core Data: Determine if managed object is deleted

2011-10-21 Thread David Riggle
This is what I have used for years with good success:

- (BOOL)retainedObjectHasBeenDeleted
{
// if object has been deleted, then it no longer exists
if ([self isDeleted]) return YES;   
// otherwise, see if object with this ID exists in the database
NSManagedObjectContext *context = [self managedObjectContext];
if (context == nil) return YES;
NSManagedObjectID *objectID = [self objectID];
if (objectID == nil) return YES;
NSManagedObject *obj = [context objectRegisteredForID:objectID];
return obj == nil;
}

I'm currently experimenting with the following to see if it's as safe and 
perhaps faster:

- (void)prepareForDeletion
{
// track object deletion for faster testing below
NSString *objIDStr = [[[self objectID] URIRepresentation] 
resourceSpecifier];
[_deletedObjectIDs addObject:objIDStr];
}

- (BOOL)retainedObjectHasBeenDeleted
{
NSString *objIDStr = [[[self objectID] URIRepresentation] 
resourceSpecifier];
return [_deletedObjectIDs containsObject:objIDStr];
}

Unfortunately _deletedObjectIDs grows without bound. So you wouldn't want to 
use this approach if you are expecting a lot of deletions.

___

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


Using version number in code

2011-10-21 Thread Chris Paveglio
In an app's Info.plist there are the 2 values for Bundle Version. Is there a 
way to use those directly in a class, in code? For example, I often like to put 
the version number of an app in the title bar or in part of the window (I 
mostly develop in-house for my company so UI standards can suit our needs, 
users can see immediately if it's the newest version). So far I've simply made 
a variable or set the version number directly (as a string) in my AppDelegate 
class, but if I could somehow use the Bundle Version or Bundle Version String 
Short that would be great. Any suggestions?
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: Exception when entering too big value in text field (with number formatter)

2011-10-21 Thread Nick Zitzmann

On Oct 21, 2011, at 4:13 AM, Antonio Nunes wrote:

> I'm not sure what, if anything, I'm doing wrong, and how to get this setup to 
> function properly. I've done this type of binding before, but never in a 
> popover window. Could it be a framework bug? Any ideas about what might be 
> wrong with the setup, and/or how to solve the issue?

Framework bugs happen, but this:

> 2011-10-21 11:49:49.520 AwesomeApp[35994:707] -[NSPopoverFrame titlebarRect]: 
> unrecognized selector sent to instance 0x1050e7a30

…often happens when an object was deallocated, and then some other object was 
allocated in its place, and then the original object was addressed after it was 
deallocated & something else took its place. Try running your code using 
Instruments' zombies template and then reproducing the problem. If it stops due 
to a zombie access, and the trace shows the problem happened completely within 
the AppKit, then it is a framework bug. Otherwise, your code most likely 
over-released something.

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


Prevent table sorting

2011-10-21 Thread Chris Paveglio
I have a tableview, that's populated via bindings to an array controller. Is 
there a way to prevent selecting the table column headers, so that the content 
can't be rearranged at all? I've looked through everything in IB for the array 
controller, the table, its columns, etc and don't see a box to prevent/allow 
selection reordering. I could hide the table headers and make my own text 
labels, but I thought there'd be a simple on/off checkbox for this.
(XCode 3.2)
Thanks, 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: CD database breaks after lightweight migration?

2011-10-21 Thread Fritz Anderson
On 21 Oct 2011, at 6:17 AM, Jerry Krinock wrote:

> On 2011 Oct 20, at 12:03, Fritz Anderson wrote:
> 
>> Does it in fact not work? Or is there something else I should be frobbing?
> 
> I think that the lightweight migration you described should work, and there 
> is something else you should be frobbing.

I understand your answer to mean that the problem may come from a bug in 
apparently-unrelated code, which was exposed by instituting the migration, and 
I haven't supplied enough information to debug this specific problem. 
Acknowledged.

What I meant by "something else I should be frobbing" is whether there was an 
additional step I am supposed to be taking in building my Core Data stack. 
processPendingChanges? save:? These seem to be gratuitous. I'd experiment, but 
I have to be away from the project till Monday.

I still hope that someone can come up with guidance on where to look. The 
migration is the _only_ change between working and not-working. The managed 
object comes back as a fault _immediately_ after the fetch, and accessing any 
attribute raises an exception. (Incidentally, -isDeleted is NO.) 

I wonder if this is familiar to anyone?

— F

___

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: playing a streamed audio file

2011-10-21 Thread Fritz Anderson
On 21 Oct 2011, at 7:31 AM, John Love wrote:

> I discovered that I cannot use the AVAudioPlayer methods for playing a 
> streamed audio file because this class only supports embedded audio (file:// 
> links).  OK, so I use the UIViewController method:
> 
> - presentMoviePlayerViewControllerAnimated:myMPMoviePlayerController
> 
> That works well, except that I have the lyrics showing in my UIView and this 
> method totally hides the lyrics and shows the usual ((Q)) Quicktime logo and 
> the Done button.
> 
> So, instead I call:
> 
> [moviePlayerController_ setControlStyle:MPMovieControlStyleNone];
> 
> and the lyrics continue to show, with the audio playing in the background as 
> I want, but then I lose total control of audio playback.

Does AVPlayer do what you want? You'll have to provide your own controls, but 
you get the total control you're looking for.

— F

___

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


Connect to server - list of shared volumes

2011-10-21 Thread Dragan Milić
Hello,

This may not be strictly related to Cocoa, but I'm willing to use any API that 
can serve the purpose and perhaps something like that exists in Cocoa, I just 
don't know of it.

So, I want to mount shared volume(s) that reside on the same server. I use 
FSMountServerVolumeAsync() function, supplying it the URL of the server, as one 
of arguments. As I understand, this function loads and runs the appropriate 
URLMount plug-in, which structure is private. If there are move mountable 
volumes connected to the server, this plug-in automatically presents a modal 
panel with the list of all available servers and allows user to choose which 
one to connect to.

I want to skip this "magic" provided by the API and to create this list of 
available mountable volumes myself (e.g. I may choose to exclude some from the 
list or do something else). Is there a public way to retrieve a list of 
mountable volumes connected to the server, which full URL is known? If not, 
I'll be also satisfied if I can do it in undocumented way, using any private 
API.

Thanks,
-- Dragan
___

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: Core Data: Determine if managed object is deleted

2011-10-21 Thread Mike Abdullah

On 20 Oct 2011, at 23:37, Jerry Krinock wrote:

> When I need to know whether or not a managed object is deleted, often I fall 
> into the trap of trying -[NSManagedObject isDeleted], forgetting that its 
> documentation states …
> 
>  "… It may return NO at other times, particularly after the object has been 
> deleted. …"
> 
> In other words, they should have named that method -isDeletedForSure, to 
> indicate that the NO result is not reliable.
> 
> Anyhow, today I fixed a problem by using this instead …
> 
>   BOOL isDeleted ;
>   isDeleted = [object isDeleted] || ([object managedObjectContext] == nil) ;
> 
> I'm not sure if it will work in all situations.  I suppose that sending the 
> magical -processPendingChanges would be another workaround.

The problem here is that Core Data's definition of "deleted" is a little 
different to what you'd' expect:

Expected:

-[NSManagedObjectContext deleteObject:] has been called with the 
object, and that deletion hasn't been undone

Actual:

The object is listed under -[NSManagedObjectContext deletedObjects]. 
i.e. the object has been marked for removal from the parent store/context, next 
time the context is saved.

___

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


Font problem: iOS5 NSString's sizeWithFont returns integral values unlike drawAtPoint

2011-10-21 Thread David Hoerl
I was having this bizarre issue with some odd text alignments. In the 
end I tracked it down to sizeWithFont returning different CGSizes than 
did drawAtPoint. The latter returns widths (using Courier 19pt bold) of 
around 12.002 while sizeWithFont says 13.00. Its like sizeWithFont is 
using "ceilf" on the values...


Is this a documentation issue or system problem?

In the end I just use a clearColor to draw the text, but boy was I 
surprised at this.


David
___

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


playing a streamed audio file

2011-10-21 Thread John Love
I discovered that I cannot use the AVAudioPlayer methods for playing a streamed 
audio file because this class only supports embedded audio (file:// links).  
OK, so I use the UIViewController method:

- presentMoviePlayerViewControllerAnimated:myMPMoviePlayerController

That works well, except that I have the lyrics showing in my UIView and this 
method totally hides the lyrics and shows the usual ((Q)) Quicktime logo and 
the Done button.

So, instead I call:

[moviePlayerController_ setControlStyle:MPMovieControlStyleNone];

and the lyrics continue to show, with the audio playing in the background as I 
want, but then I lose total control of audio playback.

How do I show the lyrics and retain audio playback control?

The docs state that if I used:

[moviePlayerController_ setControlStyle:MPMovieControlStyleEmbedded]; 

that the controls for an embedded view are displayed ... but they are not.

Do I mess with myMoviePlayerController.view.frame .. for the macOS, this would 
translate to a floating window, but for iOS I would like:


--
||
||
||
|scrollable  |
|lyrics here |
||
||
||
|-|
||
|fixed |
|   controls here   |
||
--

Thanks,

 

John Love
Touch the Future! Teach!



___

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: Core Data: Determine if managed object is deleted

2011-10-21 Thread Steve Steinitz
Hi Jerry,

On 21 Oct 11, at 2:53pm, cocoa-dev-requ...@lists.apple.com wrote:

> In other words, they should have named that method -isDeletedForSure, to 
> indicate that the NO result is not reliable.

Funny.

> Anyhow, today I fixed a problem by using this instead
> 
> BOOL isDeleted ;
> isDeleted = [object isDeleted] || ([object managedObjectContext] == nil) ;

Another try:

isDeleted = [[[object managedObjectContext] deletedObjects] 
containsObject: object];

That aside, Quincey's essay makes sense.

Cheers,

Steve

___

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: CD database breaks after lightweight migration?

2011-10-21 Thread Jerry Krinock

On 2011 Oct 20, at 12:03, Fritz Anderson wrote:

> Does it in fact not work? Or is there something else I should be frobbing?

I think that the lightweight migration you described should work, and there is 
something else you should be frobbing.

___

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


Exception when entering too big value in text field (with number formatter)

2011-10-21 Thread Antonio Nunes
Hi,

I have an NSTextField with a number formatter and an NSStepper in a view that 
is used in an NSPopover. The values of both interface items are bound to an 
ivar of the view controller via an object controller. Both the text field and 
the stepper have a max value of 9.

When I enter a value superior to that in the text field and tab out, or click 
another field, an exception is raised. The backtrace is pasted below. 
(Depending on my next action, or the way I exit the text field in the first 
place, one or two alert views may show with the 'Value "x" is too large' 
warning. The first alert has no title bar and can't be dismissed by clicking 
the discard or ok buttons, the other alert is a proper window that can be 
dismissed. I see these alerts also when the stepper is unbound, so the issue 
looks to be only with the text field.

I'm not sure what, if anything, I'm doing wrong, and how to get this setup to 
function properly. I've done this type of binding before, but never in a 
popover window. Could it be a framework bug? Any ideas about what might be 
wrong with the setup, and/or how to solve the issue?

-António

==

2011-10-21 11:49:49.520 AwesomeApp[35994:707] -[NSPopoverFrame titlebarRect]: 
unrecognized selector sent to instance 0x1050e7a30
2011-10-21 11:49:49.521 AwesomeApp[35994:707] Exception detected while handling 
key input.
2011-10-21 11:49:49.521 AwesomeApp[35994:707] -[NSPopoverFrame titlebarRect]: 
unrecognized selector sent to instance 0x1050e7a30
2011-10-21 11:49:49.530 AwesomeApp[35994:707] (
0   CoreFoundation  0x7fff892c1286 
__exceptionPreprocess + 198
1   libobjc.A.dylib 0x7fff8d3ebd5e 
objc_exception_throw + 43
2   CoreFoundation  0x7fff8934d4ce -[NSObject 
doesNotRecognizeSelector:] + 190
3   CoreFoundation  0x7fff892ae133 
___forwarding___ + 371
4   CoreFoundation  0x7fff892f813d 
__forwarding_prep_1___ + 237
5   AppKit  0x7fff90082870 
-[NSWindow(NSSheets) startRectForSheet:] + 151
6   AppKit  0x7fff900822d2 
-[NSWindow(NSSheets) _positionSheet:constrained:andDisplay:] + 151
7   AppKit  0x7fff900813b2 
-[NSMoveHelper(NSSheets) _moveParent:andOpenSheet:] + 774
8   AppKit  0x7fff90082e8f 
-[NSWindow(NSSheets) _orderFrontRelativeToWindow:] + 192
9   AppKit  0x7fff8fc222f2 -[NSWindow 
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1679
10  AppKit  0x7fff8fc21b7a -[NSWindow 
_doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 807
11  AppKit  0x7fff8fddc5cb 
-[NSApplication _orderFrontModalWindow:relativeToWindow:] + 662
12  AppKit  0x7fff8fddc094 
-[NSApplication 
_commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:]
 + 831
13  AppKit  0x7fff8fddc92e 
-[NSApplication 
beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:] + 134
14  AppKit  0x7fff8fdd008b -[NSAlert 
beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:] + 295
15  AppKit  0x7fff8fddfdb0 
-[NSApplication(NSErrorPresentation) 
presentError:modalForWindow:delegate:didPresentSelector:contextInfo:] + 446
16  AppKit  0x7fff90198893 
-[NSValueBinder 
_presentDiscardEditingSheetWithError:discardEditingCallback:otherCallback:callbackContextInfo:relatedToBinding:]
 + 314
17  AppKit  0x7fff901991d8 
-[NSValueBinder 
handleValidationError:description:inEditor:errorUserInterfaceHandled:] + 510
18  AppKit  0x7fff901d9180 
-[_NSBindingAdaptor 
_handleValidationError:description:inEditor:errorUserInterfaceHandled:bindingAdaptor:]
 + 194
19  AppKit  0x7fff901d92a3 
-[_NSBindingAdaptor 
handleValidationError:description:inEditor:errorUserInterfaceHandled:] + 280
20  AppKit  0x7fff8fe50d98 -[NSCell 
_validateEntryString:uiHandled:] + 455
21  AppKit  0x7fff900f4303 
-[NSTextField textShouldEndEditing:] + 80
22  AppKit  0x7fff90155e68 
-[NSTextView(NSSharing) resignFirstResponder] + 426
23  AppKit  0x7fff8fc43bf5 -[NSWindow 
makeFirstResponder:] + 429
24  AppKit  0x7fff901b214d -[NSWindow 
_makeParentWindowHaveFirstResponder:] + 48
25  AppKit  0x0

Re: Document-based app: design question

2011-10-21 Thread Citizen
One way of dealing with this is to make the method part of an informal protocol 
and check before calling it. Details are here:
http://cocoadevcentral.com/articles/75.php

--
David Kennedy (http://www.zenopolis.com)


On 21 Oct 2011, at 08:39, Luc Van Bogaert wrote:

> Hi,
> 
> I'm using the following piece of code in several places to get a pointer to 
> the "active" windowController in my document-based application:
> 
> NSDocument *currentDocument = [[NSDocumentController 
> sharedDocumentController] currentDocument];
>if (!currentDocument)
>return;
> 
>NSWindowController *windowController = [[currentDocument 
> windowControllers] objectAtIndex:0];
>if (![windowController isMemberOfClass:[DSSketchLibraryWindowController 
> class]])
>return;
> 
> Obviously, I'm looking for a way to refactor this duplicate code. Since this 
> code is used in several different classes, I need to put it someplace where I 
> can easily reference it. AppDelegate comes to mind. So, I'm wondering if 
> putting this code in a public method in the application delegate would be the 
> correct "cocoa way" of doing things?
> 
> Thanks for any advice.
> 
> -- 
> Luc Van Bogaert.
> ___
> 
> 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/citizen%40zenopolis.com
> 
> This email sent to citi...@zenopolis.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


Document-based app: design question

2011-10-21 Thread Luc Van Bogaert
Hi,

I'm using the following piece of code in several places to get a pointer to the 
"active" windowController in my document-based application:

 NSDocument *currentDocument = [[NSDocumentController 
sharedDocumentController] currentDocument];
if (!currentDocument)
return;

NSWindowController *windowController = [[currentDocument windowControllers] 
objectAtIndex:0];
if (![windowController isMemberOfClass:[DSSketchLibraryWindowController 
class]])
return;

Obviously, I'm looking for a way to refactor this duplicate code. Since this 
code is used in several different classes, I need to put it someplace where I 
can easily reference it. AppDelegate comes to mind. So, I'm wondering if 
putting this code in a public method in the application delegate would be the 
correct "cocoa way" of doing things?

Thanks for any advice.

-- 
Luc Van Bogaert.
___

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