Setting wantsLayer = YES; crashes on view load.

2009-06-01 Thread Kevin Ross
Hi everyone, I have a Core Data document based app that I've been  
working on for a while and I now want to change some of the view  
drawing to use CALayers.  The trouble I'm having is that when I set a  
view's wantsLayer = YES, I end up getting EXC_BAD_ACCESS.This  
happens when I try to set it on any arbitrary view in any of the nibs  
in my project, when setting it from code, or from clicking the  
checkbox in IB.  I've tried new CALayer projects from scratch and they  
work fine, is there something I could have done to my project that  
would prevent me from setting a view's wantsLayer property to YES?


Thank you for taking time to read this.

Kevin Ross


Stack Trace of crash:

#0  0x9129c688 in objc_msgSend ()
#1  0x91bbe7a6 in +[NSConcreteNotification  
newTempNotificationWithName:object:userInfo:] ()

#2  0x91bc158d in _nsnote_callback ()
#3  0x951fa64a in __CFXNotificationPost ()
#4  0x951fa923 in _CFXNotificationPostNotification ()
#5  0x951fac18 in CFNotificationCenterPostNotification ()
#6  0x9368250c in CARenderContextNew ()
#7  0x9365671a in -[CAContextImpl initWithOptions:] ()
#8  0x936823cf in +[CAContext localContextWithOptions:] ()
#9  0x93682386 in +[CAContext localContext] ()
#10 0x93682296 in CAViewCreate ()
#11 0x930643d0 in -[NSView(NSInternal) _createLayerTreeRenderer] ()
#12 0x930642ac in -[NSView(NSLayerKitGlue)  
_setUpLayerTreeRendererAndSurface] ()

#13 0x92df5e51 in -[NSView lockFocusIfCanDraw] ()
#14 0x92df58b1 in -[NSView lockFocus] ()
#15 0x92df9c4b in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#16 0x92dfa0ba in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#17 0x92dfa0ba in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#18 0x92dfa0ba in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#19 0x92dfa0ba in -[NSView  
_recursiveDisplayAllDirtyWithLockFocus:visRect:] ()
#20 0x92df8679 in -[NSView  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#21 0x92df7fbb in -[NSThemeFrame  
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView 
:] ()
#22 0x92df4adf in -[NSView  
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] ()

#23 0x92d354b3 in -[NSView displayIfNeeded] ()
#24 0x92d35061 in -[NSWindow displayIfNeeded] ()
#25 0x92df0c37 in -[NSWindow  
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] ()

#26 0x92df0690 in -[NSWindow orderWindow:relativeTo:] ()
#27 0x92e2270d in -[NSWindow orderFront:] ()
#28 0x92d03503 in -[NSIBObjectData  
nibInstantiateWithOwner:topLevelObjects:] ()

#29 0x92cf9616 in loadNib ()
#30 0x92cf8f78 in +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:] ()
#31 0x92cf8bbb in +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:] ()

#32 0x92d38ed9 in -[NSWindowController loadWindow] ()
#33 0x92d38c72 in -[NSWindowController window] ()
#34 0x92d38b9a in -[NSWindowController showWindow:] ()
#35 0x92d38add in -[NSDocument showWindows] ()
#36 0x92d36da4 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:] ()

#37 0x92f229ea in -[NSDocumentController newDocument:] ()
#38 0x92e044cb in -[NSApplication sendAction:to:from:] ()
#39 0x92eb3108 in -[NSMenu performActionForItemAtIndex:] ()
#40 0x92eb2e0d in -[NSCarbonMenuImpl  
performActionWithHighlightingForItemAtIndex:] ()

#41 0x92eb2a93 in -[NSMenu performKeyEquivalent:] ()
#42 0x92eb1338 in -[NSApplication _handleKeyEquivalent:] ()
#43 0x92dce0fb in -[NSApplication sendEvent:] ()
#44 0x92d2b62f in -[NSApplication run] ()
#45 0x92cf8834 in NSApplicationMain ()






___

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: How to draw background image in my app window

2009-06-01 Thread cocoa learner
On Sun, May 31, 2009 at 9:37 PM, Andy Lee ag...@mac.com wrote:

 On May 31, 2009, at 8:51 AM, Uli Kusterer wrote:

 Another approach would be to try changing the class of your content view in
 Interface builder. Simply click the background of the window, that should
 show the content view in the inspector. Go to the Identity tab and change
 the class to NSImageView. Then you can probably just do

 [(NSImageView*)[myWindow contentView] setImage: [[[NSImage alloc]
 initWithContentsOfFile: path] autorelease]];


 I had the same thought but when I tried it (and added a call to
 setImageScaling:) the image didn't appear.  I wonder what I'm doing wrong:

 - (void)awakeFromNib
 {
 NSLog(@-[AppDelegate awakeFromNib]);

 NSImage *whiteRoomImage = [NSImage imageNamed:@WhiteRoom];
 NSImageView *backgroundImageView = (NSImageView *)[_imageWindow
 contentView];

 NSLog(@image: %@, whiteRoomImage);
 NSLog(@contentView: %@, [_imageWindow contentView]);

 [backgroundImageView setImageScaling:NSScaleToFit];
 [backgroundImageView setImage:whiteRoomImage];
 }

 Yet another approach would be to use IB to add an image view as a subview
 of the window's content view, and use autoresizing to have it always fill
 the content view.  The benefit of this approach is that you can see the
 background image in IB, so you can see what it looks like as you lay out its
 subviews.


This is same as what I had in the start of mail thread. [my first mail in
this mail thread].

Regards
Cocoa.learner


 --Andy


___

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

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

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

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


Re: Setting wantsLayer = YES; crashes on view load.

2009-06-01 Thread Michael Vannorsdel
Are you registering for any notifications?  It looks like it's  
crashing while trying to notify an object.



On Jun 1, 2009, at 12:31 AM, Kevin Ross wrote:

Hi everyone, I have a Core Data document based app that I've been  
working on for a while and I now want to change some of the view  
drawing to use CALayers.  The trouble I'm having is that when I set  
a view's wantsLayer = YES, I end up getting EXC_BAD_ACCESS.This  
happens when I try to set it on any arbitrary view in any of the  
nibs in my project, when setting it from code, or from clicking the  
checkbox in IB.  I've tried new CALayer projects from scratch and  
they work fine, is there something I could have done to my project  
that would prevent me from setting a view's wantsLayer property to  
YES?


Thank you for taking time to read this.


___

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 NSMenuItem in IB

2009-06-01 Thread Vijay Kanse
Hello List,

I was customizing my Application Main Menu and I deleted Edit menu from
Main Menu.
Now My Application needs to add Edit Menu in Main Menu.

I am not able to drag NSMenu to main menu. and i am not able to do it by
coding as well.

So, how can i add this Menu Item ?


Thanks.
___

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

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

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

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


Re: Adding NSMenuItem in IB

2009-06-01 Thread Kyle Sluder
On Mon, Jun 1, 2009 at 12:39 AM, Vijay Kanse vijay.ka...@avinashi.com wrote:
 I am not able to drag NSMenu to main menu. and i am not able to do it by
 coding as well.

Really?  There's an Edit menu in the IB library which you should be
able to just drag to the main menu in your MainMenu.nib.  If this
isn't working for you, please explain exactly what you're trying to
do.

--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


NSTableView - setting row heights

2009-06-01 Thread Peter Hudson

Here is the setup ...

Table view with 3 columns.

In tableView:objectValueForTableColumn:row:   I return an  
NSAttributedString,  most of which use 2 different fonts.


To set the row height I have implemented the delegate method :-

-(float)tableView:(NSTableView *)tableView   heightOfRow:(int)row
{

	NSAttributedString *str = [[data objectAtIndex:row] objectAtIndex: 
1];  // recover the longest string


	NSTableColumn *col = [[tableView tableColumns] objectAtIndex:1];
	// the middle column


NSCell *colDataCell = [[[NSCell alloc] initTextCell:@] autorelease];
[colDataCell setWraps:YES];
[colDataCell  setAttributedStringValue:str];

	return [colDataCell cellSizeForBounds:NSMakeRect(0.0, 0.0, [col  
width], FLT_MAX)].height + 2;


}


The cell contents are reproduced as expected - row heights vary and  
are correct.
I can change column widths and the text is adjusted correctly and the  
new row height set.
The table scrolls correctly.  Resizing the parent window resizes the  
table and the row heights correctly.


The problem appears when I try to select a row. Rows are not selectable.
When I try to select a row I get the error message

NSConcreteMutableAttributedString addAttribute:value:range:: nil value

I have tried hard coding into 
tableView:objectValueForTableColumn:row:  a simple attributed string  
which
works in another app without any problem.  But this produces the same  
error message.


I have used this technique of returning NSAttributedStrings to  
NSTableView s  many times previously with no problem.


I'm using xCode 3.1  Targeting OSX 10.4  and its a universal build.

Any help would be much appreciated.

Peter






___

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

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

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

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


Re: Adding NSMenuItem in IB

2009-06-01 Thread Vijay Kanse
Sorry for My Question,
Actually i was dragging NSMenu from Library and I was trying to Add it as
Sub Menu.

Thanks For guiding me right way.


On Mon, Jun 1, 2009 at 2:49 PM, Kyle Sluder kyle.slu...@gmail.com wrote:

 On Mon, Jun 1, 2009 at 12:39 AM, Vijay Kanse vijay.ka...@avinashi.com
 wrote:
  I am not able to drag NSMenu to main menu. and i am not able to do it by
  coding as well.

 Really?  There's an Edit menu in the IB library which you should be
 able to just drag to the main menu in your MainMenu.nib.  If this
 isn't working for you, please explain exactly what you're trying to
 do.

 --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: Several Questions

2009-06-01 Thread Ammar Ibrahim
On Mon, Jun 1, 2009 at 6:04 AM, Chris Hanson c...@me.com wrote:

 On May 30, 2009, at 11:18 PM, Ammar Ibrahim wrote:

 On Sun, May 31, 2009 at 6:16 AM, Chris Hanson c...@me.com wrote:

  The best way to ensure your daemon or agent is always running is to have
 it
 run via launchd.

 Start by reading the launchd man page and the Daemons and Agents tech
 note; these will give you an overview of how Mac OS X used launchd to
 manage
 these types of on-demand and always-on services.


 But my app is a normal Cocoa App, it's not a daemon or an agent.


 It's still essentially an agent, just one that runs in the foreground, not
 the background.

 You can use launchd to keep your app alive.  That way you, don't have to
 worry about adding code to your application to do it, you just have to
 ensure the launchd property list is in the right place.

 That will also make development of your application easier, because your
 application can run normally; you won't have to put a bunch of extra code
 into it to disable its keep-alive behavior during development.



Great, so I understand from what you're saying that I can launch a GUI app
using launchd? I will look into it. Also, what if the application stops
responding? Is that something that launchd can detect?
___

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


About [super dealloc];

2009-06-01 Thread Bright
Hi ,all
In Cocoa, if there is [super init];, there will be [super dealloc]; 
correspondently at the end of this class.
But I find that sometimes if there is not [super init];, there will be 
[super dealloc]; correspondently too.
I puzzled. When should use the [super dealloc];?  Could anyone list all of 
case.


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


Re: Several Questions

2009-06-01 Thread Jelle De Laender

why should your app stops responding?

Do you want to detect time-outs (network-times, IO-timeouts, ...) or  
will your app be crap and full with bugs?




On 01 Jun 2009, at 13:19, Ammar Ibrahim wrote:


On Mon, Jun 1, 2009 at 6:04 AM, Chris Hanson c...@me.com wrote:


On May 30, 2009, at 11:18 PM, Ammar Ibrahim wrote:


On Sun, May 31, 2009 at 6:16 AM, Chris Hanson c...@me.com wrote:

The best way to ensure your daemon or agent is always running is  
to have

it
run via launchd.

Start by reading the launchd man page and the Daemons and  
Agents tech
note; these will give you an overview of how Mac OS X used  
launchd to

manage
these types of on-demand and always-on services.



But my app is a normal Cocoa App, it's not a daemon or an agent.



It's still essentially an agent, just one that runs in the  
foreground, not

the background.

You can use launchd to keep your app alive.  That way you, don't  
have to
worry about adding code to your application to do it, you just have  
to

ensure the launchd property list is in the right place.

That will also make development of your application easier, because  
your
application can run normally; you won't have to put a bunch of  
extra code

into it to disable its keep-alive behavior during development.




Great, so I understand from what you're saying that I can launch a  
GUI app
using launchd? I will look into it. Also, what if the application  
stops

responding? Is that something that launchd can detect?
___

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/maillist%40codingmammoth.com

This email sent to maill...@codingmammoth.com


___

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

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

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

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


Re: About [super dealloc];

2009-06-01 Thread Graham Cox


On 01/06/2009, at 9:52 PM, Bright wrote:

When should use the [super dealloc];?  Could anyone list all of  
case.


Whenever you have overridden -dealloc. Simple as that.

When do you override dealloc? When there are instance member variables  
(ivars) that must be released when your object is deallocated. While  
these will usually be also allocated at init time, there's no reason  
that there should be exact symmetry, so looking for it as a rule is  
misguided.


--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: About [super dealloc];

2009-06-01 Thread Jelle De Laender
You need to call [super dealloc] when you want to call the dealloc  
method of the super of your class. (logical, isn't?).


Every class has default the next dealloc method:

-(void)dealloc {
[super dealloc];
}

But, when you want to release classes you have initialised in your  
object, you need to do this in the dealloc method, so you need to  
overwrite the dealloc method, add your releases and call the dealloc  
of the super (to keep the chain).


See http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html 
 for the real method.


Jelle

On 01 Jun 2009, at 13:52, Bright wrote:


Hi ,all
In Cocoa, if there is [super init];, there will be [super  
dealloc]; correspondently at the end of this class.
But I find that sometimes if there is not [super init];, there  
will be [super dealloc]; correspondently too.
I puzzled. When should use the [super dealloc];?  Could anyone  
list all of case.



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/maillist%40codingmammoth.com

This email sent to maill...@codingmammoth.com


___

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

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

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

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


Re: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Keary Suska

On May 31, 2009, at 4:31 PM, Dominik Pich wrote:


Hi,
I use NSXMLParser to parse large XML files-- going good BUT :)
I cant get the parser to resolve the external entities from the DTD.

I googled and read documentation and older mails...
and I did set parser.shouldResolveExternalEntities = YES


Well, the docs state: 1) An NSXMLParser notifies its delegate about  
the items (elements, attributes, CDATA blocks, comments, and so on)  
that it encounters as it processes an XML document. It does not itself  
do anything with those parsed items except report them. and 2) in  
setShouldResolveExternalEntities, Indicates whether the receiver  
reports declarations of external entities using the delegate method  
parser:foundExternalEntityDeclarationWithName:publicID:systemID:.


