Re: exception in init

2012-04-04 Thread Klaus Backert

Hi,

On 4 Apr 2012, at 19:39, Dave wrote:


Hi,

If it's a real error

...

If it's a programming error

...

Just to be sure what you mean: What is a real error? Simply an error  
which is not a programmer's (or programming?) error?


Regards
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Document-based app: UI item validation

2011-08-21 Thread Klaus Backert


On 21 Aug 2011, at 18:59, Luc Van Bogaert wrote:


On 21 Aug 2011, at 15:43, Jerry Krinock wrote:



On 2011 Aug 21, at 05:02, Luc Van Bogaert wrote:

Adding a windowcontroller to the mainmenu nib also doesn't work,  
as the windowcontrollers should be instantiated from my document  
objects. right?


That is correct.

So, that leaves me the option to use the First Responder object.  
This does work, but I'm still wondering if maybe there is a better  
approach.


There is no better approach.  "First Responder Magic" is a good  
thing to use.




OK, thanks.

But this still leaves me with the question of how to reference my  
windowcontroller objects from the mainmenu nib? I need this because  
I want to modify the title of some menu items, depending on the  
state of the document windows. So I would like to make my  
windowcontroller objects menu delegates.


I thought about using an application delegate as file's owner in the  
mainmenu nib, and then target the menu items from this delegate.  
From the app delegate I can reference the window using keyWindow,  
but I haven't found a way to reference the windowcontroller objects...


When creating the window controller in the document's method  
makeWindowControllers, you might set a property (you declared) to this  
window controller. This way you will have access to it from all  
methods of the document, including action methods. You should also be  
able to bind the button's title to something like  
"document.myWindowController.myButtonTitle".


Regards
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


Re: NSLog() without the timestamp?

2011-08-09 Thread Klaus Backert


On 10 Aug 2011, at 02:29, William Squires wrote:

Thanks, this is the sort of thing I'm looking for, but is one of  
those cases of "if you don't know the right thing to ask for, you  
can't Google it"... In this case, the 'right thing' is QuietLog. :)


Try Google with "NSLog without timestamp" -- straightforward "the  
right thing to ask for".


Cheers

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


Re: What is the expected Cocoa API behavior in an incomplete object traversal?

2010-10-15 Thread Klaus Backert


On 15 Oct 2010, at 21:42, Tito Ciuro wrote:


Hello,

I'm implementing a method and I'm not sure what the behavior should  
be when detecting an anomaly.


Case in point: I have a method that iterates through an array of  
objects. As I traverse the array, I'm, checking whether the object  
in the array conforms to a custom protocol. If it does, everything  
is fine and I process it. However, if at some point I detect that  
the array contains a non-conforming object, what should the method  
do?:


a) skip the non-conforming object and continue processing and return  
a BOOL or fill an NSError?

b) stop processing and return a BOOL or fill an NSError?
c) throw an exception?

Since the method would end up processing less objects that the  
developer intended, I wonder what Cocoa developers would expect in  
this case...


Based on this last sentence "... processing less objects that " [i.e.  
"than"] "the developer intended ...", what you describe would count as  
a programmer error, because of which throwing an exception would be  
most appropriate for a Cocoa application.


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


Re: QTMovie Error -2048

2010-09-05 Thread Klaus Backert


On 5 Sep 2010, at 15:01, Mr. Gecko wrote:

I do not know if this is the right place to ask, I would think the  
quicktime list would be best, but, I am using cocoa to interface  
with quicktime so here it goes.
I have a customer who is getting error -2048 on my application, from  
my research it looks like it's an error with quicktime not being  
able to detect the file format, I believe the reason it can't detect  
this is because I'm loading from a URL without an extension (E.G. http://example.com/audio/2389f892988v998.) 
 How might I fix this, can I fix this, or do I have to give  
instructions to my customer on how to fix this? I haven't had anyone  
else with this problem, I am considering moving to NSSound and  
making my own controls, but I don't know if I'll have the same error  
there. I cannot change the URL for the mp3 files as it'll miss up my  
system.


In case you haven't found this already:




i.e. your customer's file is not a movie file.

regards
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


Re: menu madness with retain count

2010-04-27 Thread Klaus Backert


On 27 Apr 2010, at 21:38, vincent habchi wrote:

Because earlier in this afternoon I decided to trace the retain/ 
release messages sent to an object by overriding the respective  
methods and have them write the retain count before calling super  
methods. I registered most curious behaviors, for example objects  
released while the last time their retain count was printed it was  
equal to 2. No 1, no 0. That's why I asked, just to know if  
autorelease does not short-circuit the traditional release: call by  
accessing the retain count directly.


As others have said: This is the way to madness. You didn't believe  
it, do you?


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


Re: iPad Programming Tutorial

2010-04-26 Thread Klaus Backert


On 26 Apr 2010, at 17:49, David Rowland wrote:


On Apr 26, 2010, at 8:15 AM, ML wrote:



How about a good book that explains what IB does, how to set  
delegates, first responders, connect things up, etc


I think that misunderstanding prevents me from using IB as much as  
I really should.

...

I'm going to have to agree with Rick, IB is the way to go.


I have avoided IB because I find its operation peculiar and its  
terminology abstract. When I create objects in code I have a much  
firmer idea of where they are, when they come into existence and  
what I can do with them. IB is yet another language to master. and  
you still have to write a fair amount of custom code.


One more reason to follow the advice above. And: Apple's documentation  
clearly states the how, where, when, what, etc. of objects created via  
Interface Builder. Read the fine manual! May be, you will recognize  
that IB is not a language but a tool -- it's easier to get a grip --,  
and that you do not have to write a fair amount of custom code. In  
your current situation you just don't know, you only assume.


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


Re: Implied use of Properties

2010-04-06 Thread Klaus Backert


On 6 Apr 2010, at 16:19, Dave wrote:

Also as far as I can see, there are a couple of draw-backs to doing  
it this way. In the example:


-(ClassY*) mClassY
{
if (mClassY == nil)
{
mClassY = [[ClassY alloc] initWithData:someData]:
}
return mClassY;
}

The reasons I don't like this are:

1.  "someData" is hardwired and it's impossible to pass a parameter  
to "mClassY" since it's a getter.


Yes, and in the OpenGL example a gave, there is indeed something  
hardwired: the attributes of the pixel format the OpenGL context is  
built upon -- which is no problem for this kind of application.


2.  If either the alloc or initWithData methods fail there is no way  
to pass the error back to the caller except by passing nil as the  
Class Selector. And if this were done in a statement like:


self.mClassY. mClassYValue = someValue;

I'm not sure what would happen but it wouldn't be good news!


After getting the OpenGL context property, I always have an assertion  
in the debug configuration (see below). And I almost never concatenate  
several invocations of methods, including properties. For debugging  
purposes I have a lot of assertions in between (may be, I'm a little  
bit paranoid, but, well, what would you expect from a mathematician ;-).


@interface MyCustomView : NSView
{
@private
NSOpenGLContext * mContext;
}
...
@property (readonly, retain) NSOpenGLContext *myContext;
...
@end

@implementation MyCustomView
...
@dynamic myContext;
...
- (NSOpenGLContext *) myContext
{
if (mContext == nil)
{
		mContext = [[NSOpenGLContext alloc] initWithFormat:  
self.myPixelFormat shareContext: nil];

}
return mContext;
}
...
- (void)mySomethingOne
{
NSOpenGLContext *theContext = self. myContext;
MY_ASSERT(theContext != nil);
...
}
- (void)mySomethingTwo
{
NSOpenGLContext *theContext = self. myContext;
MY_ASSERT(theContext != nil);
...
}
@end

There is, of course, a release (and setting to nil) in dealloc, in  
order to balance the retain by alloc-init.


Whatever is called first, mySomethingOne or mySomethingTwo, the  
context is created at that point during the execution.



-(ClassY*) SetmClassY (ClassY* theClassY)



This should be

- (void)setmClassY: (ClassY *)theClassY

regards
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


Re: Two text fields, one outlet?

2010-04-05 Thread Klaus Backert


On 5 Apr 2010, at 22:40, Kyle Sluder wrote:

On Mon, Apr 5, 2010 at 1:56 AM, Klaus Backert > wrote:
Setting of properties can and should be done this way (except when  
using the

modern runtime and synthesizing the instance variable):


There's nothing different about synthesizing the instance variable.

If you want the property semantics, use either dot syntax (foo.bar =
baz) or message syntax ([foo setBar:baz]). They are defined to be
exactly equivalent. Again, you can use whichever you like.

If you want the direct ivar access semantics (for example, in -init
and -dealloc), but you've synthesized the ivar, you can use pointer
dereference through self to get at it (self->bar = baz).

Both semantics are necessary. It's important to understand the
difference between them.

Older compilers don't support pointer dereference for synthesized
ivars. This is a bug, and you should upgrade your development tools.

--Kyle Sluder


Yes, I know. My statement above has a different background, among  
other things a documentation bug (somebody told me off list about it),  
and, sigh, my incomplete ablity of expressing myself in a foreign  
language.


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


Re: Two text fields, one outlet?

2010-04-05 Thread Klaus Backert


On 5 Apr 2010, at 04:09, Jenny M wrote:


This is the method I ended up going with. I had tried to use bindings
before by doing exactly that - setting up a property, synthesizing it,
and binding the value to the property - but I noticed I was setting
the value wrong. I was calling
  property = [NSNumber...]
rather than
  [self setProperty:[]]. <-- Finally, that worked!!



Setting of properties can and should be done this way (except when  
using the modern runtime and synthesizing the instance variable):


self.property = ...

which is equivalent to [self setProperty: ...]

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


Re: Alternative startup for application

2010-04-02 Thread Klaus Backert


On 3 Apr 2010, at 01:15, Gideon King wrote:

Excellent, I like the new way of doing it using NSEvent directly,  
but I do need to support Leopard.


- (NSUInteger)modifierFlags

Available in Mac OS X v10.0 and later.

NSAlternateKeyMask
Set if Option or Alternate key is pressed.

Available in Mac OS X v10.0 and later.


etc.

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


Re: Implied use of Properties

2010-04-02 Thread Klaus Backert

Hi, Dave

On 2 Apr 2010, at 22:48, Dave wrote:


Hi All,

I came across this code and was wondering if this is normal practice  
and/or considered good coding style.


Given two classes ClassX and ClassY:

@interface ClassX
{
ClassY  mClassY;
}

@property (nonatomic,retain,readonly)   ClassY* mClassY
@end

@interface ClassY
{
int mClassYValue;
}

@property (nonatomic,retain,readonly)   ClassY* mClassY

@end

@implementation ClassX

-(ClassY*) mClassY
{
if (mClassY == nil)
{
mClassY [[ClassY alloc] initWithData:someData]:
}
return mClassY;
}


Then later in another method of ClassX, I found the following code:

self.mClassY. mClassYValue = someValue;

Before this statement is executed, self. mClassY is nil. When it is  
executed it causes the "mClassY" method to be called which allocates  
the Class and sets the Variable.


There are some typing errors in this code, I think, but anyway, this  
might be a case of lazy creation of an object inside a getter of  
another object. You will find the same e.g. in Apple's code examples  
about OpenGL, where the OpenGL context is an instance variable of the  
OpenGL view. Accessing the context is managed by a getter method or  
property, respectively, of the view, where, in the case of the  
instance variable being nil, the context is created, stored in the  
instance variable, and eventually returned. I call the creation  
"lazy", because it is done at the latest point during execution,  
immediately before it is needed. For me this practice is normal.


But, may be, I don't understand your question correctly.

regards
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


Re: Solving memory leaks

2010-03-28 Thread Klaus Backert


On 28 Mar 2010, at 19:27, Michael Davey wrote:

That would be gut for the fact that my fields are released and set  
to nil whenever a new SELECT query is executed - however, I think I  
can do this by emptying the array when a new query is done and just  
counting the size of the array in my fetch method - thanks...


"emptying the array" is among the "etc." below ;-)

[fields removeAllObjects];

and, if you first add and then remove [all] correctly, then the  
balance between retain and release of the objects in the dictionary is  
not destroyed (not this way at least).



On 28 Mar 2010, at 18:11, Klaus Backert wrote:

...
In order to handle your fields instance variable correctly, what do  
you think about the following:


Create fields in the init method of your "MyClass" object (I don't  
know how you call this class):


fields  = [[NSMutableDictionary alloc] init];

by which you retain the fields dictionary.

And destroy fields in the corresponding dealloc method:

[fields release];
fields = nil;

If you want to use the fields dictionary anywhere in your code, you  
just do only calls like:


[fields addObject: ...];
[fields removeObject: ...];
MyOtherObject *myOtherObject = (MyOtherObject *)[fields  
objectForKey: ...];

etc.

but you do *not* invoke methods which initialize or dealloc the  
fields object.


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


Re: Solving memory leaks

2010-03-28 Thread Klaus Backert


On 28 Mar 2010, at 19:11, Klaus Backert wrote:


MyOtherObject *myOtherObject = [fields objectWithKey: ...];


Correction: objectForKey

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


Re: Solving memory leaks

2010-03-28 Thread Klaus Backert


On 28 Mar 2010, at 18:40, Michael Davey wrote:

1. Some other piece of code assigns a new value to 'myFields'  
without releasing the old value.


That is the only part of my code that adds values to the field.


In order to handle your fields instance variable correctly, what do  
you think about the following:


Create fields in the init method of your "MyClass" object (I don't  
know how you call this class):


fields  = [[NSMutableDictionary alloc] init];

by which you retain the fields dictionary.

And destroy fields in the corresponding dealloc method:

[fields release];
fields = nil;

If you want to use the fields dictionary anywhere in your code, you  
just do only calls like:


[fields addObject: ...];
[fields removeObject: ...];
MyOtherObject *myOtherObject = [fields objectWithKey: ...];
etc.

but you do *not* invoke methods which initialize or dealloc the fields  
object.


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


Re: Solving memory leaks

2010-03-27 Thread Klaus Backert


On 27 Mar 2010, at 23:16, Quincey Morris wrote:


On Mar 27, 2010, at 14:11, Klaus Backert wrote:


something like this (caution: typed in mail, etc.)



Yeah, something like this, but *not* this:


self.myFields = [[NSMutableArray alloc] init];


That's a memory leak right there. :)


Yes, sorry, and shame on me; too fast, too erroneous. The alloc-init  
retains and is not balanced by a release.


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


Re: Solving memory leaks

2010-03-27 Thread Klaus Backert


On 27 Mar 2010, at 21:31, Michael Davey wrote:

So, you are saying I should call a retain when I get my reference so  
that it is kept as an instance var?


On 27 Mar 2010, at 19:33, Sandor Szatmari wrote:

Every time this method runs you would loose the reference to the  
memory previously allocated for the fields array.  This happens  
when you assign a newly allocated array to feilds.


You should either release fields before  reassigning it  
(conditionally if it is not nil), or do not reallocate memory for  
it, instead empty it and reuse the existing memory.


Assuming fields is an instance variable of some object, you could --  
or even should -- access it not directly but via getters and setters,  
which do memory management according to the rules, e.g. something like  
this (caution: typed in mail, etc.)


@interface MyClass
{
NSMutableDictionary *fields;
}
@property (retain) NSMutableDictionary *myFields;
@end

@implementation MyClass
@synthesize myFields = fields;
...
- (NSDictionary *)fetch
{
...
self.myFields = [[NSMutableArray alloc] init];
...
}
@end

regards
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


Re: set file name in NSSavePanel

2010-03-17 Thread Klaus Backert


On 17 Mar 2010, at 10:49, Nikhil Khandelwal wrote:


Is there any way to to set the file name in NSSavePanel for 10.5.
I tried "setNameFieldStringValue" but this is available for 10.6 or  
later. Is there any similar method available for 10.5.


According to the documentation of NSSavePanel the method

- (void)beginSheetForDirectory:(NSString *)path file:(NSString *)name  
modalForWindow:(NSWindow*)docWindow modalDelegate:(id)modalDelegate  
didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo


"Presents a Save panel as a sheet with a specified path and,  
optionally, a specified file in that path."