I should be clear, then, that NSXMLParser does *not* resolve external  
entities in any way, only reports them, and explains what you see.



I do get:
- (NSData *)parser:(AQXMLParser *)parser resolveExternalEntityName: 
(NSString *)name systemID:(NSString *)systemID

but I have no idea what to return...
the entities are defined in the DTD...


As the docs say, An NSData object that contains the resolution of the  
given external entity


if I could get the folowing for the entries in the DTD, I would just  
build a table myself
- (void)parser:(AQXMLParser *)parser  
foundInternalEntityDeclarationWithName:(NSString *)name value: 
(NSString *)value;


Still, shouldnt NSXMLParser do entity substitution for me?
somehow... :)



The companion document to NSXMLParser, Event-Driven XML Programming  
Guide for Cocoa, tells you what you need to do to resolve external  
entities.


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


orderFrontStandardAboutPanel problem on Tiger - [NSCFDictionary setObject:forKey:]: attempt to insert nil value

2009-06-01 Thread Chris Jones
Hi, This is my first Cocoa App and I'm new to programming in anything other
than scripting languages, so please bear with me.
Goal: (embarrassingly simple) Show the about menu in a Tiger.  Everything
works find in Leopard.

Problem: I'm developing a NSStatusbar background (LSUIElement = true) app.
 It builds and functions perfectly in Leopard and builds in Tiger.  However,
I get one tiny problem in Tiger: an error in Console when accessing the
about menu of my application.

The error is: [NSCFDictionary setObject:forKey:]: attempt to insert nil
value. And the StandardAboutPanel does not appear.

Code:

- (IBAction)showAboutPanel:(id)sender {

[NSApp activateIgnoringOtherApps:YES];

[[NSApplication sharedApplication] orderFrontStandardAboutPanel:sender];

}

I don't think it could get more simple, but I can't see where I'm passing a
nil value. I thought this was related to a missing piece of info in
info.plist, but all required fields seem to be present.

I'm building this in 10.4 SDK on Xcode 3.1 on Leopard and have tried in
Xcode 2.5 on Tiger.

I've also tried the following straight from the Apple Developer docs :

- (IBAction)showAboutPanel:(id)sender {

[NSApp activateIgnoringOtherApps:YES];

NSDictionary *options;

NSImage *img;

img = [NSImage imageNamed: @iconAbout];


options = [NSDictionary dictionaryWithObjectsAndKeys:

@1.0, @Version,

@App name, @ApplicationName,

img, @ApplicationIcon,

@Copyright notice, @Copyright,

@App Version, @ApplicationVersion,

nil];

[[NSApplication sharedApplication]
orderFrontStandardAboutPanelWithOptions:options];

}


And done a lot of googling. My other thoughts were if I am missing a call to
a framework under Tiger somewhere?


Where am I passing this nil value?

Thanks for any help.

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: Problems choosing an encoding for Word generated html

2009-06-01 Thread Michael Ash
On Sun, May 31, 2009 at 7:08 PM, Ken Tozier kentoz...@comcast.net wrote:
 Hi

 I wrote an app that converts Word files into a simpler format by first
 converting from .doc to html using scripting and Word's Save as Web page
 command followed by using NSXMLDocument to extract the parts I need. I'm
 finding that there are no good options when it comes to choosing a character
 encoding for the saved html (this is set in Word) because it uses some
 custom tags to embed special characters like bullets and that UTF-8 chokes
 on.

 My basic process is to
 - Use Applescript to tell Word to convert from .doc to html and save as
 utf-8
 - Read the resultant file into an NSString with NSUTF8StringEncoding

 I've tried saving the html from Word as NSLatin1Encoding but many important
 characters like double-quotes, apostrophes, dashes etc are translated to cap
 O's with various diacritical marks.

 Not really sure how to proceed as there doesn't seem to be a single encoding
 useable by NSString that will both translate the quotes and allow me to
 access Word's special characters. Anyone have any ideas how I can read the
 html and treat it as a mostly normal character string without resorting to a
 custom binary  character translation class?

UTF-8 shouldn't choke on anything. It is a universal character
encoding. It's vaguely possible that Word uses some custom characters
that aren't even in Unicode, but if it does, those characters won't be
in any *other* encoding either, so they wouldn't work regardless.

Can you elaborate on just what choosing UTF-8 produces and how it fails?

In any case, this is probably more of a Word question than a Cocoa
question, and I imagine you'd get better answers somewhere where
people are knowledgeable about Word.

Mike
___

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: NSAttributedString -size Crash

2009-06-01 Thread Michael Ash
On Sun, May 31, 2009 at 7:30 PM, Kyle Sluder kyle.slu...@gmail.com wrote:
 On Sun, May 31, 2009 at 4:08 PM, Seth Willits sli...@araelium.com wrote:
 Alright, well, either way I know it's not happening because it's not in the
 console log.

 You don't know it's not nil unless you check yourself.  Set a
 conditional breakpoint; it's the only real way to reason about your
 code.

That is quite backwards. Breakpoints in Xcode's debugger are so
unreliable that the only real way to know whether a piece of code is
running is to stick a logging statement in it and see if it gets
printed. Since Cocoa has already done this for you in this case, it's
extra convenient.

 And FWIW, click a button isn't threadsafe.  AppKit on the whole, with
 few and documented exceptions, isn't threadsafe.

It's neither thread safe nor thread unsafe. It simply does not make
sense. Thread safety is a property of code or APIs, and click a
button is a physical action taken by a user.

I think what Seth meant to say was that this would only screw up if
clicking a button could run code in a secondary thread. The answer to
that is, only if you explicitly make it do so by spawning a thread (or
an operation or whatever) in your button's action.

Mike
___

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: orderFrontStandardAboutPanel problem on Tiger - [NSCFDictionary setObject:forKey:]: attempt to insert nil value

2009-06-01 Thread Jim Correia
On Mon, Jun 1, 2009 at 7:29 AM, Chris Jones littlemaca...@gmail.com wrote:

 The error is: [NSCFDictionary setObject:forKey:]: attempt to insert nil
 value. And the StandardAboutPanel does not appear.

[...]

 I don't think it could get more simple, but I can't see where I'm passing a
 nil value. I thought this was related to a missing piece of info in
 info.plist, but all required fields seem to be present.

Set a breakpoint on -[NSCFDictionary setObject:forKey:] and a
condition for when the object parameter is nil. (The specific
condition is going to depend upon what architecture you are debugging
in.)

When you stop there, examine the value for the key. Hopefully at that
point the problem is obvious.

- Jim
___

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: NSTableView - setting row heights

2009-06-01 Thread Corbin Dunn


On Jun 1, 2009, at 2:50 AM, Peter Hudson wrote:

The problem appears when I try to select a row. Rows are not  
selectable.

When I try to select a row I get the error message

NSConcreteMutableAttributedString addAttribute:value:range:: nil value


Break on objc_exception_throw and look at the bt; that should help you  
find the source of the exception being raised.


http://www.corbinstreehouse.com/blog/index.php/2008/08/your-most-important-breakpoint-in-cocoa/

corbin


___

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: Several Questions

2009-06-01 Thread Benjamin Dobson


On 1 Jun 2009, at 12:58:17, Jelle De Laender wrote:


why should your app stops responding?

Do you want to detect time-outs (network-times, IO-timeouts, ...) or  
will your app be crap and full with bugs?


There will always be unforeseen circumstances. Better safe than sorry,  
right?


Just because an app *may* stop responding doesn't mean it's crap or  
full of bugs. It's good that the developer is aware that he isn't  
perfect and might miss something. All sorts of applications have  
crashed or stopped responding on me. I wouldn't say many of them were  
crap and full of bugs.

___

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: Several Questions

2009-06-01 Thread Michael Ash
On Mon, Jun 1, 2009 at 7:19 AM, Ammar Ibrahim ammar.ibra...@gmail.com wrote:
 Great, so I understand from what you're saying that I can launch a GUI app
 using launchd? I will look into it. Also, what if the application stops
 responding? Is that something that launchd can detect?

As far as I know, no, launchd can't know if you stop responding,
which is not a well defined condition in any case.

You'll have to do that part of it yourself. Ideally, you'll have a
separate tool (which can also be maintained by launchd) that pings the
main application periodically and kills it if it doesn't respond
within some timeout. This tool would be as small as possible to reduce
the chance of a hanging bug in it. You could do a similar thing by
simply spawning a watchdog thread within your own application,
although the chance for mishap is higher there.

Mike
___

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: NSURLConnection sendSynchronousRequest: crashes since, upgrading to 10.5.7

2009-06-01 Thread Dennis Hartigan-O'Connor

Thanks, Andrew,

I believe that Colin Gray got to the bottom of this at Stack Overflow:

http://stackoverflow.com/questions/916718/nsurlconnection-crashing-under-10-5-7

Dennis


Andrew Farmer wrote:

On 27 May 2009, at 18:20, Dennis Hartigan-O'Connor wrote:
I have a very similar problem: my simple program that downloads stock 
prices has been working fine but intermittently crashes on 10.5.7, 
whether I use sendSynchronousRequest or stringWithContentsOfURL.  For 
me, too, everything is fine for 10-15 minutes and then the program 
crashes.


Here is the crash log from the crashed thread:

Thread 1 Crashed:
0   libobjc.A.dylib 0x965c3688 objc_msgSend + 24
1   com.apple.CoreFoundation0x946cc581 
_CFStreamSignalEventSynch + 193
2   com.apple.CoreFoundation0x946ba595 
CFRunLoopRunSpecific + 3141
3   com.apple.CoreFoundation0x946bac78 CFRunLoopRunInMode 
+ 88
4   com.apple.Foundation0x9058c530 
+[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 
320

5   com.apple.Foundation0x90528e0d -[NSThread main] + 45
6   com.apple.Foundation0x905289b4 __NSThread__main__ 
+ 308


Any ideas out there?  I can't believe this isn't happening to lots of 
people.


The symptoms described in the original thread all pointed strongly to a 
latent memory management issue that's being triggered by changes in the 
URL loading code. Does your application print any console output before 
(or as) it's crashing? If this doesn't point straight at anything, try 
running your application under MallocDebug.




___

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


QTMovieLayer and movie controls

2009-06-01 Thread Ramakrishna Vavilala
I have layer hosting view which hosts a single layer with several child
layers. Some child layers can be QTMovieLayers to display quick time movies.
 Things work fine.
Now my main issue is that I want to add video controls (Play, Pause, time
Slider) to control the movie:  Is there an already available solution for
it?

I have the following options:-

1. Create a sub-view with controls - buttons and a slider. But it seems
that adding subviews to layer hosting views is a no - no.

2. Create a layer for controls and implement controls as CALayers.

Which is a better option? Is there a third option?
___

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


highlighting menu item in main menu bar

2009-06-01 Thread kvic...@pobox.com
my app has a scripts menu item (in the main menu bar). the items in 
this menu correspond to applescript files the user has placed in my 
application support folder. when the user selects one of these menu 
items, i execute the appropriate script. i execute the script in a 
(sub) task (NSTask). i do it this way because i discovered (the 
hard/empirical way) that if an executing script, executes 
functionality in my app that calls -[NSScriptCommand 
suspendExecution], then the executing of that script will erroneously 
terminate early. using a sub task solves this problem.


in my app, when i launch this task, i register for the 
NSTaskDidTerminateNotification and in my notification routine, i 
display any errors returned.


this all works fine... except that as soon as i return from launching 
the sub task, the menu item (in the main menu bar) for the scripts 
menu un-highlights. i would like this to remain highlighted until my 
notification routine is called, in order to provide feedback to the 
user that his/her script is still executing.


is this possible? if so, could someone provide any code and/or 
documentation pointers?


thanx,
ken
___

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


Cancel button in NSSearchField

2009-06-01 Thread kvic...@pobox.com
my app contains an NSSearchField in the toolbar of the various 
document windows. and i have the various predicates of the search 
field bound to iVars in my app. additionally, i have my own predicate 
builder that lets the user build complex search predicates. when the 
user has built a complex predicate, i set the placeholder text of the 
search field to be Custom Filter.


all this works fine.

the problem is that in the situation in which there is a custom 
filter, there is no text for the search field, and thus the cancel 
button doesn't show. i've worked around this for now by having a 
Cancel Custom Filter menu item in the search field's menu.


is there anyway to get the cancel button to show if the search field 
has my special (Custom Filter) placeholder text?


thanx,
ken
___

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: Several Questions

2009-06-01 Thread Todd Heberlein

why should your app stops responding?

Do you want to detect time-outs (network-times, IO-timeouts, ...) or  
will your app be crap and full with bugs?


I wish my code never had infinite loops (Apple's address:) or  
multithreaded deadlocks or other types of bugs... but sometimes sh*t  
happens. I'm not sure how launchd would reliably detect all the  
potential variations however. I liked someone else's suggested  
solution -- periodically send your application something it should  
respond to, or maybe have it generate some type of heartbeat (e.g.,  
send a message to another application, append data to a file, or  
update the timestamp on a file).


Todd

___

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

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

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

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


Re: QTMovieLayer and movie controls

2009-06-01 Thread David Duncan

On Jun 1, 2009, at 9:29 AM, Ramakrishna Vavilala wrote:

Now my main issue is that I want to add video controls (Play, Pause,  
time
Slider) to control the movie:  Is there an already available  
solution for

it?


Nothing that I'm aware of.


I have the following options:-

1. Create a sub-view with controls - buttons and a slider. But it  
seems

that adding subviews to layer hosting views is a no - no.


Correct. You could however add them as a subview of the superview for  
the hosting view and then position them over the hosting view.



2. Create a layer for controls and implement controls as CALayers.


This is also an option, although you would need to do hit testing and  
such yourself. For that reason alone I would probably go with option 1.

--
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: NSTableView - setting row heights

2009-06-01 Thread Corbin Dunn
Yup -- that makes it tough to figure out with that bt, since the  
problem doesn't appear to be in your code.


Can you post your objectValueXXX method implementation?

Can you also show the string in your array that you are setting as the  
object value? (ie: print it in the debugger or NSLog(@%@) on it.)


corbin

On Jun 1, 2009, at 9:40 AM, Peter Hudson wrote:


Hi Corbin,

Many thinks for the debug tip - it works a treat !
I'll just leave it there for the future.

Here is the stack trace when the exception is thrown.
I can't see where the problem is as the underlying code has clearly  
used the attributed strings to draw the contents in the first place.

Is the mechanism of rendering different when I try to select a row ?

Peter

StackTrace-NSAttributedStringProblem.tiff







On 1 Jun 2009, at 16:37, Corbin Dunn wrote:



On Jun 1, 2009, at 2:50 AM, Peter Hudson wrote:

The problem appears when I try to select a row. Rows are not  
selectable.

When I try to select a row I get the error message

NSConcreteMutableAttributedString addAttribute:value:range:: nil  
value


Break on objc_exception_throw and look at the bt; that should help  
you find the source of the exception being raised.


http://www.corbinstreehouse.com/blog/index.php/2008/08/your-most-important-breakpoint-in-cocoa/

corbin






___

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: NSURLConnection sendSynchronousRequest: crashes since, upgrading to 10.5.7

2009-06-01 Thread Jeff Johnson
I'm not sure that this is the full story. My app Vienna implements  
connection:willSendRequest: redirectResponse: at AsyncConnection.m: 396


http://vienna-rss.svn.sourceforge.net/viewvc/vienna-rss/trunk/2.3.0/AsyncConnection.m?view=markup

However, I'm seeing crash reports from users on 10.5.7, for example:

http://dl.getdropbox.com/u/32952/ViennaCrash.txt

-Jeff



On Jun 1, 2009, at 11:23 AM, Dennis Hartigan-O'Connor wrote:


Thanks, Andrew,

I believe that Colin Gray got to the bottom of this at Stack Overflow:

http://stackoverflow.com/questions/916718/nsurlconnection-crashing-under-10-5-7

Dennis


Andrew Farmer wrote:

On 27 May 2009, at 18:20, Dennis Hartigan-O'Connor wrote:
I have a very similar problem: my simple program that downloads  
stock prices has been working fine but intermittently crashes on  
10.5.7, whether I use sendSynchronousRequest or  
stringWithContentsOfURL.  For me, too, everything is fine for  
10-15 minutes and then the program crashes.


Here is the crash log from the crashed thread:

Thread 1 Crashed:
0   libobjc.A.dylib 0x965c3688 objc_msgSend + 24
1   com.apple.CoreFoundation0x946cc581  
_CFStreamSignalEventSynch + 193
2   com.apple.CoreFoundation0x946ba595  
CFRunLoopRunSpecific + 3141
3   com.apple.CoreFoundation0x946bac78  
CFRunLoopRunInMode + 88
4   com.apple.Foundation0x9058c530 + 
[NSURLConnection(NSURLConnectionReallyInternal)  
_resourceLoadLoop:] + 320
5   com.apple.Foundation0x90528e0d -[NSThread  
main] + 45
6   com.apple.Foundation0x905289b4  
__NSThread__main__ + 308


Any ideas out there?  I can't believe this isn't happening to lots  
of people.
The symptoms described in the original thread all pointed strongly  
to a latent memory management issue that's being triggered by  
changes in the URL loading code. Does your application print any  
console output before (or as) it's crashing? If this doesn't point  
straight at anything, try running your application under MallocDebug.


___

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: highlighting menu item in main menu bar

2009-06-01 Thread Peter Ammon

Hi Ken,

The menu item unhighlights after the menu item's action is finished.   
If user input should be blocked while the script is running, then you  
should register for the NSTaskDidTerminateNotification and then drive  
the main run loop forwards from within your menu item's action method,  
until you get the notification.


On the other hand, if the user can continue using your app as normal,  
you should not show the menu item highlighted, because the user might  
want to choose different menu items.


On Jun 1, 2009, at 9:34 AM, kvic...@pobox.com wrote:

my app has a scripts menu item (in the main menu bar). the items in  
this menu correspond to applescript files the user has placed in my  
application support folder. when the user selects one of these menu  
items, i execute the appropriate script. i execute the script in a  
(sub) task (NSTask). i do it this way because i discovered (the hard/ 
empirical way) that if an executing script, executes functionality  
in my app that calls -[NSScriptCommand suspendExecution], then the  
executing of that script will erroneously terminate early. using a  
sub task solves this problem.


in my app, when i launch this task, i register for the  
NSTaskDidTerminateNotification and in my notification routine, i  
display any errors returned.


this all works fine... except that as soon as i return from  
launching the sub task, the menu item (in the main menu bar) for the  
scripts menu un-highlights. i would like this to remain highlighted  
until my notification routine is called, in order to provide  
feedback to the user that his/her script is still executing.


is this possible? if so, could someone provide any code and/or  
documentation pointers?


thanx,
ken


___

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] mergeChangesFromContextDidSaveNotification: and thread safety

2009-06-01 Thread Sean McBride
On 5/29/09 2:25 PM, Ben Trumbull said:

You can download the debug version of Core Data from ADC and use the
multithreading assertions.

Not if you're using 10.5.7 you can't.  :(  The 'Debug and Profile
Libraries' for 10.5.7 are still unavailable.

--

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


___

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

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

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

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


Re: highlighting menu item in main menu bar

2009-06-01 Thread kvic...@pobox.com

hi peter,
thanx for the reply.

i believe i understand your reply. i've never driven the run loop 
forward by hand before, but i think i could figure that out. but 
before i embark down that path, some quick questions that perhaps you 
could help me with:


1) if the executing script (from the sub task) causes my app to 
display a dialog that requires user input, would this be blocked by 
driving the run loop manually from within the initiating menu item's 
action method?


2) the reason i went to using a sub task was because of problems with 
-[NSScriptCommand suspendExecution] (see below). do you know if i 
might have similar problems if i'm driving the run loop manually? (or 
am i destined to go down this path and see what happens? :-( )


thanx,
ken


At 11:10 AM -0700 6/1/09, Peter Ammon wrote:

Hi Ken,

The menu item unhighlights after the menu item's action is finished.  
If user input should be blocked while the script is running, then 
you should register for the NSTaskDidTerminateNotification and then 
drive the main run loop forwards from within your menu item's action 
method, until you get the notification.


On the other hand, if the user can continue using your app as 
normal, you should not show the menu item highlighted, because the 
user might want to choose different menu items.


On Jun 1, 2009, at 9:34 AM, kvic...@pobox.com wrote:

my app has a scripts menu item (in the main menu bar). the items in 
this menu correspond to applescript files the user has placed in my 
application support folder. when the user selects one of these menu 
items, i execute the appropriate script. i execute the script in a 
(sub) task (NSTask). i do it this way because i discovered (the 
hard/empirical way) that if an executing script, executes 
functionality in my app that calls -[NSScriptCommand 
suspendExecution], then the executing of that script will 
erroneously terminate early. using a sub task solves this problem.


in my app, when i launch this task, i register for the 
NSTaskDidTerminateNotification and in my notification routine, i 
display any errors returned.


this all works fine... except that as soon as i return from 
launching the sub task, the menu item (in the main menu bar) for 
the scripts menu un-highlights. i would like this to remain 
highlighted until my notification routine is called, in order to 
provide feedback to the user that his/her script is still executing.


is this possible? if so, could someone provide any code and/or 
documentation pointers?


thanx,
ken


___

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: QTMovieLayer and movie controls

2009-06-01 Thread Klaus Backert


On 1. Jun 2009, at 18:29, Ramakrishna Vavilala wrote:

I have layer hosting view which hosts a single layer with several  
child
layers. Some child layers can be QTMovieLayers to display quick time  
movies.

Things work fine.
Now my main issue is that I want to add video controls (Play, Pause,  
time
Slider) to control the movie:  Is there an already available  
solution for

it?

I have the following options:-

1. Create a sub-view with controls - buttons and a slider. But it  
seems

that adding subviews to layer hosting views is a no - no.

2. Create a layer for controls and implement controls as CALayers.

Which is a better option? Is there a third option?


What's about QTMovieView? It has builtin controls. Look at the  
QTKitPlayer in the example folder of your Xcode installation.


Klaus

___

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


Fwd: Making an undefined Spotlight NSPredicate?

2009-06-01 Thread Nick Zitzmann
I asked this a while back on the Spotlight mailing list and never  
received a reply. Maybe someone here knows.


Begin forwarded message:


From: Nick Zitzmann n...@chronosnet.com
Date: May 20, 2009 6:38:36 PM MDT
To: spotlight-...@lists.apple.com
Subject: Making an undefined Spotlight NSPredicate?
X-Mailer: Apple Mail (2.935.3)

I did search the archives, and didn't see anything. How do I make a  
NSPredicate for an NSMetadataQuery which evaluates to true if a key- 
value is undefined by the metadata? I'm trying to run a query that  
returns true if something is not present.


I already tried com_chronos_ourkey == NULL, and when attempting to  
set the predicate in the NSMetadataQuery object, it raises this  
exception: NSComparisonPredicate with a right expression which is  
not a string, number, or date given to NSMetadataQuery  
(com_chronos_ourkey == nil)


Nick Zitzmann
http://www.chronosnet.com/

___
Do not post admin requests to the list. They will be ignored.
Spotlight-dev mailing list  (spotlight-...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/spotlight-dev/nick%40chronosnet.com

This email sent to n...@chronosnet.com



Nick Zitzmann
http://www.chronosnet.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


NSMapTable C function API equivalent

2009-06-01 Thread George King
I just read in the NSMapTable Class Reference that I can use the class  
to map to and from pointers to C structs:


You can configure an NSMapTable instance to operate on arbitrary  
pointers and not just objects, although typically you are encouraged  
to use the C function API for void * pointers. The object-based API  
(such as setObject:forKey:) will not work for non-object pointers  
without type-casting.


Can somebody point me to the documentation for the C function API  
referred to above? I was hoping to find a CFMapTable but I suppose  
that would be too obvious :)


 Are there any known simple examples of using NSMapTable with C  
pointers as keys?


As for type casting, does this simply mean that I need to cast my key  
and value C pointer types to id in order for the compiler to accept  
them as message arguments?


My particular use case is that I have a simple pair struct that  
consists of two unsigned ints, which I use as a key to look up an  
NSArray. I could use a std::map with NSArray* as the value type, and  
ignore the objective-c retain/release semantics for the NSArray  
pointers in the map, but I'd prefer to respect those. Currently I'm  
converting the pair struct into an NSNumber for use as a key in an  
NSDictionary, which seems to work OK, but I'm concerned that all the  
autoreleased NSNumbers are going to pile up. Rather than start  
creating and draining pools, I would prefer to avoid the temporary key  
instances altogether. This is a performance-sensitive lookup in both  
time and space; it remains to be seen whether Cocoa hash tables or stl  
map trees are more efficient.


Thanks!
George
___

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: NSMapTable C function API equivalent

2009-06-01 Thread Seth Willits
Can somebody point me to the documentation for the C function API  
referred to above? I was hoping to find a CFMapTable but I suppose  
that would be too obvious :)



Type NSMapTable into Xcode and command-double click on it to open  
NSMapTable.h. The functions are all in the header.


They're also documented in Foundation reference:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html


Are there any known simple examples of using NSMapTable with C  
pointers as keys?


I doubt it. It's pretty straightforward.


As for type casting, does this simply mean that I need to cast my  
key and value C pointer types to id in order for the compiler to  
accept them as message arguments?


Yes.



--
Seth Willits



___

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: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Dominik Pich

:) thanks but . it doesnt work for me.
I read all that about NSParser just calling you back. I implemented  
all the delegates BUT
I dont seem to be getting an appropriate callback for the Entities in  
the DTD, although I did set 'shouldResolveExternalEntities = YES'


I get that messages asking me to PROVIDE a substitution for an entity
But I never get the messages FOR the declaration of the entities, so I  
dont know WHAT to return as data.


I hope I explained my issue?

For example:
In the xml I have
nameOfPerson; goes to nameOfCiname; :)

I never get to know about the declares (which are in the DTD. which  
should be loaded. no?)
 http://developer.apple.com/documentation/Cocoa/Conceptual/XMLParsing/Articles/ValidatingXML.html#/ 
/apple_ref/doc/uid/20002269-BBCFBAHB


On 01.06.2009, at 17:16, Keary Suska wrote:


On May 31, 2009, at 4:31 PM, Dominik Pich wrote:


Hi,
I use NSXMLParser to parse large XML files-- going good BUT :)
I cant get the parser to resolve the external entities from the DTD.

I googled and read documentation and older mails...
and I did set parser.shouldResolveExternalEntities = YES


Well, the docs state: 1) An NSXMLParser notifies its delegate about  
the items (elements, attributes, CDATA blocks, comments, and so on)  
that it encounters as it processes an XML document. It does not  
itself do anything with those parsed items except report them. and  
2) in setShouldResolveExternalEntities, Indicates whether the  
receiver reports declarations of external entities using the  
delegate method  
parser:foundExternalEntityDeclarationWithName:publicID:systemID:.


I should be clear, then, that NSXMLParser does *not* resolve  
external entities in any way, only reports them, and explains what  
you see.



I do get:
- (NSData *)parser:(AQXMLParser *)parser resolveExternalEntityName: 
(NSString *)name systemID:(NSString *)systemID

but I have no idea what to return...
the entities are defined in the DTD...


As the docs say, An NSData object that contains the resolution of  
the given external entity


if I could get the folowing for the entries in the DTD, I would  
just build a table myself
- (void)parser:(AQXMLParser *)parser  
foundInternalEntityDeclarationWithName:(NSString *)name value: 
(NSString *)value;


Still, shouldnt NSXMLParser do entity substitution for me?
somehow... :)



The companion document to NSXMLParser, Event-Driven XML Programming  
Guide for Cocoa, tells you what you need to do to resolve external  
entities.


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/dominik%40pich.info

This email sent to domi...@pich.info


Dominik Pich
http://www.pich.info




___

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: About [super dealloc];

2009-06-01 Thread Greg Parker

On Jun 1, 2009, at 4:59 AM, Graham Cox wrote:

On 01/06/2009, at 9:52 PM, Bright wrote:
When should use the [super dealloc];?  Could anyone list all of  
case.


Whenever you have overridden -dealloc. Simple as that.


Pretty much. If you override +alloc then you may or may not want to  
call [super dealloc], depending on exactly what your +alloc  
implementation does. But you should almost never override +alloc.



--
Greg Parker gpar...@apple.com Runtime Wrangler


___

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 NSMenuItem in IB

2009-06-01 Thread Jonathan Hess


On Jun 1, 2009, at 2:59 AM, Vijay Kanse wrote:


Sorry for My Question,
Actually i was dragging NSMenu from Library and I was trying to Add  
it as

Sub Menu.


Ah, the problem here is that NSMenu instances contain an array of  
NSMenuItem instances. NSMenuItem instances can each contain a single  
NSMenu.


The hierarchy of a main menu would look something like this:

NSMenu (Main Menu)
NSMenuItem(File)
NSMenu(File)
NSMenuItem(Open)
NSMenuItem(Save As)
…
NSMenuItem(Edit)
NSMenuItem(View)

Jon Hess




Thanks For guiding me right way.


On Mon, Jun 1, 2009 at 2:49 PM, Kyle Sluder kyle.slu...@gmail.com  
wrote:


On Mon, Jun 1, 2009 at 12:39 AM, Vijay Kanse vijay.ka...@avinashi.com 


wrote:
I am not able to drag NSMenu to main menu. and i am not able to do  
it by

coding as well.


Really?  There's an Edit menu in the IB library which you should be
able to just drag to the main menu in your MainMenu.nib.  If this
isn't working for you, please explain exactly what you're trying to
do.

--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/jhess%40apple.com

This email sent to jh...@apple.com


___

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

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

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

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


Re: Several Questions

2009-06-01 Thread Todd Heberlein
FYI: I was looking through some Darwin mailing lists archives, and I  
ran across this posting about launchd at WWDC that may be of interest  
to this thread:



Hello all,

If you're attending WWDC and are interested in the BSD-level  
technologies in Mac OS X, I'm giving a talk on launchd this year. It's  
session 500, Managing Processes with launchd, and several of us from  
the BSD team will be available for QA afterward. We'll all be happy  
to answer your questions.


Hope to see you there!
--
Damien Sorresso
BSD Engineering
Apple Inc.

___

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: Setting wantsLayer = YES; crashes on view load.

2009-06-01 Thread Kevin Ross

Thanks Michael,

I do have a few notifications registered throughout the app, but  
nothing that is connected with any of the CALayers or views.  This  
seems to happen no matter which view or nib I use.  I'm trying to see  
if I can isolate the notification that is causing  the crash.




On Jun 1, 2009, at 12:07 AM, Michael Vannorsdel wrote:

Are you registering for any notifications?  It looks like it's  
crashing while trying to notify an object.



On Jun 1, 2009, at 12:31 AM, Kevin Ross wrote:

Hi everyone, I have a Core Data document based app that I've been  
working on for a while and I now want to change some of the view  
drawing to use CALayers.  The trouble I'm having is that when I set  
a view's wantsLayer = YES, I end up getting EXC_BAD_ACCESS.This  
happens when I try to set it on any arbitrary view in any of the  
nibs in my project, when setting it from code, or from clicking the  
checkbox in IB.  I've tried new CALayer projects from scratch and  
they work fine, is there something I could have done to my project  
that would prevent me from setting a view's wantsLayer property to  
YES?


Thank you for taking time to read this.


___

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/apple-lists%40twentyfourmountains.com

This email sent to apple-li...@twentyfourmountains.com



___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-06-01 Thread Sean McBride
On 5/28/09 3:49 PM, Martin Wierschin said:

This is a nice trick, I wasn't aware of that function, thanks.
Perhaps a minor improvement (one call instead of two):

- (BOOL) isTrashedFileAtPath:(NSString*)path
{
   Boolean inTrash = false;
   const UInt8* utfPath = (UInt8*)[path UTF8String];
   OSStatus err = DetermineIfPathIsEnclosedByFolder(kOnAppropriateDisk,
kTrashFolderType, utfPath, false, inTrash);
   return (noErr == err) ? (true == inTrash) : NO;
}

Probably it does the same thing behind the scenes, but why not.

For the archives: 2 more problems:

a) use fileSystemRepresentation not UTF8String.

b) with GC, 'path' may be collected before
DetermineIfPathIsEnclosedByFolder() is finished with utfPath.  So best
to add a [path self] just before the 'return'.

--

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


___

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

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

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

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


Re: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Jeffrey Oleander

 On Mon, 2009/06/01, Keary Suska cocoa-...@esoteritech.com wrote:
 From: Keary Suska cocoa-...@esoteritech.com
 Subject: Re: NSXMLParser - howto resolve entities defined in DTD
 To: Cocoa-Dev (Apple) Cocoa-dev@lists.apple.com
 Date: Monday, 2009 June 1, 10:16
 On 2009 May 31, at 4:31 PM, Dominik Pich wrote:
 I use NSXMLParser to parse large XML files-- going
 good BUT :)
 I cant get the parser to resolve the external entities
 from the DTD.
 
 I googled and read documentation and older mails...
 and I did set parser.shouldResolveExternalEntities =
 YES
 
 Well, the docs state: 1) An NSXMLParser notifies its
 delegate about the items (elements, attributes, CDATA
 blocks, comments, and so on) that it encounters as it
 processes an XML document. It does not itself do
 anything with those parsed items except report them.
 and 2) in setShouldResolveExternalEntities, Indicates
 whether the receiver reports declarations of external
 entities using the delegate method
 parser:foundExternalEntityDeclarationWithName:publicID:systemID:.
 
 I should be clear, then, that NSXMLParser does *not*
 resolve external entities in any way, only reports
 them, and explains what you see.

And I don't recall it saying anything about parsing and
otherwise examining the DTD or XML schema file except 
that there were hooks for later possible development
of means to check whether the XML conforms to a DTD
or XML schema.

My reading is that it should be possible to have it 
parse whatever it finds in an XML file without any 
regard for whether it conforms to a DTD or XML schema.



  
___

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: NSURLConnection sendSynchronousRequest: crashes since, upgrading to 10.5.7

2009-06-01 Thread Dennis Hartigan-O'Connor
Thanks, Jeff, others are also saying that implementing this method 
doesn't always fix the problem.  Which makes sense: presumably Apple's 
implementation amounts to return request;, so it is hard to see how 
that method could be at the root of the problem.


I hope everybody is filing bug reports with Apple.  I just can't believe 
that Apple could have introduced a flaw in something so basic.



Jeff Johnson wrote:
I'm not sure that this is the full story. My app Vienna implements 
connection:willSendRequest: redirectResponse: at AsyncConnection.m: 396


http://vienna-rss.svn.sourceforge.net/viewvc/vienna-rss/trunk/2.3.0/AsyncConnection.m?view=markup 



However, I'm seeing crash reports from users on 10.5.7, for example:

http://dl.getdropbox.com/u/32952/ViennaCrash.txt

-Jeff



On Jun 1, 2009, at 11:23 AM, Dennis Hartigan-O'Connor wrote:


Thanks, Andrew,

I believe that Colin Gray got to the bottom of this at Stack Overflow:

http://stackoverflow.com/questions/916718/nsurlconnection-crashing-under-10-5-7 



Dennis


Andrew Farmer wrote:

On 27 May 2009, at 18:20, Dennis Hartigan-O'Connor wrote:
I have a very similar problem: my simple program that downloads 
stock prices has been working fine but intermittently crashes on 
10.5.7, whether I use sendSynchronousRequest or 
stringWithContentsOfURL.  For me, too, everything is fine for 10-15 
minutes and then the program crashes.


Here is the crash log from the crashed thread:

Thread 1 Crashed:
0   libobjc.A.dylib 0x965c3688 objc_msgSend + 24
1   com.apple.CoreFoundation0x946cc581 
_CFStreamSignalEventSynch + 193
2   com.apple.CoreFoundation0x946ba595 
CFRunLoopRunSpecific + 3141
3   com.apple.CoreFoundation0x946bac78 
CFRunLoopRunInMode + 88
4   com.apple.Foundation0x9058c530 
+[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] 
+ 320
5   com.apple.Foundation0x90528e0d -[NSThread main] 
+ 45
6   com.apple.Foundation0x905289b4 
__NSThread__main__ + 308


Any ideas out there?  I can't believe this isn't happening to lots 
of people.
The symptoms described in the original thread all pointed strongly to 
a latent memory management issue that's being triggered by changes in 
the URL loading code. Does your application print any console output 
before (or as) it's crashing? If this doesn't point straight at 
anything, try running your application under MallocDebug.





___

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: Custom view resizing

2009-06-01 Thread Robert Olivier


Thanks Graham,

While I was waiting for my post to get moderated I did implement the  
data model method of calculating the view bounds and thats working  
great.


rjo

On May 29, 2009, at 11:55 PM, Graham Cox wrote:



On 29/05/2009, at 10:14 AM, Robert Olivier wrote:

I'm a new Cocoa programmer working on my first non-trivial custom  
view and I have a question regarding the right way to handle view  
resizing.


Say that I have a list of shapes that I need to draw left to right  
across my view, and this list grows over time.  Eventually, I will  
need to draw a shape outside of the existing view frame and I when  
this happens I want to resize the view.


Initially I had all of the drawing code directly in the view and  
when the code detected that the next shape would be outside of the  
existing view bounds it would resize it like this:


if((current + spacing + headerSize.width) = rect.size.width) {
NSSize newSize;
newSize.width = [self frame].size.width + spacing+headerSize.width;
newSize.height = [self frame].size.height;
[super setFrameSize:newSize];
[self setNeedsDisplay:YES];
}


This is a very bad idea. From what you're saying this is called  
within -drawRect: You should never try do do anything except drawing  
there.


I want to move to a model where the shapes draw themselves rather  
than having all of the drawing code in the custom view, but without  
the shape object knowing anything about the NSView object itself,  
only the NSRect that is being drawn.


What is the best practice for this?  Am I thinking right that the  
shapes should draw themselves rather inspecting each shape and  
drawing it in the view?



There are differing views on this, but yes, I think this is a good  
way to go. I'd suggest you do need a way to tell the shapes what  
view they are drawing in though, so they can ask it whether they  
really need to draw (using -needsToDrawRect:, etc).



IF so, and a shape object knows that the view is not big enough for  
it to render itself, should it send a notification to the view  
telling it to resize or would it be best to just let the shape  
objects know about the NSView object?  What are the implications  
for pagination during a print job?


Do NOT attempt to resize the view while drawing. It doesn't matter  
if this is triggered by a notification or in some other way,  
resizing the view at drawing time is a bad idea. Don't do it.


Instead, look at it another way. You are adding and removing shapes  
in a data model. Each shape has a bounding rect. The data model  
could calculate the union of the bounding rect easily, so when a  
shape is added/removed, ask the DM for the overall bounds and size  
the view to that. This is done totally outside of the drawing code.  
Adding/Removing/Resizing will trigger drawing, which then just  
iterates over the shapes and asks them to draw. At that point the  
view will be the right size.


--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


NSFileManager's copyItemAtPath:toPath:error: syslogging every directory it finds?

2009-06-01 Thread Jim Turner
Hopefully this has a simple answer but it seems now that when I call
copyItemAtPath:toPath:error: to copy a folder to another location, I
get this in the console:

6/1/09 3:48:28 PM
/Users/jimt/Source/MyApp/trunk/build/Debug/MyApp.app/Contents/MacOS/MyApp[29625]
reading from /Users/jimt/Library/MyApp/MyFolder: Is a directory

I had to break on syslog() to see who was even causing this to happen.
 I'm not sure what's changed or if I've set some magic flag someplace
that's finding its way into the internals of
copyItemAtPath:toPath:error: but does anyone know why I'd be getting
that logged? Very confusing.

-- 
Jim
http://nukethemfromorbit.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


SQL store, GC apps, statement is still active exception, setReturnsObjectsAsFaults:NO

2009-06-01 Thread Sean McBride
Hi all,

Now that 10.5.7 (allegedly) fixes the incompatibilities between the SQL
store and GC apps, I have been trying to switch from XML to SQL.  Most
problems I've fixed, but I'm getting an exception:

statement is still active

See backtrace below.  I've search the archives of course, and see that
this is usually a threading problem.  My app is multithreaded, but I do
all my UI, bindings, and Core Data stuff on the main thread (barring
mistakes).

Experimentation has revealed that if I change this:

[request setReturnsObjectsAsFaults:NO];

from NO to YES the problem goes away.

What might I be doing wrong here?  Or is this a Core Data bug?

#0  0x9539ae17 in objc_exception_throw ()
#1  0x92b1f178 in -[NSSQLConnection prepareSQLStatement:] ()
#2  0x92b1ea33 in -[NSSQLiteConnection prepareSQLStatement:] ()
#3  0x92b4fdab in -[NSSQLChannel selectRowsWithCachedStatement:] ()
#4  0x92b1b17b in newFetchedRowsForFetchPlan_MT ()
#5  0x92b4f410 in -[NSSQLCore newFetchedPKsForSourceID:andRelationship:] ()
#6  0x92b4eeff in -[NSSQLCore retaine
dRelationshipDataWithSourceID:forRelationship:withContext:] ()
#7  0x92b4ec47 in -[NSFaultHandler re
tainedFulfillAggregateFaultForObject:andRelationship:withContext:] ()
#8  0x92b25597 in -[_NSFaultingMutableSet willRead] ()
#9  0x92b28459 in -[_NSFaultingMutableSet
countByEnumeratingWithState:objects:count:] ()
#11 0x003cc449 in -[MyManagedObjectSuperClass awakeFromFetch]
#12 0x003cdf70 in -[MyManagedObject awakeFromFetch]
#13 0x92b0b987 in _PFFaultHandlerFulfillFault ()
#14 0x92b38162 in -[NSSQLCore _prepareResultsFromResultSet:usingFetchPlan:] ()
#15 0x92b242ab in -[NSSQLCore _newRow
sForFetchPlan:selectedBy:withArgument:] ()
#16 0x92b141b0 in -[NSSQLCore newRowsForFetchPlan:] ()
#17 0x92b13d10 in -[NSSQLCore objectsForFetchRequest:inContext:] ()
#18 0x92b13a17 in -[NSSQLCore executeRequest:withContext:] ()
#19 0x92b12aaa in -[NSPersistentStoreCoordinator(_NSInternalMethods)
executeRequest:withContext:] ()
#20 0x92b1007b in -[NSManagedObjectContext executeFetchRequest:error:] ()

Thanks,

--

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


___

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

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

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

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


gcc parsing error?

2009-06-01 Thread Dave DeLong

Hey everyone,

I'm writing a simple test project to try and isolate some unexpected  
behavior, and found more unexpected behavior (not what I was looking  
for).


I'm trying to use a simple NSAssert macro, like so:

NSAssert(NO, [NSString stringWithFormat:@Caught unexpected exception:  
%@, e]);


However, when I try to compile, I get the error that macro NSAssert  
passed 3 arguments, but takes just 2.  To verify what I'm seeing, I  
tried changing it to:


NSAssert(NO, [NSString stringWithFormat:@Caught unexpected exception:  
%@, %@, e, e]);


This tells me I'm passing 4 arguments to NSAssert (instead of the  
required 2).  If I change it to:


NSString *err = [NSString stringWithFormat:@Caught unexpected  
exception: %@, e];

NSAssert(NO, err);