and
"name
Specifies a particular file in path that is selected when the Save  
panel is presented to a user. When nil, no file is initially selected."


Hope this helps.

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


Re: Help visualizing something in IB

2010-03-10 Thread Klaus Backert


On 11 Mar 2010, at 00:54, Brian Postow wrote:

Basically, I want the topView to scroll, but I always want to be  
able to see the buttonView. So if part of the topView isn't visible  
because it's been scrolled up, I want the buttonview at the top of  
the screen.


This looks like you just do *not* want to scroll the part with the  
buttons. Wouldn't this lead to having the buttons outside the scroll  
view, and only having the image inside?


All together like this:
A window with a regular content view, having two subviews:
- your button view
- a regular scroll view with your image view as its one and only subview

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


Re: How a window was closed?

2010-03-05 Thread Klaus Backert


On 5 Mar 2010, at 20:01, Eric Gorr wrote:


Why is -windowShouldClose: not reliable?


May be, because the situation is as the method's documentation says:

"This method may not always be called during window closing.  
Specifically, this method is not called when a user quits an  
application."


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


Re: NSWindow - makeKeyAndOrderFront problem

2010-02-28 Thread Klaus Backert


On 28 Feb 2010, at 15:46, Alexander Bokovikov wrote:



On 28.02.2010, at 17:48, jonat...@mugginsoft.com wrote:


Try scheduling it for the next iteration of the run loop.

[mainWindow performSelector:@selector(makeKeyAndOrderFront:)  
withObject:nil afterDelay:0.0];


It looks like I've understood why it is not working. Here is the  
message description:


his action method moves the receiver to the front of the screen  
list, within its level, and makes it the key window; that is, it  
shows the window.