That will compile appropriately.  It would therefore appear that the  
statement is not getting correctly parsed.


So my question is:  Is this expected/documented behavior?  (My  
searches haven't found anything)  If it isn't, is this a known issue?   
If not, where would be the best place to file a bug?


Thanks,

Dave

___

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: gcc parsing error?

2009-06-01 Thread Stephen J. Butler
On Mon, Jun 1, 2009 at 4:33 PM, Dave DeLong davedel...@me.com wrote:
 I'm writing a simple test project to try and isolate some unexpected
 behavior, and found more unexpected behavior (not what I was looking for).

 I'm trying to use a simple NSAssert macro, like so:

 NSAssert(NO, [NSString stringWithFormat:@Caught unexpected exception: %@,
 e]);

 However, when I try to compile, I get the error that macro NSAssert passed
 3 arguments, but takes just 2.

Ugg. Sounds like a bug. What happens when you do this:

NSAssert(NO, ([NSString stringWithFormat:@Caught unexpected
exception: %@, e]));
___

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: gcc parsing error?

2009-06-01 Thread Dave DeLong

Oh good call; I didn't think of that.  That WILL compile correctly.

Dave

On Jun 1, 2009, at 3:42 PM, Stephen J. Butler wrote:


Ugg. Sounds like a bug. What happens when you do this:

NSAssert(NO, ([NSString stringWithFormat:@Caught unexpected
exception: %@, e]));

___

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: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Greg Guerin

Dominik Pich wrote:


I get that messages asking me to PROVIDE a substitution for an entity
But I never get the messages FOR the declaration of the entities,  
so I dont know WHAT to return as data.



When something like this happens, i.e. I've set my delegate, but  
it's not getting called, it may mean that you've misspelled or  
otherwise botched the method definition in your delegate's source.


There clearly ARE delegate methods that are invoked when DTD parsing  
occurs.  You should double-check your spelling, the parameter types,  
etc.


If nothing looks wrong, then post your delegate's code.  We need to  
see the actual code of the actual delegate that should be receiving  
these DTD messages.


We may also need to see the XML from the DTD that is defining the  
entity.  If it's too big to post, break it down to a small fail-case  
that reliably exhibits the problem.




nameOfPerson; goes to nameOfCiname; :)


Is Ciname supposed to be Cinema?

  -- GG

___

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: gcc parsing error?

2009-06-01 Thread Ken Thomases

On Jun 1, 2009, at 4:33 PM, Dave DeLong wrote:

I'm writing a simple test project to try and isolate some unexpected  
behavior, and found more unexpected behavior (not what I was looking  
for).


I'm trying to use a simple NSAssert macro, like so:

NSAssert(NO, [NSString stringWithFormat:@Caught unexpected  
exception: %@, e]);


However, when I try to compile, I get the error that macro NSAssert  
passed 3 arguments, but takes just 2.  To verify what I'm seeing, I  
tried changing it to:


NSAssert(NO, [NSString stringWithFormat:@Caught unexpected  
exception: %@, %@, e, e]);


This tells me I'm passing 4 arguments to NSAssert (instead of the  
required 2).  If I change it to:


NSString *err = [NSString stringWithFormat:@Caught unexpected  
exception: %@, e];

NSAssert(NO, err);

That will compile appropriately.  It would therefore appear that the  
statement is not getting correctly parsed.


So my question is:  Is this expected/documented behavior?  (My  
searches haven't found anything)  If it isn't, is this a known  
issue?  If not, where would be the best place to file a bug?


The problem seems to be that NSAssert is a macro, which is handled by  
the preprocessor rather than the compiler.  While the compiler has  
been extended to understand Objective-C, the preprocessor may not have  
been.  It might not be legal to extend it that way, since the  
preprocessor is used (abused?) in other contexts, for text processing.


It should be possible to work around the problem by surrounding the  
second argument in an extra pair of parentheses.


Regards,
Ken

___

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: gcc parsing error?

2009-06-01 Thread Nick Zitzmann


On Jun 1, 2009, at 3:33 PM, Dave DeLong wrote:


Is this expected/documented behavior?



Yes, because the preprocessor relies on the commas and isn't aware of  
the underlying language. Use NSAssert1/NSAssert2, etc. or wrap the  
call in parentheses as already suggested.


Nick Zitzmann
http://www.chronosnet.com/

___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-06-01 Thread Gwynne Raskind

On Jun 1, 2009, at 4:31 PM, Sean McBride wrote:

This is a nice trick, I wasn't aware of that function, thanks.
Perhaps a minor improvement (one call instead of two):

- (BOOL) isTrashedFileAtPath:(NSString*)path
{
Boolean inTrash = false;
const UInt8* utfPath = (UInt8*)[path UTF8String];
OSStatus err = DetermineIfPathIsEnclosedByFolder(kOnAppropriateDisk,
kTrashFolderType, utfPath, false, inTrash);
return (noErr == err) ? (true == inTrash) : NO;
}

Probably it does the same thing behind the scenes, but why not.

For the archives: 2 more problems:

a) use fileSystemRepresentation not UTF8String.

b) with GC, 'path' may be collected before
DetermineIfPathIsEnclosedByFolder() is finished with utfPath.  So best
to add a [path self] just before the 'return'.



This is a perfect example of why I would never use GC: That is the  
most nonintuitive confusing behavior I have ever heard of. If I  
crashed in the middle of DetermineIfPathIsEnclosedByFolder() for that  
reason I would never guess that GC was responsible!


-- Gwynne

___

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: SQL store, GC apps, statement is still active exception, setReturnsObjectsAsFaults:NO

2009-06-01 Thread Ben Trumbull
Now that 10.5.7 (allegedly) fixes the incompatibilities between the  
SQL

store and GC apps, I have been trying to switch from XML to SQL.  Most
problems I've fixed, but I'm getting an exception:


Yes, 10.5.7 fixes all the known issues with (GC, NSDocument,  
NSSQLiteStore).  The incompatibilities were in document based apps.   
Non-document GC apps worked with the NSSQLiteStore prior to 10.5.7



statement is still active

See backtrace below.  I've search the archives of course, and see that
this is usually a threading problem.  My app is multithreaded, but I  
do

all my UI, bindings, and Core Data stuff on the main thread (barring
mistakes).

Experimentation has revealed that if I change this:

[request setReturnsObjectsAsFaults:NO];

from NO to YES the problem goes away.

What might I be doing wrong here?  Or is this a Core Data bug?


This is a known issue that is not related to GC.  On all versions of  
10.5, Core Data is less than completely thrilled by fetching  
recursively in -awakeFromFetch. This has subsequently been fixed.


- Ben


#0  0x9539ae17 in objc_exception_throw ()
#1  0x92b1f178 in -[NSSQLConnection prepareSQLStatement:] ()
#2  0x92b1ea33 in -[NSSQLiteConnection prepareSQLStatement:] ()
#3  0x92b4fdab in -[NSSQLChannel selectRowsWithCachedStatement:] ()
#4  0x92b1b17b in newFetchedRowsForFetchPlan_MT ()
#5  0x92b4f410 in -[NSSQLCore  
newFetchedPKsForSourceID:andRelationship:] ()

#6  0x92b4eeff in -[NSSQLCore retaine
dRelationshipDataWithSourceID:forRelationship:withContext:] ()
#7  0x92b4ec47 in -[NSFaultHandler re
tainedFulfillAggregateFaultForObject:andRelationship:withContext:] ()
#8  0x92b25597 in -[_NSFaultingMutableSet willRead] ()
#9  0x92b28459 in -[_NSFaultingMutableSet
countByEnumeratingWithState:objects:count:] ()
#11 0x003cc449 in -[MyManagedObjectSuperClass awakeFromFetch]
#12 0x003cdf70 in -[MyManagedObject awakeFromFetch]
#13 0x92b0b987 in _PFFaultHandlerFulfillFault ()
#14 0x92b38162 in -[NSSQLCore  
_prepareResultsFromResultSet:usingFetchPlan:] ()

#15 0x92b242ab in -[NSSQLCore _newRow
sForFetchPlan:selectedBy:withArgument:] ()
#16 0x92b141b0 in -[NSSQLCore newRowsForFetchPlan:] ()
#17 0x92b13d10 in -[NSSQLCore objectsForFetchRequest:inContext:] ()
#18 0x92b13a17 in -[NSSQLCore executeRequest:withContext:] ()
#19 0x92b12aaa in -[NSPersistentStoreCoordinator(_NSInternalMethods)
executeRequest:withContext:] ()
#20 0x92b1007b in -[NSManagedObjectContext  
executeFetchRequest:error:] ()


___

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: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Keary Suska


On Jun 1, 2009, at 1:43 PM, Dominik Pich wrote:


:) thanks but . it doesnt work for me.
I read all that about NSParser just calling you back. I implemented  
all the delegates BUT
I dont seem to be getting an appropriate callback for the Entities  
in the DTD, although I did set 'shouldResolveExternalEntities = YES'


I get that messages asking me to PROVIDE a substitution for an entity
But I never get the messages FOR the declaration of the entities, so  
I dont know WHAT to return as data.


I hope I explained my issue?

For example:
In the xml I have
nameOfPerson; goes to nameOfCiname; :)

I never get to know about the declares (which are in the DTD. which  
should be loaded. no?)


No. That's the point. NSXMLParser does nothing outside of parsing the  
particular XML. It does not load DTDs, it does not validate, it does  
not resolve any links. It is the responsibility of the delegate to  
handle such things as DTD-related functions. You can use the NSXMLDTD  
class for this.


All external entities must be declared in the core XML. If they  
aren't, your XML is not well-formed.  When the parser finds and  
external entity declaration, the delegate is sent - 
parser:foundExternalEntityDeclarationWithName:publicID:systemID: .  
This just gives you a heads-up that the XML document expects to need  
to resolve that entity. When it finds the entity, you should be sent - 
parser:resolveExternalEntityName:systemID: (if you set the option),  
where you return the declaration as it appears in the DTD (as NSData).


I believe that NSXMLDocument may provide the functionality that you  
want, so you might want to look down that route.


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: How determine if file is in Trash, given Path or Alias

2009-06-01 Thread Martin Wierschin

const UInt8* utfPath = (UInt8*)[path UTF8String];
OSStatus err = DetermineIfPathIsEnclosedByFolder 
(kOnAppropriateDisk, kTrashFolderType, utfPath, false, inTrash);


For the archives: 2 more problems:

a) use fileSystemRepresentation not UTF8String.


I initially considered that, but the documentation for  
DetermineIfPathIsEnclosedByFolder specifically says it requires UTF-8  
encoded characters, while fileSystemRepresentation mentions no  
guarantee as to the encoding. I'm sure that that the file system  
representation is currently UTF-8, and will stay that way, but I  
don't want to make that assumption.


I don't often work with the C-based APIs, so maybe I'm way off base  
here. Should I file a documentation bug? And if so, which piece of  
documentation needs adjusting?


~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: SQL store, GC apps, statement is still active exception, setReturnsObjectsAsFaults:NO

2009-06-01 Thread Sean McBride
On 6/1/09 3:01 PM, Ben Trumbull said:

 Now that 10.5.7 (allegedly) fixes the incompatibilities between the
 SQL
 store and GC apps, I have been trying to switch from XML to SQL.  Most
 problems I've fixed, but I'm getting an exception:

Yes, 10.5.7 fixes all the known issues with (GC, NSDocument,
NSSQLiteStore).  The incompatibilities were in document based apps.
Non-document GC apps worked with the NSSQLiteStore prior to 10.5.7

Glad to hear it!

 statement is still active

 See backtrace below.  I've search the archives of course, and see that
 this is usually a threading problem.  My app is multithreaded, but I
 do
 all my UI, bindings, and Core Data stuff on the main thread (barring
 mistakes).

 Experimentation has revealed that if I change this:

  [request setReturnsObjectsAsFaults:NO];

 from NO to YES the problem goes away.

 What might I be doing wrong here?  Or is this a Core Data bug?

This is a known issue that is not related to GC.

But is related to SQL I'm assuming?  I don't see this problem with XML.
Maybe I'm just lucky?

On all versions of
10.5, Core Data is less than completely thrilled by fetching
recursively in -awakeFromFetch. This has subsequently been fixed.

OK, so I guess I'll just use setReturnsObjectsAsFaults:YES and move on.

Thanks!

--

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


___

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

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

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

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


Re: How determine if file is in Trash, given Path or Alias

2009-06-01 Thread Sean McBride
On 6/1/09 3:03 PM, Martin Wierschin said:

 const UInt8* utfPath = (UInt8*)[path UTF8String];
 OSStatus err = DetermineIfPathIsEnclosedByFolder
 (kOnAppropriateDisk, kTrashFolderType, utfPath, false, inTrash);

 For the archives: 2 more problems:

 a) use fileSystemRepresentation not UTF8String.

I initially considered that, but the documentation for
DetermineIfPathIsEnclosedByFolder specifically says it requires UTF-8
encoded characters, while fileSystemRepresentation mentions no
guarantee as to the encoding.

Nice catch.

I'm sure that that the file system
representation is currently UTF-8, and will stay that way, but I
don't want to make that assumption.

I don't often work with the C-based APIs, so maybe I'm way off base
here. Should I file a documentation bug? And if so, which piece of
documentation needs adjusting?

I'd say it's DetermineIfPathIsEnclosedByFolder's docs that could use
clarifying.  But at least they say _something_ about encoding, unlike
the man pages for open() and friends. :)

But it's not a huge issue: fileSystemRepresentation and UTF8String give
the same thing 99% of the time.

--

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


___

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

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

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

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


Re: NSXMLParser - howto resolve entities defined in DTD

2009-06-01 Thread Keary Suska

On Jun 1, 2009, at 4:03 PM, Keary Suska wrote:

All external entities must be declared in the core XML. If they  
aren't, your XML is not well-formed.


Correction, this would not be the case for declarations in a DTD,  
which are part of the external subset, so the first delegate message  
should not be sent. But the problem still stands that the parser won't  
load/parse the DTD, and the delegate will have to handle it.


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


NSToolbar: notification of change?

2009-06-01 Thread David Reitter
Having subclassed NSToolbar, I am now trying to get a notification of  
changes done by the user using the customization palette.
This works fine for the removal of items (toolbarDidRemoveItem:), but  
I can't see a way to get notified of added/moved items after the fact.
The only notification I can get is toolbarWillAddItem:, but that's  
obviously before the addition, which is not very helpful.


I have tried implementing insertItemWithItemIdentifier: and also  
setConfigurationFromDictionary:, but it seems that the palette doesn't  
go through these.


Short of regularly monitoring the tool bar for possible changes, I  
don't know what to do...


Thanks for your suggestions!

PS.: please cc me on replies.



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

Garbage Collection Crash using NSImage

2009-06-01 Thread Kristof Van Landschoot
 This piece of code was split off from a project I am working on. It
consistently reproduces a garbage collection error on my Mac OS 10.5.7 and
sometimes crashes. I have been looking at it for too long so my question is:
does anybody else see why this would give errors when garbage collection is
on?

- (void) doCrash: (id) sender
{
NSArray *lURLArray = [ NSArray arrayWithObjects:


@http://userserve-ak.last.fm/serve/300x300/23621007.jpg;,


@http://userserve-ak.last.fm/serve/300x300/26675609.png;,


@http://userserve-ak.last.fm/serve/300x300/26675609.png;,

  nil ];
NSString *lImageURL = nil;

for (lImageURL in lURLArray)

{
NSImage *lImage = [[NSImage alloc] initWithContentsOfURL:
[NSURL URLWithString: lImageURL]];

NSSize targetSize = NSMakeSize(80,80);

NSImage *newImage = [[NSImage alloc] initWithSize:targetSize];

[newImage lockFocus];

NSRect thumbnailRect = NSMakeRect(0,0,80,80);

NSRect sourceRect = NSMakeRect(0,0,[lImage size].width,[lImage
size].height);

[lImage drawInRect: thumbnailRect
  fromRect: sourceRect

 operation: NSCompositeSourceOver
  fraction: 1.0];

[newImage unlockFocus];
}
}

When playing around with the URLs in the lURLArray I get different behavior:
sometimes crashes, sometimes the error message.

The garbage collection error message is triggered when the garbage collector
is freeing one of the images and goes like this:

reference count underflow for address, break on
auto_refcount_underflow_error to debug.

Stack Trace:

#0   auto_refcount_underflow_error ()
#1   Auto::Zone::dec_refcount_small_medium ()
#2   Auto::Zone::block_decrement_refcount ()
#3   CFRelease ()
#4   -[NSBitmapImageRep _freeData] ()
#5   -[NSBitmapImageRep _freeImage] ()
#6   -[NSBitmapImageRep finalize] ()
#7   finalizeOneObject ()
#8   foreach_block_do ()
#9   batchFinalize ()
#10  batchFinalizeOnMainThread ()
#11  objc_collect_if_needed ()
#12  NSPopAutoreleasePool ()

Any help is much appreciated, thanks, Kristof

[ see also
http://stackoverflow.com/questions/937105/garbage-collection-crash-using-nsimagefor
the same question ]

Best Regards,

Kristof
___

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: NSToolbar: notification of change?

2009-06-01 Thread Keary Suska

On Jun 1, 2009, at 4:53 PM, David Reitter wrote:

Having subclassed NSToolbar, I am now trying to get a notification  
of changes done by the user using the customization palette.
This works fine for the removal of items (toolbarDidRemoveItem:),  
but I can't see a way to get notified of added/moved items after the  
fact.
The only notification I can get is toolbarWillAddItem:, but that's  
obviously before the addition, which is not very helpful.


I have tried implementing insertItemWithItemIdentifier: and also  
setConfigurationFromDictionary:, but it seems that the palette  
doesn't go through these.


Short of regularly monitoring the tool bar for possible changes, I  
don't know what to do...


There is no built-in way to do what you want that I know of. There may  
be third-party subclasses or substitutes, but none that I recall.


You can know when the customization palette is invoked, so all you  
need to check for is when it is closed and then check for changes. You  
could take a snapshot at -runCustomizationPalette:, then set a timer  
that checks -customizationPaletteIsRunning until it returns NO, at  
which time you check for changes. You are still polling, but at least  
it is relatively lightweight.


HTH,

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


Referring to file by Alias ^or^ path

2009-06-01 Thread Jerry Krinock

My app needs a reference to files that may or may not exist (yet).

When the file exists, I prefer to use the Alias because it tracks if  
the user moves it, etc.  But if the file does not exist yet, my + 
[NSData aliasRecordFromPath:] method (shown below) returns nil.


It is implied but not explicitly stated in the Alias Manager Reference  
that you cannot have an Alias to a nonexistent file.  My main  
question: Is this true?


If so, then I need a little MyFileReference class that encapsulates an  
Alias ^or^ a path.  But before I write such a thing, I'm further  
asking, is such a class is already available somewhere?  It seems like  
something that many developers would need.


On the other hand, if an Alias can refer to a nonexistent file, then  
presumably my +[NSData aliasRecordFromPath:] can be improved to  
produce such an alias, and vice versa for my +[NSData  
pathFromAliasRecord:] method.  I'll need something better than  
FSNewAliasFromPath() which returns -43.


Thanks,

Jerry Krinock


The following is a category on NSData which has two methods, one for  
converting a path to an alias, and its vice versa.  I've cobbled it  
together from various sources over time.


#import NSData+FileAlias.h

@implementation NSData (FileAlias)

+ (NSData*)aliasRecordFromPath:(NSString*)path {
if ([path length] == 0) {
return nil ;
}

const char* pathC = [path UTF8String] ;

OSErr osErr ;
AliasHandle aliasHandle ;
osErr = FSNewAliasFromPath (
NULL,
pathC,
0,
aliasHandle,
NULL
) ;
NSData* data = nil ;
if (osErr == noErr) {

#if MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_4
Size size = GetAliasSize(aliasHandle) ;
#else
Size size = aliasHeader.aliasSize ;
#endif

AliasPtr aliasPtr = *aliasHandle ;
data = [NSData dataWithBytes:aliasPtr
  length:size] ;
}
else {
NSLog(@FSNewAliasFromPath returned OSErr %d for path %s,  
osErr, pathC) ;

}

return data ;
}

- (NSString*)pathFromAliasRecord {
int err = 0 ;

unsigned short nBytesAliasRecord ;

// Cast to an AliasRecord and resolve the alias.
AliasRecord aliasHeader = *((AliasPtr)[self bytes]) ;
#if MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_4
AliasPtr ap = aliasHeader ;
AliasHandle ah = ap ;
nBytesAliasRecord = GetAliasSize(ah) ;
#else
nBytesAliasRecord = aliasHeader.aliasSize ;
#endif

Handle handle = NULL;
FSRef resolvedFSRef;
if (err = 0)
{
// Move the now-decoded data into the Handle.
if (PtrToHand([self bytes], handle, nBytesAliasRecord) !=  
noErr)

{
NSLog(@Internal Error 589-5451.  Can't allocate handle  
for alias) ;

err = 1 ;
}

Boolean changed;
OSErr osErr = FSResolveAlias(NULL, (AliasHandle)handle,  
resolvedFSRef, changed);


if (osErr != noErr)
{
// File could not be found.  The invoker is responsible to
// raise an error or exception if desired when nil is  
returned.

err = 1 ;
}
}

if (handle)
DisposeHandle(handle);

char fullPath[4096];
if (err = 0)
{
OSStatus osStatus = FSRefMakePath (resolvedFSRef,  
(UInt8*)fullPath, sizeof(fullPath)) ;


if (osStatus != noErr)
{
NSLog(@Internal Error 959-2697.  OSStatus %i from  
FSResolveAlias, osStatus) ;

err = 1 ;
}

}

NSString* fullPathNSString = nil ;

if (err = 0)
fullPathNSString = [NSString stringWithCString:fullPath] ;

// The full path returned by FSRefMakePath will NOT have a  
trailing slash UNLESS
// the path is the root, i.e. @/.  In that case it will.  Thus,  
in order to return
// a standard result to which /Filename.ext should be appended,  
we remove that:

if ([fullPathNSString length] == 1)
fullPathNSString = @ ;

return [[fullPathNSString retain] autorelease] ;
}

@end
___

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


CF/NSNotifications on the same thread not working.

2009-06-01 Thread Robert Monaghan

Hi Everyone,

I am trying to post a notification (a  
CFNotificationCenterPostNotification) on a thread from a  
CFNotificationCenterGetLocalCenter, to a NSNotificationCenter  
defaultCenter. All on the same thread, spun off from my main thread.  
The observer that I am adding, never gets called. If I move all of  
this to my main thread, everything works as expected.


I am stumped. Is there something special that I have to do, to get a  
notification to work entirely on the same thread?


bob.

___

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: Referring to file by Alias ^or^ path

2009-06-01 Thread James Walker

Jerry Krinock wrote:

My app needs a reference to files that may or may not exist (yet).

When the file exists, I prefer to use the Alias because it tracks if the 
user moves it, etc.  But if the file does not exist yet, my +[NSData 
aliasRecordFromPath:] method (shown below) returns nil.


It is implied but not explicitly stated in the Alias Manager Reference 
that you cannot have an Alias to a nonexistent file.  My main question: 
Is this true?


No. There's the function NewAliasMinimalFromFullPath, whose 
documentation says it can be used to create an alias for a file that 
doesn't exist.  However, this function is deprecated, with no 
replacement, and I think it might expect an HFS-style path.


If you know that the parent directory of the file exists, then you can 
use FSNewAliasMinimalUnicode, and its documentation does say it will 
work in this case.

--
  James W. Walker, Innoventive Software LLC
  http://www.frameforge3d.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


Thin navigation tool bars in landscape

2009-06-01 Thread Mike Manzano
How do you get the thin-style bars in landscape like Mail has? Mine  
doesn't do that automatically. I haven't been able to find an API or  
developer doc that mentions it.



Mike Manzano
Sent while mobile
___

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


End Of Method Releasing Order?

2009-06-01 Thread Chunk 1978
does it matter which order objects are released at the end of a
method?  example:

-=-=-=-=-

- (void)applicationWillTerminate:(NSNotification *)notification
{
FourLines *fourLines = [[FourLines alloc] init];
fourLines.field1 = field1.text;
fourLines.field2 = field2.text;
fourLines.field3 = field3.text;
fourLines.field4 = field4.text;

NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
[archiver encodeObject:fourLines forKey:kDataKey];
[archiver finishEncoding];
[data writeToFile:[self dataFilePath] atomically:YES];

[archiver release];
[data release];
[fourLines release];
}

-=-=-=-=-

at the end i'm finished with archiver, data and fourLines, but does it
matter in this case which one i release first?
___

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: Several Questions

2009-06-01 Thread Todd Heberlein


Great, so I understand from what you're saying that I can launch a  
GUI app

using launchd?


Out of curiosity, I just tried this. I created a basic Cocoa app (I  
made no changes to it, I just built the default skeleton application  
that Xcode creates for you). The project is in the directory:

/Users/heberlei/Development/Tests/BasicApp/
and the full path to the program is
	/Users/heberlei/Development/Tests/BasicApp/build/Debug/Basic.app/ 
Contents/MacOS/BasicApp


I then created a launchd XML file called app_shouldnt_die.plist and  
put it in the directory


/Library/LaunchAgents