What is "within its level"? What is the level? Does it mean that  
this message brings a window to front within the same application/ 
process only? If yes, then how to do the same when the process  
(application is not the active (hasn't keyboard input)?


Window levels are defined in the NSWindow Class Reference. See in the  
"Constants" section: NSNormalWindowLevel, NSFloatingWindowLevel,  
NSSubmenuWindowLevel, etc.


"These constants specify the window’s level. The stacking of levels  
takes precedence over the stacking of windows within each level. That  
is, even the bottom window in a level will obscure the top window of  
the next level down. Levels are listed in order from lowest to  
highest. These constants are mapped (using #define statements) to  
corresponding elements in the Window Level Keys in Core Graphics."


See also the chapter "Window Layers and Levels" in the "Window  
Programming Guide for Cocoa".


Regards
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


Re: NSDocument

2010-01-14 Thread Klaus Backert


On 14 Jan 2010, at 23:44, David Blanton wrote:


Ok. So I diagnose that MyDocument.xib was somehow hosed.

I deleted my main view which was embedded in a scroll view.

Added a custom view set its class to my class MainView.

Embedded MainView in a scroll view.

Compiled and ran.

And guess what, awakeFromNib in MyDocument.m which is a sub class of  
NSDocument is now being called when I choose open.


Go figure.

Now I still need to delete LibraryObjectTemplate (which mysteriously  
appeared, see separate post) but cannot delete noway no how.


Thanks for the comments.


Congratulations!

Regarding LibraryObjectTemplate ...

According to my experience one reason for objects in a nib/xib file  
not being deletable is, that they contain other objects (you can see  
this in the outline view mode in the Interface Builder document  
window), or that they have certain connections to other objects. These  
other "things" have to be deleted first.


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


Re: NSDocument

2010-01-14 Thread Klaus Backert


On 14 Jan 2010, at 22:51, David Blanton wrote:

No.  This is a vanilla document based app with two nibs, MainMenu  
and MyDocument as created by the project template.


The document window is in MyDocument.xib.


What is specified as the class of file's owner in the nib/xib file: (a  
subclass of) NSDocument  or (a subclass of) NSWindowController? You  
can set and see this in the inspector's identity panel.


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


Re: change value for key in NSDictionary

2009-11-23 Thread Klaus Backert


On 23 Nov 2009, at 13:33, Ariel Feinerman wrote:


Hi,
there is instance of NSDictionary to storage graphics attributes (full
screen, buffers` sizes, resolution),
my question is can I change value for, example, key "fullscreen"
somewhere in my progam?


From the NSDictionary Class Reference:

"An instance of NSDictionary is an immutable dictionary: you establish  
its entries when it’s created and cannot modify them afterward. An  
instance of NSMutableDictionary is a mutable dictionary: you can add  
or delete entries at any time, and the object automatically allocates  
memory as needed."


Use an NSMutableDictionary and invoke e.g.

[myMutableDictionary setObject: [NSNumber numberWithBool: fstate]  
forKey: @"fullscreen"];


This replaces a previous entry with the same key.

Regards
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


Re: Cocoa Sounds

2009-11-09 Thread Klaus Backert


On 9 Nov 2009, at 19:25, Chunk 1978 wrote:


humm... i'm running 10.5.8 on 2008 iMac C2D, but i never though it
could have been the computer.  would like to hear from others.


Did you check whether there are certain "special" processes running on  
your machine?


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


Re: UIView animation docs question

2009-11-03 Thread Klaus Backert


On 3 Nov 2009, at 23:23, lorenzo7...@gmail.com wrote:


Here's the code:

[UIView beginAnimations:@"display" context:NULL];
[UIView setAnimationDuration:0.30];
[UIView setAnimationDelegate:self];
[UIView  
setAnimationDidStopSelector 
:@selector(animationDidStop:finshed:context:)];


Really "finshed" -- the "i" missing -- above and "finished" below in  
your code?


-(void)animationDidStop:(NSString *)animationID finished:(NSNumber  
*)finished context:(void *)context{...}


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


Re: _NSAutoreleaseNoPool missing in Snow Leopard

2009-08-31 Thread Klaus Backert


On 31 Aug 2009, at 03:50, Kyle Sluder wrote:

Except his previous stack trace seems to indicate that the at-fault  
code is in QTKit…


When logging image and library names as they are loaded and calls to  
class and category +load methods it looks like you can see below.  
Interestingly -- or not interestingly? -- +[QTMovieContentView load]  
is called before the autorelease error message appears.


...
Running…
Blotto(388) malloc: enabling scribbling to detect mods to free blocks
objc[388]: OBJC_PRINT_OPTIONS is set
objc[388]: OBJC_PRINT_IMAGES is set
objc[388]: OBJC_PRINT_LOAD_METHODS is set
objc[388]: OBJC_PRINT_CXX_CTORS is set
objc[388]: OBJC_DISABLE_GC is set
objc[388]: IMAGES: processing 109 newly-mapped images...

objc[388]: IMAGES: loading image for /usr/lib/libobjc.A.dylib  
(supports GC)




objc[388]: IMAGES: loading image for /System/Library/Frameworks/ 
AppKit.framework/Versions/C/AppKit (supports GC)


objc[388]: IMAGES: loading image for /System/Library/Frameworks/ 
QTKit.framework/Versions/A/QTKit (supports GC)


objc[388]: IMAGES: loading image for /Volumes/C/Development/Projects/ 
Blotto/build/Debug/Blotto.app/Contents/MacOS/Blotto


objc[388]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
objc[388]: LOAD: class 'NSObject' scheduled for +load
objc[388]: LOAD: +[NSObject load]



objc[388]: LOAD: +[NSApplication load]

 invoking at /Volumes/C/Development/ 
Projects/Demokrit/DktWorld.cpp:18
 initialize ODE library at /Volumes/C/ 
Development/Projects/Demokrit/DktWorld.cpp:21

objc[388]: LOAD: class 'QTMovieContentView' scheduled for +load
objc[388]: LOAD: +[QTMovieContentView load]

(gdb) continue
objc[388]: IMAGES: checking 1 images for compatibility...
objc[388]: IMAGES: processing 18 newly-mapped images...

2009-08-31 12:18:36.793 Blotto[388:813] *** _NSAutoreleaseNoPool():  
Object 0xa0c13290 of class NSCFString autoreleased with no pool in  
place - just leaking
Stack: (0x94350dac 0x9427de14 0x9134ca24 0x940bcab4 0x940bc934  
0x940bb010 0x96df69d8 0x940c49b0 0x940bd4ec 0x8fe02d7c 0x8fe0f220  
0x8fe0f198 0x8fe0f36c 0x8fe03848 0x8fe08144 0x8fe01774 0x8fe01048)

(gdb)

This all is on Leopard. I haven't had the opportunity of testing this  
on Snow Leopard.


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


Re: _NSAutoreleaseNoPool missing in Snow Leopard

2009-08-30 Thread Klaus Backert


On 31 Aug 2009, at 03:29, Roland King wrote:


DKT_LOG("initialize ODE library");

What does that macro do - does it create an autoreleased NSString  
from its argument and then NSLog it? If so, that NSString is being  
leaked as the message suggests.



The macro DKT_LOG is implemented in the following way.

#include 
#define DKT_LOG_ENABLED
#define DKT_CURRENT_FUNCTION BOOST_CURRENT_FUNCTION
#ifdef DKT_LOG_ENABLED
#define DKT_LOG(MESSAGE) dkt::log(DKT_CURRENT_FUNCTION, __FILE__,  
__LINE__, (MESSAGE))

#else
#define DKT_LOG(MESSAGE)
#endif

in the DktDebug.h file:

namespace dkt {
extern void log(char const * function, char const * file, long int  
line, char const * message);

}

in the DktDebug.cpp file:

namespace dkt {
void log(char const * function, char const * file, long int line, char  
const * message)

{
	std::cerr << "<" << function << "> " << message << " at " << file  
<<":" << std::dec << line << std::endl << std::flush;

}
}

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


Re: _NSAutoreleaseNoPool missing in Snow Leopard

2009-08-30 Thread Klaus Backert


On 31 Aug 2009, at 02:45, Kyle Sluder wrote:

On Aug 30, 2009, at 5:33 PM, Klaus Backert online.de> wrote:


No Objective-C program code of my own has been executed up to this  
point. I have not been able to manage this.


Are you doing anything before calling NSApplicationMain?


My NSApplicationMain is the "standard" one:

#import 

int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}

Previous to any of my own Objective-C code the following C++ module  
initializer function is executed, which is contained in a C++ library  
of mine:


static bool WorldIsInitialized = false;
static void __attribute__((constructor)) InitializeWorld()
{
DKT_LOG_INVOKING;
if (!dkt::WorldIsInitialized)
{
DKT_LOG("initialize ODE library");
dkt::Integer isODEInitialized = dInitODE2(0);
DKT_ASSERT(isODEInitialized);
dkt::WorldIsInitialized = true;
}
}

(The macros DKT_LOG_INVOKING and DKT_LOG display the pertinent  
messages you can see below.)


The debugger console displays the following, after having stepped out  
of NSLog():


[Session started at 2009-08-31 03:03:06 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-966) (Tue Mar 10 02:46:18  
UTC 2009)

Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and  
you are
welcome to change it and/or distribute copies of it under certain  
conditions.

Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for  
details.

This GDB was configured as "powerpc-apple-darwin".tty /dev/ttys001
sharedlibrary apply-load-rules all
Loading program into debugger…
Program loaded.
run
[Switching to process 2101 local thread 0x2e03]
bash(2101) malloc: enabling scribbling to detect mods to free blocks
arch(2101) malloc: enabling scribbling to detect mods to free blocks
objc[2101]: OBJC_PRINT_OPTIONS is set
objc[2101]: OBJC_PRINT_CXX_CTORS is set
objc[2101]: OBJC_PRINT_EXCEPTIONS is set
objc[2101]: OBJC_PRINT_ALT_HANDLERS is set
objc[2101]: OBJC_DISABLE_GC is set
objc[2101]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
Running…
Blotto(2101) malloc: enabling scribbling to detect mods to free blocks
objc[2101]: OBJC_PRINT_OPTIONS is set
objc[2101]: OBJC_PRINT_CXX_CTORS is set
objc[2101]: OBJC_PRINT_EXCEPTIONS is set
objc[2101]: OBJC_PRINT_ALT_HANDLERS is set
objc[2101]: OBJC_DISABLE_GC is set
objc[2101]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
 invoking at /Volumes/C/Development/ 
Projects/Demokrit/DktWorld.cpp:18
 initialize ODE library at /Volumes/C/ 
Development/Projects/Demokrit/DktWorld.cpp:21

(gdb) continue
2009-08-31 03:03:28.075 Blotto[2101:813] *** _NSAutoreleaseNoPool():  
Object 0xa0c13290 of class NSCFString autoreleased with no pool in  
place - just leaking
Stack: (0x94350dac 0x9427de14 0x9134ca24 0x940bcab4 0x940bc934  
0x940bb010 0x96df69d8 0x940c49b0 0x940bd4ec 0x8fe02d7c 0x8fe0f220  
0x8fe0f198 0x8fe0f36c 0x8fe03848 0x8fe08144 0x8fe01774 0x8fe01048)

(gdb)

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


Re: _NSAutoreleaseNoPool missing in Snow Leopard

2009-08-30 Thread Klaus Backert


On 30 Aug 2009, at 23:00, Seth Willits wrote:



In Snow Leopard I started seeing this:
*** __NSAutoreleaseNoPool(): Object 0x100a49ec0 of class NSCFString  
autoreleased with no pool in place - just leaking



I have no idea where this is happening so I tried to break in  
_NSAutoreleaseNoPool just like the Apple documentation at http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html 
 says to. However, it's not resolving. GDB claims there is no  
_NSAutoreleaseNoPool defined. I used nm on Foundation in Snow  
Leopard and there is no function. On 10.5, though, there is. So it  
seems it's gone and I can't find anything similarly named.


Does anyone know what I *should* be breaking on? I'd obviously like  
to track this down.


For me such a message, e.g.
*** _NSAutoreleaseNoPool(): Object 0xa0c13290 of class NSCFString  
autoreleased with no pool in place - just leaking
appeared in Mac OS X 10.5.8 already, and has not been there in 10.5.7.  
The function name has only one underscore at the beginning.


The stack is as follows:

#0  0x942f0900 in NSLog
#1  0x94350dc4 in _NSAutoreleaseNoPool
#2  0x9427de14 in -[NSObject(NSObject) autorelease]
#3  0x9134ca24 in +[NSView initialize]
#4  0x940bcab4 in _class_initialize
#5  0x940bc934 in _class_initialize
#6  0x940bb010 in _class_lookupMethodAndLoadCache
#7  0x96df69d8 in +[QTMovieContentView load]
#8  0x940c49b0 in call_load_methods
#9  0x940bd4ec in load_images
#10	0x8fe02d7c in  
__dyld__ZN4dyld12notifySingleE17dyld_image_statesPK11mach_headerPKcl
#11	0x8fe0f220 in  
__dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj
#12	0x8fe0f198 in  
__dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj
#13	0x8fe0f36c in  
__dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE

#14 0x8fe03848 in __dyld__ZN4dyld24initializeMainExecutableEv
#15 0x8fe08144 in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_
#16 0x8fe01774 in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl
#17 0x8fe01048 in __dyld__dyld_start

No Objective-C program code of my own has been executed up to this  
point. I have not been able to manage this.


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


Re: Cocoa Graphics Parsing

2009-07-21 Thread Klaus Backert


On 21 Jul 2009, at 03:50, Courtney Arnold wrote:


Hello all,

I need to programmatically parse/read through the contents of an  
NSImage. I am unable to find a tutorial or documentation that would  
explain how to do so. I would like to get some input on where I may  
be able to search for this information.


thank you,


since you want to scan barcode, by Googling I found, among other  
things, this:


http://www.bruji.com/cocoa/barcode.html

They have a "barcode scanner project, written in Cocoa". The code is  
available for free.


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


Re: GC pros and cons

2009-06-27 Thread Klaus Backert


On 27. Jun 2009, at 14:17, Thomas Davie wrote:


Now I'm confused, because other people said, GC frees objects  
*when* nothing depends on them any more *or* at some point later in  
time. By the way, it would be different, if you said "if" instead  
of "when", but then, I think, you would have no point in the  
ongoing discussion.


Why is this a problem?


It's not a problem for me (and I didn't say so).

Nothing depends on the objects, and hence nothing can see when  
they're actually collected.  If you're worried about running out of  
space because the collector is lazy


I'm not worried about this.

, then all you need to know is that as soon as you get to the "oh  
shit, no memory" stage, the collector runs and frees some more up  
(unless there really is none to free up).


All you're doing by keeping track of the dependancy graph yourself  
is reinventing the wheel


I'm not reinventing the wheel, I use simple retain/release based  
memory management -- and after all these years it *is* simple for me.


-- lots of people have put a lot of research into how to keep track  
of those dependancies fast, and in a way that frees up memory  
quickly and efficiently.


Is it correct reading your answer as "wether objects are freed *when*  
nothing depends on them any more *or* at some point later in time --  
it does *not* matter"?


Still open question:
With GC are objects freed *when* they are used any more *or* at some  
point later in time?


And if it doesn't matter, doesn't it really matter in *all* cases?

By the way, I won't start using GC now because I'm in the midst of a  
project I started without GC. A "monster" :-) dependency graph inside  
is built using OpenSceneGraph, which has its own memory management  
mechanism.


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


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


Re: One IBAction, multiple results from multiple methods

2009-02-26 Thread Klaus Backert


On 26. Feb 2009, at 03:49, I. Savant wrote:


On Feb 25, 2009, at 9:36 PM, Walker Argendeli wrote:

Lets say I have some custom code that does the same thing, with the  
exception that a few IBOutlets are different for each type.   
Instead of having multiple methods, is there a way to use 1  
IBAction, and take necessary action depending on where it was sent?



- (IBAction)seek:(id)sender
{
 int tag = [sender tag];  // or NSInteger tag = [sender tag];
 switch (case)
 {
   case 1001: // seek back
   [self seekBack];
   break;

   case 1002: // seek back FAST
   [self seekBackFast];
   break;

   case 1003: // seek forward
   [self seekForward];
   break;

   case 1004: // seek forward FAST
   [self seekForwardFast];
   break;

   default:
   NSBeep(); // don't know what to do here ...
   break;

 }
}

 Don't forget to set the tags in IB for your controls.


... and now we went from a plethora of methods to the same plethora of  
case statements plus tags.


For the methods the dispatch is made under the hood. The switch  
statement is kind of re-inventing the objected-oriented wheel in a  
procedural way.


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


Re: Core Data reads xml store value @" " as @""

2009-02-20 Thread Klaus Backert


On 21. Feb 2009, at 01:51, Ricky Sharp wrote:



On Feb 20, 2009, at 6:45 PM, Jerry Krinock wrote:

There is an attribute in my Core Data document-based app whose  
string value can legitimately be a single single utf8 0x20 space  
character, @" ".  (It's a user-selectable delimiter.)


When I save a document with this attribute value, reading the XML  
store file with BBEdit shows that it is a single space character,  
like this:


  



I'd file that as a bug.  The XML above, while legal, will most  
likely always result in a value of  being an empty  
string.  Whitespace is typically trimmed by XML parsers.


e.g. if you had:

[NEW LINE]
[TAB][SPACE][NEW_LINE]


You'd typically still get an empty string.


Not exactly. See this: 

2.10 White Space Handling
In editing XML documents, it is often convenient to use "white  
space" (spaces, tabs, and blank lines) to set apart the markup for  
greater readability. Such white space is typically not intended for  
inclusion in the delivered version of the document. On the other hand,  
"significant" white space that should be preserved in the delivered  
version is common, for example in poetry and source code.


An XML processor must always pass all characters in a document that  
are not markup through to the application. A validating XML processor  
must also inform the application which of these characters constitute  
white space appearing in element content.


A special attribute named xml:space may be attached to an element to  
signal an intention that in that element, white space should be  
preserved by applications. In valid documents, this attribute, like  
any other, must be declared if it is used. When declared, it must be  
given as an enumerated type whose values are one or both of "default"  
and "preserve". For example:


 xml:space (preserve) #FIXED 'preserve'>
The value "default" signals that applications' default white-space  
processing modes are acceptable for this element; the value "preserve"  
indicates the intent that applications preserve all the white space.  
This declared intent is considered to apply to all elements within the  
content of the element where it is specified, unless overridden with  
another instance of the xml:space attribute. This specification does  
not give meaning to any value of xml:space other than "default" and  
"preserve". It is an error for other values to be specified; the XML  
processor may report the error or may recover by ignoring the  
attribute specification or by reporting the (erroneous) value to the  
application. Applications may ignore or reject erroneous values.


The root element of any document is considered to have signaled no  
intentions as regards application space handling, unless it provides a  
value for this attribute or the attribute is declared with a default  
value.


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


Re: Switching NSDocument based application to tabbed views interface

2009-01-22 Thread Klaus Backert


On 22. Jan 2009, at 17:02, Ross Carter wrote:



On Jan 21, 2009, at 1:38 PM, Fritz Anderson wrote:


On 21 Jan 2009, at 9:42 AM, Ross Carter wrote:

Can someone give me a hint how can I switch one window per  
document model (that currently works as expected thanks to  
NSDocument) to one tab per document, same window?


This is answered in the archives. Search cocoabuilder.com for  
document window tabs


I'm sure it's answered in the archives _somewhere_, but searching  
cocoabuilder for "document window tabs" produces tens of thousands  
of results, and none in the first few pages is relevant.


That's odd. When I went to www.cocoabuilder.com, and typed "document  
window tabs" in the search field, I got 78 hits. The second one was  
a thread titled "Document based apps and tabbed windows."


If you really did get tens of thousands of results from the query I  
suggested, then I understand your frustration.


It's the difference between "Search for: All of the words" and "Search  
for: Any of the words". You can choose this in the "Advanced search".  
The default is _Any_, because of which more than 40.000 results are  
found in this case.


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


Re: Main menu crash when migrating to Leopard

2008-12-23 Thread Klaus Backert

Apologies for answering my own question (nobody else did)

On 2008-12-13 I posted the following:

Being about to migrate a Cocoa document-based application of mine,  
which is under development, from Mac OS X 10.4.11 and Xcode 2.5 to  
Mac OS X 10.5.5 and Xcode 3.1.2 (on a PowerPC G5) the application  
crashes in the phase of – I think – setting up and displaying the  
main menu.


2008-12-13 12:57:33.701 Blotto[715:813] NSExceptionHandler has  
recorded the following exception:
NSUnknownKeyException -- [< 0x45fdd0>  
setValue:forUndefinedKey:]: this class is not key value coding- 
compliant for the key inputBarExtent.



objc_exception_throw (in libobjc.A.dylib) + 72
-[NSException init] (in CoreFoundation) + 0
-[CIFilter setValue:forUndefinedKey:] (in QuartzCore) + 200
-[NSObject(NSKeyValueCoding) setValue:forKey:] (in Foundation) + 264
-[CIFilter setValue:forKey:] (in QuartzCore) + 308
ResetMenuBarWindowFilter() (in HIToolbox) + 464
ShowBar(unsigned char, unsigned char) (in HIToolbox) + 312
SetSystemUIMode (in HIToolbox) + 284
-[NSApplication finishLaunching] (in AppKit) + 776
-[NSApplication run] (in AppKit) + 100
NSApplicationMain (in AppKit) + 444
main (in Blotto) (main.m:9)
start (in Blotto) + 68



- project format: Xcode 3.1 compatible
- architecture: native
- base SDK: Mac OS X 10.5
- compiler: GCC 4.0
- deployment target: Mac OS X 10.5
- garbage collection: off


In the meantime I created a brand new project, added step by step one  
part of the previous project after the other, built the application  
after each addition, started it in the debugger, etc. etc., until the  
crash appeared again.


The cause of the crash is the following category, I had implemented,  
overriding a method of NSObject's NSKeyValueCoding category:


@interface NSObject (MyKeyValueCoding)
+ (BOOL)accessInstanceVariablesDirectly;
@end

@implementation NSObject (MyKeyValueCoding)
+ (BOOL)accessInstanceVariablesDirectly { return NO; }
@end

After having deleted this category, the application works again.

Well, there have been warnings on this mailing list about overriding  
methods of Cocoa categories. I did it at my own risk. Apparently it's  
too much stopping direct access of instance variables in key-value  
coding for *each* and *every* class.


Regards
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


Re: C++ instance variables not destructed if NSZombieEnabled

2008-12-22 Thread Klaus Backert


On 22.12.2008, at 22:54, Greg Parker wrote:


On Dec 22, 2008, at 6:49 AM, Klaus Backert wrote:
In an application of mine I have some Objective-C classes with C++  
instance variables (the Objective-C things own the C++ things). I  
build with the option GCC_OBJC_CALL_CXX_CDTORS = YES, i.e. run non- 
trivial default constructors and destructors on C++ instance  
variables of Objective-C classes.


As long as I do *not* set the environment variable NSZombieEnabled  
to YES, everything works like this: Constructors of C++ instance  
variables have been called when returning from NSObject's init, and  
destructors have been called when returning from NSObject's dealloc.


But if I do set NSZombieEnabled to YES, then the destructors are  
*not* called anymore (by the way, setting NSDeallocateZombies to  
YES or NO does not make a difference).


It's a loophole in the implementation of NSZombie. Sorry. You might  
be able to use Guard Malloc instead (man libgmalloc); it doesn't  
have that destructor problem.


Thank you for this very useful information.

When debugging with Guard Malloc – and without zombies enabled –, the C 
++ destructors are called again indeed. I'm glad.


But, because the slowdown is remarkable – which I expected, because  
man libgmalloc tells about it –, I will not use this all the time  
during debugging, as I did with zombies enabled previously.


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


C++ instance variables not destructed if NSZombieEnabled

2008-12-22 Thread Klaus Backert
In an application of mine I have some Objective-C classes with C++  
instance variables (the Objective-C things own the C++ things). I  
build with the option GCC_OBJC_CALL_CXX_CDTORS = YES, i.e. run non- 
trivial default constructors and destructors on C++ instance variables  
of Objective-C classes.


As long as I do *not* set the environment variable NSZombieEnabled to  
YES, everything works like this: Constructors of C++ instance  
variables have been called when returning from NSObject's init, and  
destructors have been called when returning from NSObject's dealloc.


But if I do set NSZombieEnabled to YES, then the destructors are *not*  
called anymore (by the way, setting NSDeallocateZombies to YES or NO  
does not make a difference).


I can observe all this with logging and debugging.

Does anybody know, if this is normal behavior, or what else? It looks  
like there is an annoying difference: With zombies enabled, dealloc  
methods of Objective-C are invoked, but destructors of C++ are not  
called.


Mac OS X 10.5.5, Xcode 3.1.2, GCC 4.0, garbage collection off.

Thanks
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


Re: Where is the Computer Image ?

2008-12-16 Thread Klaus Backert


On 16.12.2008, at 17:45, Gerriet M. Denkmann wrote:



On 16 Dec 2008, at 08:43, Brandon Walkin wrote:

The image is in /System/Library/CoreServices/CoreTypes.bundle/ 
Contents/Resources


This works fine:
NSImage *anImage = [ NSImage imageNamed: NSImageNameComputer ];

but how to get an image of a black MacBook? (My computer is white.)

Is hardcoding the name like:
NSImage *anImage = [ [ [ NSImage alloc ] initByReferencingFile: @"/ 
System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/ 
com.apple.macbook-black.icns" ] autorelease ];


really the only solution?
Looks kind of fragile to me.



Well, I don't know why you want a black MacBook image. On my white  
MacBook the correct – white – image is shown, which is just what I  
want. But, as they usually say on these mailing lists, YMMV – young  
man ... no ... your mileage may vary :-))


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


Re: What is the default time for a CALayer transform?

2008-12-16 Thread Klaus Backert


On 16.12.2008, at 15:27, Gustavo Pizano wrote:


Hello Dimitri.

CAAnimation* rotateAnimation = [CABasicAnimation  
animationWithKeyPath:@"transform"];
		rotateAnimation.fromValue = [NSValue  
valueWithCATransform3D:nLayer.transform];
		rotateAnimation.toValue = [NSValue  
valueWithCATransform3D:transform];


its gives me an error, Error request for member "fromValue" in  
something  not a structure  or union.
shouldn't it be CABasicAnimation which has the fromValue and toValue  
properties.?


CAAnimation inherits from NSObject and doesn't have fromValue and  
toValue properties, but CABasicAnimation has (which is derived from  
CAPropertyAnimation, which is derived from CAAnimation).


This would be a good time reading the documentation, I think ;-)

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


Re: Where is the Computer Image ?

2008-12-15 Thread Klaus Backert


On 15.12.2008, at 18:00, Gerriet M. Denkmann wrote:

If the documentation for [NSImage imageNamed:] would have mentioned  
that image names are to be found in the Constants section, this  
would have helped a lot.
But it only says that it will: "Search the Application Kit framework  
for a shared image with the specified name."


The documentation says, the *method* [NSImage imageNamed:] searches,  
among other locations, in the AppKit framework (which is rather  
voluminous). This is not ment for you, I think ;-)


So I looked in the Application Kit framework, but did not find  
anything.


The document says, "declared in NSImage.h", and the constants are  
there. It's often worthwhile to look into the header file.


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


Main menu crash when migrating to Leopard

2008-12-13 Thread Klaus Backert
Being about to migrate a Cocoa document-based application of mine,  
which is under development, from Mac OS X 10.4.11 and Xcode 2.5 to Mac  
OS X 10.5.5 and Xcode 3.1.2 (on a PowerPC G5) the application crashes  
in the phase of – I think – setting up and displaying the main menu.  
This didn't happen before.


Here is an excerpt from the debugger console output ("Blotto" is the  
application's product name):


2008-12-13 12:57:33.701 Blotto[715:813] NSExceptionHandler has  
recorded the following exception:
NSUnknownKeyException -- [< 0x45fdd0>  
setValue:forUndefinedKey:]: this class is not key value coding- 
compliant for the key inputBarExtent.
Stack trace:  0x5cdbc  0x93f1f4ec  0x90d8dabc  0x923a2b40  0x95d54d14   
0x92297734  0x96450620  0x96442d6c  0x9644296c  0x9548c830   
0x9548c210  0x9545ce94  0x2ebc  0x2e5c
2008-12-13 12:57:33.724 Blotto[715:813] [  
exceptionHandler:shouldHandleException:mask:] invoking at /Volumes/C/ 
Development/Projects/Blotto/BloAppDelegate.mm:392
2008-12-13 12:57:33.725 Blotto[715:813] NSExceptionHandler will now  
suspend the current thread and wait for debugger attachment

NSExceptionHandlerExceptionRaiser (in ExceptionHandling) + 208
objc_exception_throw (in libobjc.A.dylib) + 72
-[NSException init] (in CoreFoundation) + 0
-[CIFilter setValue:forUndefinedKey:] (in QuartzCore) + 200
-[NSObject(NSKeyValueCoding) setValue:forKey:] (in Foundation) + 264
-[CIFilter setValue:forKey:] (in QuartzCore) + 308
ResetMenuBarWindowFilter() (in HIToolbox) + 464
ShowBar(unsigned char, unsigned char) (in HIToolbox) + 312
SetSystemUIMode (in HIToolbox) + 284
-[NSApplication finishLaunching] (in AppKit) + 776
-[NSApplication run] (in AppKit) + 100
NSApplicationMain (in AppKit) + 444
main (in Blotto) (main.m:9)
start (in Blotto) + 68
(gdb) continue
2008-12-13 12:57:46.521 Blotto[715:813] [<0xa0411d2c> 0x45fdd0> setValue:forUndefinedKey:]: this class is not  
key value coding-compliant for the key inputBarExtent.

(gdb) continue
2008-12-13 12:57:56.041 Blotto[715:813] An uncaught exception was raised
2008-12-13 12:57:56.042 Blotto[715:813] [<0xa0411d2c> 0x45fdd0> setValue:forUndefinedKey:]: this class is not  
key value coding-compliant for the key inputImage.
2008-12-13 12:57:56.043 Blotto[715:813] [  
exceptionHandler:shouldLogException:mask:] invoking at /Volumes/C/ 
Development/Projects/Blotto/BloAppDelegate.mm:404
2008-12-13 12:57:56.048 Blotto[715:813] NSExceptionHandler has  
recorded the following exception:
NSUnknownKeyException -- [< 0x45fdd0>  
setValue:forUndefinedKey:]: this class is not key value coding- 
compliant for the key inputImage.
Stack trace:  0x90d8de58  0x93f1f4ec  0x90d8dabc  0x923a2b40   
0x95d54d14  0x92297734  0x92297f98  0x95d33bd4  0x9548caac   
0x9548c210  0x9545ce94  0x2ebc  0x2e5c
2008-12-13 12:57:56.063 Blotto[715:813] [  
exceptionHandler:shouldHandleException:mask:] invoking at /Volumes/C/ 
Development/Projects/Blotto/BloAppDelegate.mm:392
2008-12-13 12:57:56.064 Blotto[715:813] NSExceptionHandler will now  
suspend the current thread and wait for debugger attachment

__raiseError (in CoreFoundation) + 188
objc_exception_throw (in libobjc.A.dylib) + 72
-[NSException init] (in CoreFoundation) + 0
-[CIFilter setValue:forUndefinedKey:] (in QuartzCore) + 200
-[NSObject(NSKeyValueCoding) setValue:forKey:] (in Foundation) + 264
-[CIFilter setValue:forKey:] (in QuartzCore) + 308
-[CIFilter dealloc] (in QuartzCore) + 184
NSPopAutoreleasePool (in Foundation) + 520
-[NSApplication finishLaunching] (in AppKit) + 1412
-[NSApplication run] (in AppKit) + 100
NSApplicationMain (in AppKit) + 444
main (in Blotto) (main.m:9)
start (in Blotto) + 68
[Switching to process 715 thread 0x3903]
[Switching to process 715 thread 0x3903]
kill
quit

I realize, that the functions SetSystemUIMode, ShowBar, and  
ResetMenuBarWindowFilter belong to Carbon (I have never done much with  
Carbon). I tried to find something relevant in the local documention  
and with google on the web using a lot of different search criterions,  
but got no useful result.


As one attempt to solve the problem I had deleted the old MainMenu.nib  
from the project, created a completely new MainMenu.xib – xib! –, and  
integrated it into the Xcode project. This didn't help.


Could someone please help?! This is the first time after years, that I  
don't know what to do :-(


Some more information:
- project format: Xcode 3.1 compatible
- architecture: native
- base SDK: Mac OS X 10.5
- compiler: GCC 4.0
- deployment target: Mac OS X 10.5
- garbage collection: off

Thanks in advance
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


Re: Checking One Array Against Another

2008-11-29 Thread Klaus Backert


On 29.11.2008, at 19:30, Pierce Freeman wrote:


Klaus:

For whatever reason, Xcode is telling me that "error: void value not  
ignored
as it ought to be" when I try to make badApplicationsSet a  mutable  
set.


Please. Show. Your. Code.

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 [EMAIL PROTECTED]


Re: Checking One Array Against Another

2008-11-29 Thread Klaus Backert


On 29.11.2008, at 19:00, Pierce Freeman wrote:

The only problem with running that is that I get a error in the log  
and it

doesn't seem to be working:

-[NSCFSet minusSet:]: mutating method sent to immutable object

My slightly modified code is below:

NSMutableSet *openApplicationsSet = [NSSet  
setWithArray:openApplications];


NSSet *allowedApplicationsSet = [NSSet
setWithArray:applicationsAllowedMutableArray];

NSSet *badApplicationsSet = [openApplicationsSet
minusSet:allowedApplicationsSet];


badApplicationsSet is – as NSSet * – NOT mutable here, but you want to  
mutate it – just as the compiler told you: "mutating method sent to  
immutable object".


NSMutableSet * badApplicationsSet = ...


NSLog(badApplicationsSet);


Better, to avoid more crashs, would be:

NSLog(@"badApplicationsSet: %@", badApplicationsSet);

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 [EMAIL PROTECTED]


Re: NSXMLElement -stringValue and whitepsace

2008-11-24 Thread Klaus Backert


Am 24.11.2008 um 02:41 schrieb Keith Blount:

Thanks for trying... It's a shame... I have an OPML importer (no  
export) working based on old code I had found based on  
CFXMLTreeRef, but I was hoping to write an importer/exporter based  
on NSXMLDocument, and this is the one sticking point - everything  
else has been trivial with the NSXMLDocument class. Is this just an  
oddity with the OPML specs, that they allow such whitespace in an  
attributes when XML in general doesn't? Or is it just a limitation  
of NSXMLNode attributes? And does this mean that there is just no  
way of doing it using NSXMLDocument and that I'll have to look for  
a different solution altogether?


It's known in the "XML scene", that there is an eval tendency to use  
attributes too much where nodes were more appropriate. This is a  
failure made by designers of XML data structures, not by the  
designers of XML. Your case may be one of those.


If it's possible anyhow, someone should redesign the structure of the  
XML data your application uses. But it may be – as it is so often –  
that you have to handle this as fixed.


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 [EMAIL PROTECTED]


Re: Autorelease Question

2008-11-20 Thread Klaus Backert


Am 20.11.2008 um 22:04 schrieb Adam Leonard:


Just to clarify:

They probably are identical, but not in the way everyone seems to  
be assuming.


To make sure I don't misrepresent anything, I'll just quote the rule:
"You take ownership of an object if you create it using a method  
whose name begins with "alloc" or "new" or contains "copy" (for  
example, alloc, newObject, or mutableCopy), or if you send it a  
retain message."


Nothing in that rule says or implies that objects you get through  
other methods are autoreleased.


See the Cocoa Fundamentals Guide:

"Class factory methods are implemented by a class as a convenience  
for clients. They combine allocation and initialization in one step  
and return the created object autoreleased. These methods are of the  
form + (type)className... (where className excludes any prefix)."


"autoreleased" !

Because of this the following statements are identical, as far as I  
can see:


NSString *blah = [[[NSString alloc] init] autorelease];
NSString *blah = [NSString string];

Aren't they?

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 [EMAIL PROTECTED]


Re: Xml

2008-11-04 Thread Klaus Backert


Am 04.11.2008 um 17:49 schrieb Gerriet M. Denkmann:







   < new as of today






]>







Looks better, but both problems still persist: "no DTD found!" and  
NSXMLParserNAMERequiredError.


Any ideas?


Kind regards,

Gerriet.



AFAIK the document type declaration needs the name of the root element:



BTW, I think, this has nothing to do with Cocoa-Dev ;-)

Greetings
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 [EMAIL PROTECTED]


Re: Xml

2008-11-03 Thread Klaus Backert


Am 03.11.2008 um 23:09 schrieb Gerriet M. Denkmann:


I do:
NSXMLDocument *xmlDoc = ...
NSData *data = [ xmlDoc XMLDataWithOptions: NSXMLNodePrettyPrint |  
NSXMLNodeCompactEmptyElement ];


This  looks like:









]>








So far so good(?)

When I do [ xmlDoc validateAndReturnError: &error ] I get "no DTD  
found!". Why?


And when I do:
NSXMLParser *parser = [ [ NSXMLParser alloc ] initWithData: data ];
[ parser parse];

I get:
parserDidStartDocument
NSXMLParserErrorDomain 68   = NSXMLParserNAMERequiredError

Obviously I am doing something (or several things) not right. But  
what?



Kind regards

Gerriet.


I'm not sure, if this has to do with the error mentioned above, but  
isn't the vertex element declaration  missing?


Greetings
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 [EMAIL PROTECTED]


Re: How to create a GUID?

2008-09-07 Thread Klaus Backert



- (NSString *)uuid
{
 CFUUIDRef uuidRef = CFUUIDCreate(NULL);
 CFStringRef uuidStringRef = CFUUIDCreateString(NULL, uuidRef);
 CFRelease(uuidRef);
 return [NSMakeCollectable(uuidStringRef) autorelease];
}


the receiver of this -uuid message is a NSString _instance_ – is  
there any reason why this could not be implemented as a class method


+ (NSString *)uuid { /* same as above */ }

or as a free function

NSString * MYuuid() { /* same as above */ }

?

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 [EMAIL PROTECTED]


I don't understand why this is leaking...

2008-08-12 Thread Klaus Backert


Am 12.08.2008 um 19:05 schrieb Jason Coco:


On Aug 12, 2008, at 12:50 , Klaus Backert wrote:


About $Null:


It it were a reserved word, it would be documented so.



The "Archives and Serializations Programming Guide for Cocoa" says:

Keyed Archives
...
Naming Values
...
You should avoid using “$” as a prefix for your keys. The keyed  
archiver and unarchiver use keys prefixed with “$” for internal  
values. Although they test for and mangle user-defined keys that  
have a “$” prefix, this overhead slows down archiving performance.

...


In this case, however, it's the actual value being encoded... not  
the key name. Also, if you read it, it suggests that you shouldn't  
use it for performance reasons. It specifically states that it is  
supposed to properly mangle the $ in a key name (causing the  
performance loss)...


That's right. Sorry, I confused this. But talking about ... I read  
nothing in the documentation what using $-prefixed *keys* for  
internal values *exactly* does. It improves performance, okay, but it  
can be anything else, and a different thing tomorrow. I handle this  
"implementation detail" in the usual way. I will stay away from $- 
prefixed keys.


Back to $-prefixed *values*:

Gerriet Denkmann already realized something – which is not  
documented, as far as I know. A keyed archive contains a $object  
array, and the element $object[0] has the value $null. Implementation  
detail!


I performed a test with my current project. I changed a certain value  
of a string variable to $null, saved it as a keyed archive in binary  
property list format – with the $null value anywhere in the "middle"  
–, opened the saved archive in a new document, and ...


***crash***:

2008-08-12 20:04:58.549 Blotto[24783] NSExceptionHandler has recorded  
the following exception:
NSInvalidArgumentException -- *** -[NSPlaceholderDictionary  
initWithObjects:forKeys:]: number of objects (0) not equal to number  
of keys (21)
Stack trace:  0x966eaf10  0x92c10e0c  0x92c552a0  0x92c18fc8   
0x92bfaea4  0x92bfa688  0x7bd8  0x92bfaea4  0x92bfa688   
0x0001840c  0x000160e8  0x93ac6344  0x00012acc  0x939504a8   
0x00012e20  0x93ac5634  0x9394f960  0x93acc1fc  0x93acc03c   
0x93acbec0  0x938358b4  0x93890094  0x9388fe18  0x9388f8c0   
0x9388f50c  0x93799058  0x93790960  0x93881458  0x4334   
0x3258  0x2f5c  0x1000
2008-08-12 20:04:58.550 Blotto[24783] NSExceptionHandler will now  
suspend the current thread and wait for debugger attachment

_NSExceptionHandlerExceptionRaiser (in ExceptionHandling)
+[NSException raise:format:] (in Foundation)
-[NSDictionary initWithObjects:forKeys:] (in Foundation)
-[NSDictionary initWithCoder:] (in Foundation)
__decodeObjectBinary (in Foundation)
__decodeObject (in Foundation)
-[BloWorld initWithCoder:] (in Blotto)
__decodeObjectBinary (in Foundation)
__decodeObject (in Foundation)
-[BloDocument readPListFromData:error:] (in Blotto)
-[BloDocument readFromData:ofType:error:] (in Blotto)
-[NSDocument readFromFileWrapper:ofType:error:] (in AppKit)
-[YetDocument readFromFileWrapper:ofType:error:] (in Blotto)  
(YetDocument.m:153)

-[NSDocument readFromURL:ofType:error:] (in AppKit)
-[YetDocument readFromURL:ofType:error:] (in Blotto) (YetDocument.m:172)
-[NSDocument _initWithContentsOfURL:ofType:error:] (in AppKit)
-[NSDocument initWithContentsOfURL:ofType:error:] (in AppKit)
-[NSDocumentController makeDocumentWithContentsOfURL:ofType:error:]  
(in AppKit)
-[NSDocumentController openDocumentWithContentsOfURL:display:error:]  
(in AppKit)

-[NSDocumentController openDocument:] (in AppKit)
-[NSApplication sendAction:to:from:] (in AppKit)
-[NSMenu performActionForItemAtIndex:] (in AppKit)
-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] (in  
AppKit)

-[NSMenu performKeyEquivalent:] (in AppKit)
-[NSApplication _handleKeyEquivalent:] (in AppKit)
-[NSApplication sendEvent:] (in AppKit)
-[NSApplication run] (in AppKit)
_NSApplicationMain (in AppKit)
_main (in Blotto) (main.m:10)
__start (in Blotto)
start (in Blotto)
0x1000 (in Blotto)

q.e.d.

Greetings
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 [EMAIL PROTECTED]


I don't understand why this is leaking...

2008-08-12 Thread Klaus Backert

About $Null:


It it were a reserved word, it would be documented so.



The "Archives and Serializations Programming Guide for Cocoa" says:

Keyed Archives
...
Naming Values
...
You should avoid using “$” as a prefix for your keys. The keyed  
archiver and unarchiver use keys prefixed with “$” for internal  
values. Although they test for and mangle user-defined keys that have  
a “$” prefix, this overhead slows down archiving performance.

...

Greetings
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 [EMAIL PROTECTED]


Cocoa et al as HCI usability problem

2008-05-20 Thread Klaus Backert


Am 20.05.2008 um 19:54 schrieb Erik Buck:


I agree completely with Mark Roseman's analysis:


I'm not quite with Mark and Erik.


  1) Too many chioces
The world the software is developed for is complex to such a degree,  
that we need many choices. But don't torture yourself, and apply  
Occam's razor!



  2) Too many concepts
Divide and conquer! Cut a project into pieces small enough, that –  
among other things – the short term memory limits, Mark mentioned,  
aren't a problem any more (object-orientation separates concern; the  
model-view-controller paradigm allows developing model and view  
without having to think about both at the same time; etc., etc.). Of  
course, newbies have to learn this strategy, too – sorry.



  3) Too much housekeeping

Agreed (but it is much better with Cocoa than with Carbon).


  4) Doesn't support everything
Understood and agreed. But I get very far with things out of the box  
and example code, and have more time for the complications afterwards.



  5) Too much hype.

Ignore it!

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 [EMAIL PROTECTED]


releasing NSKeyedUnarchiver causes crash

2008-05-18 Thread Klaus Backert


Am 18.05.2008 um 09:51 schrieb Markus Spoettl:

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName  
error:(NSError **)outError

{
*outError = nil;
NSKeyedUnarchiver *archiver;
archiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:  
data];


// release current data
[tracks release];
tracks = [archiver decodeObjectForKey: @"myobject"];
[tracks retain];


may be because this is missing:

[archiver finishDecoding];


[archiver release]; // <--- crash here, no crash if commented out
return YES;
}


Greetings
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 [EMAIL PROTECTED]


The challenge for Cocoa's on-line documentation

2008-05-17 Thread Klaus Backert


Johnny Lundy wrote:

I never had any problem with a language's documentation since 1970  
with the IBM 360 Reference Manual. That is, until I came across  
Apple's documentation of Cocoa. I have never been so frustrated in  
my life.


- Everything is defined in terms of something else.
- Interface Builder User Guide ignores the dozens of checkboxes and  
popups that appear in the Bindings panes and instead rambles on for  
pages about rarely-used features.
- "Examples" always say "Your code here" when My Code Here is what  
I wanted to see.



The usual pattern for a User Guide & Reference Manual is for the  
User Guide to have chapters corresponding to the areas of the  
product, and the Reference Manual having a page or so listing all  
the details of each element. The Apple docs have neither.


Like this:

- tag
Returns the tag.
See also : setTag

Great. Now if only I knew what a tag was


I search in the documentation window of Xcode and – after 5 to 10  
seconds only – find the explanation.


I have followed these threads, and I have a question to you – without  
intending any insult: Why didn't *you* do this search? (Or did you?  
But then ...) There should be a reason. If you tell the reason here,  
all these experienced and ... ahem ... well ... yes ;-) ... gentle  
people should be able to help you out of *this* – I think: basic –  
problem.


Back to lurking
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 [EMAIL PROTECTED]