(I also set it to be owned by root:wheel, don't know if that matters).

Now when I log in, that BasicApp starts up. If I quit the app, it  
starts again (usually within ~5 seconds). If I do the kill pid  
command from the command line, the application starts again.


Also, when I login as a completely different user, the application  
still starts up automatically. So no matter who logs in, they have to  
live with this darn app alway on.  Pretty cool (or maybe just  
irritating :).


The content of app_shouldnt_die.plist that directs launchd to always  
keep the program running is:


?xml version=1.0 encoding=UTF-8?
!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd 


plist version=1.0
dict
keyLabel/key
stringcom.netsq.app_shouldnt_die/string
keyProgram/key
	string/Users/heberlei/Development/Tests/BasicApp/build/Debug/ 
BasicApp.app/Contents/MacOS/BasicApp/string

keyKeepAlive/key
true/
/dict
/plist


Todd


___

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

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

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

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


Re: End Of Method Releasing Order?

2009-06-01 Thread WT
I don't think so. Releasing objects merely decreases their retain  
count. It's up to the Obj-C runtime system to figure out in what order  
to actually free the memory allocated for those objects. In other  
words, we are not the ones deciding how and when to deallocate memory  
allocated for objects. We merely indicate to the runtime system that  
we're no longer interested in a given object at a given point in the  
program runtime execution flow. What happens to the object after that  
is not up to us.


On Jun 2, 2009, at 2:46 AM, Chunk 1978 wrote:


does it matter which order objects are released at the end of a
method?  example:
...
at the end i'm finished with archiver, data and fourLines, but does it
matter in this case which one i release first?

___

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: End Of Method Releasing Order?

2009-06-01 Thread Wade Tregaskis

does it matter which order objects are released at the end of a
method?  example:

-=-=-=-=-

- (void)applicationWillTerminate:(NSNotification *)notification
{
FourLines *fourLines = [[FourLines alloc] init];
fourLines.field1 = field1.text;
fourLines.field2 = field2.text;
fourLines.field3 = field3.text;
fourLines.field4 = field4.text;

NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
[archiver encodeObject:fourLines forKey:kDataKey];
[archiver finishEncoding];
[data writeToFile:[self dataFilePath] atomically:YES];

[archiver release];
[data release];
[fourLines release];
}


In the case above, and in general, no - most retains you'll have on  
other objects are for your own use, and if they keep a reference to  
anything themselves, they are responsible for retaining it on their  
own behalf.  If, however, you have a retain on something on behalf of  
something else - e.g. you hand a struct to some function, which  
contains a pointer to an object that you have to retain on its behalf  
- then the order can matter, though for better or worse such scenarios  
often allow you to get away with it, whether coincidentally or luckily.


Wade
___

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: NSToolbar: notification of change?

2009-06-01 Thread Peter Ammon


On Jun 1, 2009, at 3:53 PM, David Reitter wrote:

Having subclassed NSToolbar, I am now trying to get a notification  
of changes done by the user using the customization palette.
This works fine for the removal of items (toolbarDidRemoveItem:),  
but I can't see a way to get notified of added/moved items after the  
fact.
The only notification I can get is toolbarWillAddItem:, but that's  
obviously before the addition, which is not very helpful.


I have tried implementing insertItemWithItemIdentifier: and also  
setConfigurationFromDictionary:, but it seems that the palette  
doesn't go through these.


Short of regularly monitoring the tool bar for possible changes, I  
don't know what to do...


Thanks for your suggestions!

PS.: please cc me on replies.


In addition to what Keary said, you can also set a timer to fire after  
toolbarWillAddItem:.  Not ideal, but better than nothing.

___

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: NSFileManager's copyItemAtPath:toPath:error: syslogging every directory it finds?

2009-06-01 Thread Chris Parker


On 1 Jun 2009, at 1:54 PM, Jim Turner wrote:


Hopefully this has a simple answer but it seems now that when I call
copyItemAtPath:toPath:error: to copy a folder to another location, I
get this in the console:

6/1/09 3:48:28 PM
/Users/jimt/Source/MyApp/trunk/build/Debug/MyApp.app/Contents/MacOS/ 
MyApp[29625]

reading from /Users/jimt/Library/MyApp/MyFolder: Is a directory

I had to break on syslog() to see who was even causing this to happen.
I'm not sure what's changed or if I've set some magic flag someplace
that's finding its way into the internals of
copyItemAtPath:toPath:error: but does anyone know why I'd be getting
that logged? Very confusing.


This is a known bug and has been fixed in a future release of the  
operating system.


.chris

--
Chris Parker
Apple Inc.

___

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: End Of Method Releasing Order?

2009-06-01 Thread Shawn Erickson
On Mon, Jun 1, 2009 at 6:05 PM, WT jrca...@gmail.com wrote:
 I don't think so. Releasing objects merely decreases their retain count.
 It's up to the Obj-C runtime system to figure out in what order to actually
 free the memory allocated for those objects. In other words, we are not the
 ones deciding how and when to deallocate memory allocated for objects. We
 merely indicate to the runtime system that we're no longer interested in a
 given object at a given point in the program runtime execution flow. What
 happens to the object after that is not up to us.

To be clear in a non-GC environment...

The -release message that causes the retain count to hit zero sends a
-dealloc message to self. In -dealloc memory is freed using runtime
methods. Not really the runtime deciding anything, it is the
implementation of NSObject that does this. Note some classes modify
-release (and/or -dealloc) to prevent deallocation in some situations
but it is the implementation of the class that is doing that.

The order of releases can matter assuming the classes involved have
some interdependencies not already managed by retains. Usually such
interdependencies will be managed by retains (normal memory contract
helps ensure this) so strict ordering of releases, etc. is not needed.

-Shawn
___

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: Dynamically getting the type of ivars

2009-06-01 Thread Dave DeLong
I just remembered that I never made good on my promise to post why I  
needed this.


In a nutshell, I wrote some code that lets me add basic NSCoding  
compliance to any class at runtime.  The only requirement is that the  
target class has to be KVC-compliant (since I pull values in and out  
using valueForKey: and setValue:forKey:)


I wrote a bit about the process here:  
http://davedelong.com/blog/2009/04/13/aspect-oriented-programming-objective-c

Dave

On Apr 13, 2009, at 3:57 PM, Dave DeLong wrote:

I understand the distinction, and your clarification has prompted me  
to think of another way I could do this.  Currently, the code where  
I'm getting the list of Ivars is in a class method.  However, I also  
have an instance method where I'm doing something very similar.  I  
could move the type getting into that method, since in there I'm  
calling [self valueForKey:]...


If this seems mysterious to you, I'll post again when I've got it  
working right and explain what I'm up to.


Thanks again,

Dave

___

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: NSToolbar: notification of change?

2009-06-01 Thread Graham Cox


On 02/06/2009, at 8:53 AM, David Reitter wrote:

Having subclassed NSToolbar, I am now trying to get a notification  
of changes done by the user using the customization palette.
This works fine for the removal of items (toolbarDidRemoveItem:),  
but I can't see a way to get notified of added/moved items after the  
fact.
The only notification I can get is toolbarWillAddItem:, but that's  
obviously before the addition, which is not very helpful.


I have tried implementing insertItemWithItemIdentifier: and also  
setConfigurationFromDictionary:, but it seems that the palette  
doesn't go through these.


Short of regularly monitoring the tool bar for possible changes, I  
don't know what to do...


Thanks for your suggestions!



It might be useful if you could explain why you need to do this. The  
design of toolbars is intended to avoid you needing this, since the  
content and layout of toolbars is something that the user is in charge  
of. Normally, where an item is sitting in the toolbar is of little  
interest to the app.


--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: 64-bit, 10.5/10.4, SDK build settings

2009-06-01 Thread Greg Guerin

Alex Sheh wrote:


My requirements are the following:
- On a machine running 10.5 or later, I need to run 64-bit code.



and:

... I need to run a 64-bit binary (the one that was built against  
10.5 SDK) when the user is running Leopard 10.5, ...


This doesn't make sense to me.  If the user is running 10.5 Leopard  
on a machine that doesn't have a 64-bit CPU, what do you intend to  
happen?  As stated, such a user would be unable to run your app.  Is  
that what you want?


If you want users who run 10.5 and also have a 64-bit CPU to run the  
64-bit code, then you still need 32-bit code that runs on all arch's  
and on 10.4 or 10.5.


As to preferring 64-bit over 32-bit on 64-bit-capable arch's, there's  
an Info.plist key for that: LSArchitecturePriority.



I think you're simply approaching this wrong.

The default SDK for all builds and arch's should be 10.4.  This will  
cover all arch's for which no arch-specific setting is defined.  It  
will be 32-bit in all cases.


The base SDK for 64-bit arch's should be 10.5.

If you approach it this way, then how to setup the per-arch settings  
should be clearer.


SDKROOT = MacOSX10.4u.sdk
SDKROOT_ppc64 = MacOSX10.5.sdk
SDKROOT_x86_64 = MacOSX10.5.sdk 5

Given the above, when it builds for ppc or i386, it will build for  
10.4, because that's the default base SDK, and the target arch  
doesn't match any arch-specific setting.



However, if I similarly set conditional build settings for Base  
SDK and MacOSX Deployment Target so that PowerPC 64-bit and  
Intel 64-bit are built against 10.5 SDK and deploy on 10.5 or  
later, then I lose 10.4 support for PowerPC 64-bit and Intel 64-bit  
architectures.


That's nonsensical.  There is no 10.4 support for PowerPC 64-bit and  
Intel 64-bit to be lost, because no such thing exists.  Unless  
you're referring only to the 64-bit System framework.


  -- GG

___

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: Setting wantsLayer = YES; crashes on view load.

2009-06-01 Thread Kevin Ross
I looked at the msgSends dump of everything after setWantsLayer, and  
at the end it looks like a NSAutoreleasePool is being created right  
before a CAContext is initialized.  It then throws an exception right  
after NSCFString NSCFString copyWithZone:.



+ NSAutoreleasePool NSObject alloc
+ NSAutoreleasePool NSAutoreleasePool allocWithZone:
+ NSAutoreleasePool NSObject self
- NSAutoreleasePool NSAutoreleasePool init
- NSAutoreleasePool NSAutoreleasePool initWithCapacity:
- NSAutoreleasePool NSObject class
+ NSAutoreleasePool NSObject self
+ CAContext NSObject initialize
+ CAContext CAContext localContext
+ CAContext CAContext localContextWithOptions:
+ CAContextImpl CAContextImpl initialize
+ CAContextImpl NSObject alloc
+ CAContextImpl NSObject allocWithZone:
- CAContextImpl CAContextImpl initWithOptions:
- CAContext NSObject init
+ NSConcreteNotification NSConcreteNotification  
newTempNotificationWithName:object:userInfo:

- NSCFString NSCFString copyWithZone:


Is there a way using instruments or dtrace to find out what objects  
are being passed to newTempNotificationWithName:object:userInfo?



Thank you for your time,

Kevin



On Jun 1, 2009, at 1:27 PM, Kevin Ross wrote:


Thanks Michael,

I do have a few notifications registered throughout the app, but  
nothing that is connected with any of the CALayers or views.  This  
seems to happen no matter which view or nib I use.  I'm trying to  
see if I can isolate the notification that is causing  the crash.




On Jun 1, 2009, at 12:07 AM, Michael Vannorsdel wrote:

Are you registering for any notifications?  It looks like it's  
crashing while trying to notify an object.



On Jun 1, 2009, at 12:31 AM, Kevin Ross wrote:

Hi everyone, I have a Core Data document based app that I've been  
working on for a while and I now want to change some of the view  
drawing to use CALayers.  The trouble I'm having is that when I  
set a view's wantsLayer = YES, I end up getting EXC_BAD_ACCESS. 
This happens when I try to set it on any arbitrary view in any of  
the nibs in my project, when setting it from code, or from  
clicking the checkbox in IB.  I've tried new CALayer projects from  
scratch and they work fine, is there something I could have done  
to my project that would prevent me from setting a view's  
wantsLayer property to YES?


Thank you for taking time to read this.


___

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/apple-lists%40twentyfourmountains.com

This email sent to apple-li...@twentyfourmountains.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/apple-lists%40twentyfourmountains.com

This email sent to apple-li...@twentyfourmountains.com



___

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

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

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

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


Re: 64-bit, 10.5/10.4, SDK build settings

2009-06-01 Thread Greg Guerin

Sorry, wrong list.  Please ignore prior post.

  -- GG
___

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: NSToolbar: notification of change?

2009-06-01 Thread David Reitter

On Jun 1, 2009, at 7:40 PM, Keary Suska wrote:

You can know when the customization palette is invoked, so all you  
need to check for is when it is closed and then check for changes.  
You could take a snapshot at -runCustomizationPalette:, then set a  
timer that checks -customizationPaletteIsRunning until it returns  
NO, at which time you check for changes. You are still polling, but  
at least it is relatively lightweight.


Yes, that what I am doing now.

I tried overriding _endCustomizationPalette:(id), but that method  
doesn't seem to be called at all, or I didn't manage to override it...


- (void)checkCustomizationChange:(NSTimer*)theTimer
{
  if (! [self customizationPaletteIsRunning])
{ [theTimer invalidate];
  [self customizationDidChange];
}
}
- (void)runCustomizationPalette:(id)sender
{
  [super runCustomizationPalette:sender];
  [NSTimer scheduledTimerWithTimeInterval: (float)0.1 target: self
 selector: @selector (checkCustomizationChange:)
 userInfo: nil repeats: YES];
}


On Jun 1, 2009, at 9:20 PM, Peter Ammon wrote:

In addition to what Keary said, you can also set a timer to fire  
after toolbarWillAddItem:.  Not ideal, but better than nothing.


I tried that first, since it would have been more light-weight, but  
this message is not sent if toolbar items are just moved around.



On Jun 1, 2009, at 10:12 PM, Graham Cox wrote:

It might be useful if you could explain why you need to do this. The  
design of toolbars is intended to avoid you needing this, since the  
content and layout of toolbars is something that the user is in  
charge of. Normally, where an item is sitting in the toolbar is of  
little interest to the app.


Normally it shouldn't be, but Emacs (Aquamacs: http://aquamacs.org )  
has to mediate between Emacs Lisp code and Cocoa.  The user's changes  
need to be percolated to the Lisp side, especially since we're  
updating the toolbar regularly from the internal (Lisp-level)  
representation.  [Also we don't use the NS defaults system due to  
cross-platform maintenance requirements, so we need to implement  
persistency, even though this doesn't have to be synchronously of  
course.]  I hope that makes it clear.


Thanks everyone for your replies.

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Adding an application to the login items

2009-06-01 Thread Misha Gonodanov
You are not creating URL correctly - basically  
CFURLRef.alloc().initWithString_() will create it by calling  
CFURLCreateWithString() while it should be created by  
CFURLCreateWithFileSystemPath(). I do not know the name of  
corresponding python method.


Misha

On Dec 3, 2008, at 4:36 PM, Bill Janssen wrote:


I'm writing an installer that adds an application to the login items,
but my script (see below) keeps failing, with a bus error, like this:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x
Crashed Thread:  0

Thread 0 Crashed:
0   com.apple.CoreFoundation0x96318aa7 CFStringGetLength + 39
1   com.apple.CoreFoundation0x963254b2 CFStringCompare + 18
2   com.apple.LaunchServices  	0x904e4b61  
LSSharedFileListInsertItemURL + 73

3   _objc.so0x00231855 ffi_call_SYSV + 53
4   _objc.so0x00231d6c ffi_call + 147
5   _objc.so  	0x0023f528  
PyObjCFormalProtocol_ForProtocol + 1551

6   org.python.python   0x0011fd3d PyObject_Call + 50
7   org.python.python 	0x0018db1a PyEval_EvalFrameEx +  
17904

8   org.python.python   0x0018f45b PyEval_EvalCodeEx + 1638
9   org.python.python   0x0018f548 PyEval_EvalCode + 87
10  org.python.python   0x001a69ec PyErr_Display + 1896
11  org.python.python   0x001a7016 PyRun_FileExFlags + 135
12  org.python.python 	0x001a8982  
PyRun_SimpleFileExFlags + 421

13  org.python.python   0x001b3c03 Py_Main + 3095
14  org.python.pythonapp0x1fca 0x1000 + 4042

Thread 0 crashed with X86 Thread State (32-bit):
eax: 0xa07444ec  ebx: 0x96318a8a  ecx: 0x  edx: 0x0007
edi: 0x01f10690  esi: 0x  ebp: 0xbfffe8c8  esp: 0xbfffe8b0
 ss: 0x001f  efl: 0x00010283  eip: 0x96318aa7   cs: 0x0017
 ds: 0x001f   es: 0x001f   fs: 0x   gs: 0x0037
cr2: 0x

Here's the script -- any advice would be appreciated!

TIA, Bill
-

#!/usr/bin/python
# -*- mode: Python -*-

import os, sys

from Foundation import *
from AppKit import *
from LaunchServices import *

pool = NSAutoreleasePool.alloc().init()

try:
  if len(sys.argv)  2:
  sys.stderr.write(Usage: %s APPLICATIONPATH\n % sys.argv[0])
  sys.exit(1)
  if not os.path.isdir(sys.argv[1]):
  sys.stderr.write(Specified application %s not an application. 
\n % sys.argv[1])

  sys.exit(1)
  url = CFURLRef.alloc().initWithString_(sys.argv[1])

  props = NSDictionary.dictionaryWithObject_forKey_(True,  
kLSSharedFileListItemHidden)


  login_items = LSSharedFileListCreate(
  kCFAllocatorDefault, kLSSharedFileListSessionLoginItems, None)

  NSLog(login_items are %s, url is %s, props are %s %  
(login_items, url, props))


  v = LSSharedFileListInsertItemURL(login_items,
kLSSharedFileListItemLast,
None,
None,
url,
props,
None)
  NSLog(v is %s % v)

finally:
  del pool
___

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/gonodanov%40apple.com

This email sent to gonoda...@apple.com


___

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

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

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

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


Keeping track of CGAffineTransform's action

2009-06-01 Thread Pierre Berloquin
I keep moving an UIImageView with CGAffineTransformTranslate through a
timer. That doesn't affect the view's frame and bounds.
Is there a variable somewhere that I can read to keep track of the transform
or must I create my own?

Thanks, Pierre
___

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: NSToolbar: notification of change?

2009-06-01 Thread Graham Cox


On 02/06/2009, at 1:06 PM, David Reitter wrote:

updating the toolbar regularly from the internal (Lisp-level)  
representation



OK, but wouldn't -validateUserInterfaceItem: be appropriate for this?

Since you're only interested in the items actually in the bar, then  
you can validate them whenever this is invoked, which will be once per  
event loop, essentially. If the internal state of your app needs to  
adjust the item, it should do so here. Note that this isn't restricted  
to enabling/disabling the item. As each individual toolbar item is  
passed to this, you have the item and can modify it as you want,  
without caring where in the bar it is.


While this isn't invoked while the user has the toolbar customising  
sheet open and is actually adding/removing items, it will be just as  
soon as they close it, so updating the items they added immediately.


--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


NSOutlineView sometimes truncates label

2009-06-01 Thread David
I have an outline view where the first column are file names. There is
absolutely no processing of the name going on in my code. It uses a
data source delegate. The method
outlineView:objectValueForTableColumn:byItem: is returning an NSString
* with the proper value.

Everything has been working fine for a long time. Suddenly I discover
a filename that causes the value displayed to be truncated. I've
played with it. There are no special characters, they're all regular
ascii single byte characters. For some names it works, some get
truncated with no apparent rhyme or reason.

Has anyone seen anything like this before? Is this some weird bug or
explainable behavior in Cocoa? Could I be doing something wrong? My
application is running on Leopard with garbage collection enabled.

I've changed the name to be generic. The following filename
Xxxx....444..66.777

displays in my NSOutlineView as
Xxxx.

If I take out some xx's it works. Many other random changes will make
it work, such as changing the Xs to 0s. Some cases will cause it to
truncate at a later period, but it always truncates at a period.

This is extremely weird. Any suggestions appreciated.
___

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

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

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

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


Re: NSOutlineView sometimes truncates label

2009-06-01 Thread Graham Cox


On 02/06/2009, at 1:24 PM, David wrote:


If I take out some xx's it works. Many other random changes will make
it work, such as changing the Xs to 0s. Some cases will cause it to
truncate at a later period, but it always truncates at a period.

This is extremely weird. Any suggestions appreciated.


Sounds like it's merely word wrapping. Try replacing the periods with  
spaces - what happens?


You can disable word wrapping in IB for the cell - set the layout to  
scrolls and the Line Breaks to truncate tail (or middle, whatever  
you need) and check the truncates last visible line checkbox.


--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: NSOutlineView sometimes truncates label

2009-06-01 Thread David Melgar

Great! Thanks! That was it.

On Jun 1, 2009, at 11:31 PM, Graham Cox wrote:



On 02/06/2009, at 1:24 PM, David wrote:


If I take out some xx's it works. Many other random changes will make
it work, such as changing the Xs to 0s. Some cases will cause it to
truncate at a later period, but it always truncates at a period.

This is extremely weird. Any suggestions appreciated.


Sounds like it's merely word wrapping. Try replacing the periods  
with spaces - what happens?


You can disable word wrapping in IB for the cell - set the layout to  
scrolls and the Line Breaks to truncate tail (or middle,  
whatever you need) and check the truncates last visible line  
checkbox.


--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: NSToolbar: notification of change?

2009-06-01 Thread Andy Lee
Dunno if this would work, but... how about doing  
setAutosavesConfiguration:YES and observing user defaults?


--Andy

___

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

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

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

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


Accessing Cocoa/Quartz from a dynamic library function

2009-06-01 Thread Mikael Grev

Hello all,

I'm new to this Mac development thing, but I'm old when it comes to  
developing in general.


I'm trying to create a dylib with a function that will ultimately  
notify me of screen refresh rectangles. It is all working when I run  
it as an application (with a main method) but nothing happens if I run  
the exact same code in a method in a library. What am I missing?


I know the dylib is being called, I can change the log strings and  
they change appropriately. It is just the callback that doesn't get  
called.



As you can see from my commented lines I have tried quite a few  
combinations without luck, the callback is never called.



void MyScreenRefreshCallback ( CGRectCount count, const CGRect *  
rectArray, void * userParameter) {

   NSLog(@Callback called!);

   //for (int i=0; i  count; i++) {
   //NSLog(@Got a Rect);
   //fprintf(stdout, %f %f %f %f\n, rectArray[i].origin.x,  
rectArray[i].origin.y, rectArray[i].size.width,  
rectArray[i].size.height);

   //}
}

void startLoop()
{
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

   NSLog(@Starting...);

   NSApplicationLoad();

   //[NSApplication sharedApplication];
   CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);

   NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
   [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow: 10]];

   //[NSApp run];
   NSLog(@Done.);

   //CFAbsoluteTime now = CFAbsoluteTimeGetCurrent ();
   //while ( CFAbsoluteTimeGetCurrent() - now  15 ) {
   // sleep(1);
   //}

   CGUnregisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
   //return 0;
   [pool release];
}

In hope for a simple solution.

Cheers,
Mikael


Mikael Grev
Systems Architect

MiG InfoCom AB
S:t Olofsg 28a, 3tr
753 32 Uppsala
Sweden



___

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


several questions about saving a bundle in an NSDocument based application

2009-06-01 Thread Matthew Jeorrett

Hi,
I have successfully implemented the NSDocument architecture in my application 
and have implemented saving and loading documents by overriding the 
dataOfType:error: and readFromData:ofType:error: methods. I now want to be 
able to export my document into a folder selected by the user.  The items I 
will be putting in the folder are a few png images and a plain text file.  I 
have created a new package document type in the build target properties with 
the role value set as none.  The first gap in my knowledge is what the store 
type should be?
I am guessing that I should override the fileWrapperOfType:error: method so 
that if the type is document package I call a method to create a directory 
file wrapper with the images and text files I want instead of the default 
behaviour which is to create a file type NSFileWrapper with the data from the 
dataOfType:error: method.  I assume that the save panel will have asked the 
user for a directory as the document type is a package.
Finally, assuming my approach so far is correct, my last problem is I am unsure 
of how to add PNG images and a text file to the wrapper.  The images are stored 
as CGImageRefs and the text is in an NSString.
If anyone can clear any of this or maybe even all of this up or point me in the 
direction of an example I would be much obliged.
Cheers
M.J.
_
Share your photos with Windows Live Photos – Free.
http://clk.atdmt.com/UKM/go/134665338/direct/01/___

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: Accessing Cocoa/Quartz from a dynamic library function

2009-06-01 Thread Bill Bumgarner

On Jun 1, 2009, at 1:38 PM, Mikael Grev wrote:

  CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);


From the docs:

The callback function you register is invoked only if your  
application has an active event loop. The callback is invoked in the  
same thread of execution that is processing events within your  
application.


That implies to me that it needs to be registered on the main thread  
or it won't work.


b.bum

___

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: How determine if file is in Trash, given Path or Alias

2009-06-01 Thread Quincey Morris

On Jun 1, 2009, at 14:53, Gwynne Raskind wrote:


On Jun 1, 2009, at 4:31 PM, Sean McBride wrote:

This is a nice trick, I wasn't aware of that function, thanks.
Perhaps a minor improvement (one call instead of two):

- (BOOL) isTrashedFileAtPath:(NSString*)path
{
Boolean inTrash = false;
const UInt8* utfPath = (UInt8*)[path UTF8String];
	OSStatus err =  
DetermineIfPathIsEnclosedByFolder(kOnAppropriateDisk,

kTrashFolderType, utfPath, false, inTrash);
return (noErr == err) ? (true == inTrash) : NO;
}

Probably it does the same thing behind the scenes, but why not.

For the archives: 2 more problems:

a) use fileSystemRepresentation not UTF8String.

b) with GC, 'path' may be collected before
DetermineIfPathIsEnclosedByFolder() is finished with utfPath.  So  
best

to add a [path self] just before the 'return'.



This is a perfect example of why I would never use GC: That is the  
most nonintuitive confusing behavior I have ever heard of. If I  
crashed in the middle of DetermineIfPathIsEnclosedByFolder() for  
that reason I would never guess that GC was responsible!


Sorry, I can't let this pass without comment.

First, I believe Sean is wrong about (b), although the documentation  
is a little unclear. The description of [NSString UTF8String] says  
that the returned C string is automatically freed just as a returned  
object would be released, which implies (to me) that the returned  
pointer is to GC-controlled memory. In that case, the reference to the  
block held in stack variable 'utfPath' keeps the memory alive until  
DetermineIfPathIsEnclosedByFolder is called, and that function's  
parameter variable (another stack reference to the block) keeps it  
alive as long as the function needs. Because 'utfPath' is a separate  
block of memory, once it has been created, the lifetime of 'path'  
isn't relevant.


There would only be a problem if [NSString UTF8String] returned an  
*interior* pointer to memory owned by 'path'. In that case, Sean's  
statement would be correct -- the lifetime of 'path' might need to be  
artificially extended. But the documentation does not really support  
that interpretation.


This is in contrast to [NSData bytes], which really does return an  
*interior* pointer to memory owned by the NSData object. Interior  
pointers and GC are problematic. :)


Second, even if Sean is correct, I believe you'd be going too far by  
refusing to use GC as a consequence. There are plenty of gotchas in  
Cocoa generally, and this mailing list pretty much thrives on the  
resultant confusion and noninutiveness. The context doesn't even seem  
terribly non-intuitive to me -- if you use a method that returns a non- 
object pointer to memory you didn't allocate (and there are only a  
handful of such methods), then it seems fairly intuitive to ask  
yourself what steps might be necessary to keep the memory alive (and  
the answer may be none necessary) -- regardless of whether you're  
using GC or retain/release.







___

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: How determine if file is in Trash, given Path or Alias

2009-06-01 Thread Michael Ash
On Mon, Jun 1, 2009 at 6:40 PM, Sean McBride s...@rogue-research.com wrote:
 But it's not a huge issue: fileSystemRepresentation and UTF8String give
 the same thing 99% of the time.

And more importantly, the 1% of the time where they give you different
results, they still give you *equivalent* results.
-fileSystemRepresentation does some canonicalization before converting
to UTF-8, but anything that wants UTF-8 will take the canonical form
and vice versa. (There used to be some bugs on OS X with
non-normalized unicode in the filesystem, but they were fixed a LONG
time ago, so unless you're still writing code for 10.2 or something,
you don't need to worry about this.)

The only reasons to use -fileSystemRepresentation these days are
either to make the code more explicit about its intentions, or to
attempt to proof the code against a change in the file system encoding
to something other than UTF-8. Given the pervasiveness of UTF-8 in Mac
OS X will almost certainly never change until Apple builds something
new from scratch, and quite probably not even then. It may be useful
if you anticipate targeting a non-Apple Cocoa platform such as GNUStep
or Cocotron.

Mike
___

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: several questions about saving a bundle in an NSDocument based application

2009-06-01 Thread Graham Cox


On 02/06/2009, at 11:40 AM, Matthew Jeorrett wrote:

I have successfully implemented the NSDocument architecture in my  
application and have implemented saving and loading documents by  
overriding the dataOfType:error: and readFromData:ofType:error:  
methods. I now want to be able to export my document into a folder  
selected by the user.  The items I will be putting in the folder are  
a few png images and a plain text file.  I have created a new  
package document type in the build target properties with the role  
value set as none.  The first gap in my knowledge is what the store  
type should be?


I would guess 'binary' if you're writing out the content yourself. I'm  
not sure where this setting is used, it doesn't actually seem to make  
any difference.


I am guessing that I should override the fileWrapperOfType:error:  
method so that if the type is document package I call a method to  
create a directory file wrapper with the images and text files I  
want instead of the default behaviour which is to create a file type  
NSFileWrapper with the data from the dataOfType:error: method.  I  
assume that the save panel will have asked the user for a directory  
as the document type is a package.


Yes - you override -fileWrapperOfType:error: and build your own file  
wrapper with your package content.


Finally, assuming my approach so far is correct, my last problem is  
I am unsure of how to add PNG images and a text file to the  
wrapper.  The images are stored as CGImageRefs and the text is in an  
NSString.
If anyone can clear any of this or maybe even all of this up or  
point me in the direction of an example I would be much obliged.


You need to first get the images/text in the form of NSData  
representing the file contents. You then add these to the package  
fileWrapper using the -addRegularFileWithContents:preferredFilename:  
method




Here's some cut down code from my current project that writes out a  
package, including Quicklook thumbnails, which is simiar to your  
situation:


- (NSFileWrapper*)	fileWrapperOfType:(NSString*) typeName error: 
(NSError**) outError

{
		NSData* mainContent = [self dataOfType:kDKDrawingDocumentType  
error:outError];


if( mainContent == nil )
{
			*outError = [NSError errorWithDomain:kOrteliusErrorDomain  
code:kOrteliusNoDataErrorCode userInfo:nil];

return nil;
}

		NSFileWrapper* fw = [[NSFileWrapper alloc]  
initDirectoryWithFileWrappers:nil];	


		[fw addRegularFileWithContents:mainContent  
preferredFilename:@main_content];


// add Quick Look preview:

		NSFileWrapper* qlFolder = [[NSFileWrapper alloc]  
initDirectoryWithFileWrappers:nil];

[qlFolder setPreferredFilename:@QuickLook];
[fw addFileWrapper:qlFolder];
[qlFolder release];

// add preview and thumbnail

NSData* preview = [[self drawing] thumbnailData];
		[qlFolder addRegularFileWithContents:preview  
preferredFilename:@Thumbnail.jpg];


if( mSavePreview )
{
preview = [[self drawing] pdf];
			[qlFolder addRegularFileWithContents:preview  
preferredFilename:@Preview.pdf];

}

return [fw autorelease];
}

___

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: several questions about saving a bundle in an NSDocument based application

2009-06-01 Thread Michael Ash
On Tue, Jun 2, 2009 at 12:39 AM, Graham Cox graham@bigpond.com wrote:

 On 02/06/2009, at 11:40 AM, Matthew Jeorrett wrote:

 I have successfully implemented the NSDocument architecture in my
 application and have implemented saving and loading documents by overriding
 the dataOfType:error: and readFromData:ofType:error: methods. I now want
 to be able to export my document into a folder selected by the user.  The
 items I will be putting in the folder are a few png images and a plain text
 file.  I have created a new package document type in the build target
 properties with the role value set as none.  The first gap in my knowledge
 is what the store type should be?

 I would guess 'binary' if you're writing out the content yourself. I'm not
 sure where this setting is used, it doesn't actually seem to make any
 difference.

Store type only matters for NSPersistentDocument (CoreData)
applications. If you're handling your own storage then this field is
ignored, so you can set it to whatever makes you happy.

Mike
___

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