Having issues using NSAttribute strings with link Attribute ..

2009-01-19 Thread Arjun SM
Hi all,
i am novice in cocoa so please bear with me ..

I have created an URL link in one my custom applications About box as
described below

NSMutableAttributedString *string =  [[NSMutableAttributedString alloc]
initWithString:@"Cocoa Inc"];

NSRange selectedRange = NSMakeRange(0, 10);
NSURL *linkURL = [NSURL URLWithString:@"http://www.apple.com/";];
[string beginEditing];
[string addAttribute:NSLinkAttributeName
   value:linkURL
   range:selectedRange];
[string addAttribute:NSForegroundColorAttributeName
   value:[NSColor blueColor]
   range:selectedRange];
[string addAttribute:NSUnderlineStyleAttributeName
   value:[NSNumber numberWithInt:NSSingleUnderlineStyle]
   range:selectedRange];
[string endEditing];


I have binded this Attributed string to a Label. I was able to get an URL
link in my About Box, clicking on it will open the browser. But i am facing
a problem with this,

The first time i open the About Box screen i am unable to click on the link.
!!! I have to click on the frame of the Label Once , then the font of the
link will change and  mouse pointer will reform to a hand(clickable)
pointer. !!
How do i fix this problem???

thanks in advance for all the help.
~Arjun
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Having issues using NSAttribute strings with link Attribute ..

2009-01-19 Thread Ron Fleckner


On 19/01/2009, at 9:33 PM, Arjun SM wrote:


Hi all,
i am novice in cocoa so please bear with me ..

I have created an URL link in one my custom applications About box as
described below

NSMutableAttributedString *string =  [[NSMutableAttributedString  
alloc]

initWithString:@"Cocoa Inc"];

NSRange selectedRange = NSMakeRange(0, 10);
NSURL *linkURL = [NSURL URLWithString:@"http://www.apple.com/";];
[string beginEditing];
[string addAttribute:NSLinkAttributeName
  value:linkURL
  range:selectedRange];
[string addAttribute:NSForegroundColorAttributeName
  value:[NSColor blueColor]
  range:selectedRange];
[string addAttribute:NSUnderlineStyleAttributeName
  value:[NSNumber numberWithInt:NSSingleUnderlineStyle]
  range:selectedRange];
[string endEditing];


I have binded this Attributed string to a Label. I was able to get  
an URL
link in my About Box, clicking on it will open the browser. But i am  
facing

a problem with this,

The first time i open the About Box screen i am unable to click on  
the link.
!!! I have to click on the frame of the Label Once , then the font  
of the

link will change and  mouse pointer will reform to a hand(clickable)
pointer. !!
How do i fix this problem???

thanks in advance for all the help.
~Arjun


Hello Arjun,

I'm not sure, but perhaps your problem is related to _when_ you create  
the hyperlink.  I forget where it was suggested, but I think you need  
to create it in your window controller's -windowDidLoad delegate method.


Hope that helps.

Ron

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Graham Cox


On 19 Jan 2009, at 6:49 pm, Kyle Sluder wrote:


Well it sounds like there are a number of issues here:
1) You're throwing exceptions in drawing code.  Even if you catch them
so they don't screw up the draw stack, this will be extremely slow and
have adverse effects on the drawing.



My understanding is that @try is pretty cheap, whereas the @catch is  
not. Since these exceptions are very rare, the @catch block is not  
being called routinely, so I'm hoping that it won't impact performance  
(which is currently swamped by Core Graphics rendering times anyway).



2) You've gotten yourself into a situation in which you're trying to
meaningfully recover from an exception but you have to do it from a
place with outside of the exception's local context.  This is why
Cocoa doesn't use exceptions for general circumstance; they're
notoriously hard to gracefully recover from.


Well, if it means I have to try/catch at every point that I save/ 
restore the graphics context, so be it, that's what I'll have to do.  
But I was hoping I could catch it at some top level and "put things  
right" without this approach being necessary.



Cocoa exceptions are not supposed to be reached in shipped code (which
I'm sure you are aware).  It also sounds like the view state is a
critical component of your app's model.  This sounds like a Very Bad
Idea(TM).


On further investigation, it seems that the majority of the "bad  
state" is caused by the clipping path being set progressively smaller  
as the drawing stack goes deeper. As you can probably visualise, that  
isn't unusual. It means though that if an exception occurs the  
clipping path may be very small when drawRect: returns. On the face of  
it I can't see why that should matter - (the clipping path should be  
mine to do with much as I please with drawRect: as long as I always  
use addClip rather than setClip), in practice this screws up my  
scrollbars and rulers in the enclosing NSScrollView. That in turn must  
be because the scrollview is assuming that the contained view's  
drawRect: will balance all save/restores of the graphics state.




If it's possible to recover from the exception, have you considered
just fixing the situation, obliterating the graphics context, and
redrawing the view?  Perhaps calling -[NSView renewGState] will make
your view usable again.


I hadn't tried renewGState but I have now and it doesn't help. Since  
the gState is always renewed when the view is focused prior to  
drawing, that doesn't surprise me. The effects of the unbalanced  
context stack are felt when exiting drawRect:, not entering it.


What does appear to help a lot is saving the current context at the  
top of the drawing stack and putting it back explicitly at the end (as  
per my previously posted code snippet). If the save/restores are  
balanced, effectively this is a no-op, as I'm putting back the same  
context that I saved. If an exception occurred, the save/restores are  
unbalanced, and this code forces it to balance - thus, the  
NSScrollView is no longer badly screwed up and things can progress  
almost normally.


My question is, is this in any way legal?

In other words, the call stack looks like this:


@try
{
save graphics state
save graphics state
save graphics state
save graphics state
// normally draw stuff, but may throw 
an exception
restore graphics state
restore graphics state
restore graphics state
restore graphics state
}
@catch
{
	// if there was an exception, the context stack is unbalanced - how  
to rebalance it in a legal way before exiting?

}



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


SIGPIPE with sockets

2009-01-19 Thread malcom
Hello guys,
I'm using blackhole netsocket class in an app of mine.
Today I've received a report regarding this error "broken pipe
abnormal exit". I've taken a look a mailing list and it seems to be an
error related to sockets (cannot write, closed before write). Anyone
can tell me how to solve it? What mean cannot write? (or...why it
cannot write?).This is the only report since the beginning (over a
year ago); could it depend from some system settings?
A dev tell me that it just means the other side closed the connection
uncleanly (and it crashed). Is this a problem related to server? can I
fix it?
Thanks a lot
malcom
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Check URL Status

2009-01-19 Thread Mike Abdullah
Create a NSURLConnection for the HD URL. It will receive an  
NSHTTPURLResponse object with -statusCode 404.


Mike.

On 19 Jan 2009, at 01:20, Mr. Gecko wrote:

Hello, I'm trying to find out how I can check a URL status in cocoa.  
I have two links to videos on a server one HD and one SD. sometime  
the HD isn't there and I need my program to check for 404 and if it  
has a 404 it'll revert to SD.


Thanks for tips and or help,
Mr. Gecko
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to cocoa...@mikeabdullah.net


___

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

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

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

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


Re: SIGPIPE with sockets

2009-01-19 Thread Jeremy Pereira


On 19 Jan 2009, at 10:51, malcom wrote:


Hello guys,
I'm using blackhole netsocket class in an app of mine.
Today I've received a report regarding this error "broken pipe
abnormal exit". I've taken a look a mailing list and it seems to be an
error related to sockets (cannot write, closed before write). Anyone
can tell me how to solve it? What mean cannot write? (or...why it
cannot write?).This is the only report since the beginning (over a
year ago); could it depend from some system settings?

A dev tell me that it just means the other side closed the connection
uncleanly (and it crashed). Is this a problem related to server? can I
fix it?


I don't know about "uncleanly", but yes, the reading end of the  
connection was closed and your program tried to write to it.


Your socket library is probably using either the write or the send  
system calls at the bottom level.  According to the man page for  
write(2) (type "man 2 write" on a command line) says that the write  
call should return the EPIPE error.  The man page for send(2) says the  
same, but also that SIGPIPE is generated (which will terminate the app).


If SIGPIPE is generated, you will need to install a signal handler to  
stop the app from crashing, or perhaps just ignore it.  In this  
situation, the write/send system call may return EINTR instead of EPIPE.




Thanks a lot
malcom
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

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

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

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

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


Re: Yo

2009-01-19 Thread Scott Anguish


On 18-Jan-09, at 10:42 AM, Scott Ribe wrote:

Hmm, seems like I might have hit the nail on the head, I just  
received

a delightfully abusive email from this character offlist. I've
notified the admins.


Since the mods seem to be missing for the weekend (imagine that!)  
let me

just point out that they unsubscribed this guy a week or so ago (and
received abusive email for it). Weird that he would re-sub under the  
same

name, but whatever...


No, I was here.. and he's moderated again.




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: CALayer removeFromSupeLayer crashes

2009-01-19 Thread Dennis Christopher

Men,

I was to find an over-release of the layer's delegate object using  
Instruments. Removing this solved the crash. Thanks for all your  
suggestions.


Dennis Christopher
On Jan 10, 2009, at 12:43 PM, David Duncan wrote:


On Jan 9, 2009, at 12:19 PM, Dennis Christopher wrote:


NSArray *theLayers = [[self layer] sublayers];
for(CALayer *layer in sublayers) {
  [layer removeFromSuperlayer];

I'm new to CALayer and at a loss as to what could be wrong with this.
Any suggestions would be appreciated.
(I've read  through most of Dudney's Core Animation book but nothing
jumps out at me.)



I would suspect that you'd see a message on the console to the effect
of "modifying an array while enumerating it". I think you can replace
this more simply by just doing [[self layer] setSublayers:nil].
--
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: [NOOB] Finding Information (was: real noob question)

2009-01-19 Thread julius


On 19 Jan 2009, at 00:21, Stuart Malin  wrote:

On Jan 18, 2009, at 1:06 AM, Rob Keniger wrote:


On 18/01/2009, at 11:18 AM, Darren Stuart wrote:


Hi there, sorry for the real noobish question but I can't figure
this out or find an answer.

I have a variable called myMoney and its a NSDecimalNumber and I
want to set init it with the value of 23.30.

NSDecimalNumber *myMoney =  [[NSDecimalNumber alloc] init];

If this is the wrong place to post this sort of question please can
someone point to such a place.

Kind Regards

Darren


You can't find an answer - have you had a look at the documentation?
It's right there.

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSDecimalNumber_Class/Reference/Reference.html


Sometimes to the newbie it may seem astounding that experienced Cocoa
programmers can snap back with specific references. These are not
really that difficult to find. Might I suggest an address to keep in
mind for searching for information:

http://developer.apple.com/cocoa

Then use the search box in the upper right.

In regard to the OP's query, I entered "creating a decimal number"
The lead result is the NSDecimalNumberHandler Class Reference, as a
PDF, as documented for iPhone, and as having the link Rob reported
above.


I too followed up on the example link which took me to the top of the  
NSDecimalNumber Class reference document. Scrolling down the first  
thing I came accross under Tasks was "Creating a Decimal Number" and  
just beneath that a link to

+ decimalNumberWithDecimal:
which looked exactly like what the OP was asking for, viz:
<>
Creates and returns an NSDecimalNumber object equivalent to a given  
NSDecimal structure.

+ (NSDecimalNumber *)decimalNumberWithDecimal:(NSDecimal)decimal>


Ah, and look perhaps I don't need to use an alloc
Now with all respect to the writers of this documentation, my first  
question is "what is a decimal structure?". Now I think I know what a  
"decimal structure" might be,  namely a number written using the  
decimal notation - is that with or without decimal points?

I followed up on  NSDecimal and obtained:
<>
NSDecimal
Used to describe a decimal number.
typedef struct {
   signed int _exponent:8;
   unsigned int _length:4;
   unsigned int _isNegative:1;
   unsigned int _isCompact:1;
   unsigned int _reserved:18;
   unsigned short _mantissa[NSDecimalMaxSize];
} NSDecimal;


Scareee and nothing like what I thought it might be.
Of course, I should have seen the bracketed NSDecimal in front of the  
"decimal" alerting me to the fact that this was either a cocoa object  
or C struct, and hence the use of the word "structure". Indeed the  
very use of an unsusual word like structure should have alerted me to  
the fact that this was not an english language construct that was  
being denoted but rather a "data structure" or more accurately a  
struct data type. But as you can see, even after a year and a half of  
looking through this documentation I am still able to make basic  
mistakes in literacy. I have had reason to think about this quite  
frequently and have come to the conclusion that there is nothing  
simple or straightforward about writing easy to use technical manuals.  
One of the main problems it seems to me occurs when I'm trying to get  
quickly to an answer and rather than read and digest every word of the  
manual (how many hours might that take?) I scan looking for key words  
that I hope will take me in the desired direction. It often seems to  
me that we fail to take human psychology sufficiently into account  
when designing such documents And somewhere in all that searching  
through a manual I think we can get waylaid by phoenomena not unlike  
those relating to "inattentional blindness" or "change blindness". For  
instance take a look at this video to see just how fragile is our  
ability to attend.


http://www.youtube.com/watch?v=voAntzB7EwE&eurl

and the set of videos here
http://viscog.beckman.uiuc.edu/djs_lab/demos.html

with discussions of the phenomena here
http://www.skepdic.com/inattentionalblindness.html
http://www.skepdic.com/changeblindness.html

and of the unwelcome effects of this in the inspection of complex  
systems

http://www.inspect-ny.com/vision/vision.htm

O.K. lets leave that and go back to  see if we can find something that  
looks a bit more like the OP's number : 23.30.


The next heading beneath "Creating a Decimal Number" is "Initializing  
a Decimal Number" and head of the list is

<>
– initWithDecimal:


That looks promising.. but
<>
initWithDecimal:
Returns an NSDecimalNumber object initialized to represent a given  
decimal.

- (id)initWithDecimal:(NSDecimal)decimal>


No good: there's that NSDecimal again, but note that this time it is  
not described as a structure but as a "decimal" 

Back to the top of the list:
<>
Initializing a Decimal Number
* – initWithDecimal:
* – initWithMantissa:exponent:isNegative:
* – initWithStr

Re: bindings and sub array modification notification.

2009-01-19 Thread Sandro Noel

mmalc.

after looking at the example page you sent me it gave me some answers  
about

controllers that I was getting ready to ask, so thank you!

Sandro Noel.

On 18-Jan-09, at 8:36 PM, mmalc Crawford wrote:



On Jan 18, 2009, at 5:02 PM, Sandro Noel wrote:

How could I possibly observe the changes in the information array  
or each host element?





mmalc



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: .DMG Keeps Getting Bigger After Converting?

2009-01-19 Thread Alastair Houghton

On 17 Jan 2009, at 21:02, Markus Spoettl wrote:

Totally agreed, scripting the entire process would be wonderful.  
But: How does one go about scripting a template DMG creation that  
should open in a certain view mode in Finder (e.g. icon) using a  
defined icon size and defined icon locations, background image, in a  
new window with a certain initial window size?


You *can* use AppleScript and shell script to do what you need here.   
The only problem is that you need to run the script from a window  
session, which may be an issue if you have some kind of build server.


We have a rather substantial chunk of AppleScript that I wrote for  
exactly this purpose, which is called from some shell scripts we use.   
Of course, we have the additional problem of needing to build bootable  
CDs, so our set-up is rather more complicated than it need be for most  
people.


If you need more information on this topic, this probably isn't the  
right list.  But you might start by looking at the man pages for  
"hdiutil" and "osascript" and the Finder's Application Dictionary (in  
Script Editor, or better yet, Script Debugger).


Alternatively, as someone else suggested, there are some third-party  
apps that you can use for this exact purpose, which will be much  
easier if they support what you need.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

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

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

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

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


Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys

2009-01-19 Thread Eric Gorr


On Jan 16, 2009, at 5:12 PM, Corbin Dunn wrote:



On Jan 16, 2009, at 11:34 AM, Eric Gorr wrote:


Note that for my custom cell class I have:

+ (BOOL)prefersTrackingUntilMouseUp {
// NSCell returns NO for this by default.
// If you want to have trackMouse:inRect:ofView:untilMouseUp:
// always track until the mouse is up, then you MUST return YES.
// Otherwise, strange things will happen.
  return YES;
}



This is what tableview passes to untilMouseUp: in trackMouse:..


which I need for normal mouse clicks when when shift or cmd key is  
not down. But I am not sure if this would be the cause of the  
problem or not...just something to note for the moment.



What I think is happening is that when I call [super  
mouseDown:theEvent], it consumes the mouseUp event. As such, when  
my custom tracking occurs, there is no mouseUp event for it to  
process.


While I might be able to place the call to [super  
mouseDown:theEvent] below my custom tracking code, it is unclear  
this would work as [super mouseDown:theEvent] needs an equal chance  
to process events and my trackMouse code can consume events and not  
tell anyone, when the shift or cmd key is pressed, that [super  
mouseDown:theEvent] needs to know about to execute correctly.



You are right -- super is consuming the mouse up. I think you'll  
have to call it later.


Unfortunately, calling it after my custom tracking code doesn't appear  
to work out-of-the-box.


The problem appears to be that my trackMouse code consumes the mouseUp  
event and that is preventing [super mouseDown:theEvent] from  
terminating.


One possible solution is to add a method to my custom cell class to  
set a flag which tells the trackMouse method that it was being called  
due to the shift or cmd key being held down. And, when this is the  
case, I don't dequeue the mouseUP event...calling NSApp's  
nextEventMatchingMask instead of NSWindow's, which was originally  
suggested.


theEvent = [NSApp nextEventMatchingMask:(NSLeftMouseUpMask |  
NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)
  untilDate:[NSDate  
dateWithTimeIntervalSinceNow:20]

 inMode:NSEventTrackingRunLoopMode
dequeue:shouldDequeue];

This seems a bit hackish and am thinking there would be a better  
solution.


The disadvantage is that you'll have to handle selection yourself,  
which can be difficult with anchored selections.


Well, I knew I was going to handle selection myself since I need  
entirely custom selection and I've written such code before, so I'm  
not concerned about that.


Maybe you can just override the left/right arrows to do sub- 
selection in your cell. For instance, image results in Tiger's  
Spotlight help results did this. It didn't allow alt/cmd multi-select.


Unfortunately, I must implement the standard shift & cmd selection  
functionality.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: SIGPIPE with sockets

2009-01-19 Thread Scott Ribe
Any decent library probably ought to set up the socket to not throw the
signal, like so:

err = setsockopt( mSocket, SOL_SOCKET, SO_NOSIGPIPE, &flg, sizeof flg );

So that the library can return the error EPIPE and let the application deal
gracefully with the condition without having to muck around with signal
handlers.

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


___

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

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

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

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


Re: Cocoa and the need for a dynamic language

2009-01-19 Thread Sean McBride
On 1/17/09 9:51 PM, Erik Buck said:

>As far as I know, there is still no compiler in
>the world that completely implements the ANSI/ISO C++ standard which
>was ratified in 1998.  If the standard hasn't been implemented in a
>decade, something is amiss.

I agree C++ is an overly complex beast... but then I got to thinking, is
there a compiler that fully implements C99?  MS's doesn't, neither does gcc:


--

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


___

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

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

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

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


Re: Cocoa and the need for a dynamic language

2009-01-19 Thread Robert Claeson


On 19 Jan 2009, at 15:41, Sean McBride wrote:


On 1/17/09 9:51 PM, Erik Buck said:


As far as I know, there is still no compiler in
the world that completely implements the ANSI/ISO C++ standard which
was ratified in 1998.  If the standard hasn't been implemented in a
decade, something is amiss.


I agree C++ is an overly complex beast... but then I got to  
thinking, is
there a compiler that fully implements C99?  MS's doesn't, neither  
does gcc:




I'm not sure, but I think that Sun's compiler does it.

___

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

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

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

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


Re: [NOOB] Finding Information (was: real noob question)

2009-01-19 Thread mmalc Crawford


On Jan 19, 2009, at 6:10 AM, julius wrote:

I too followed up on the example link which took me to the top of  
the NSDecimalNumber Class reference document. Scrolling down the  
first thing I came accross under Tasks was "Creating a Decimal  
Number" and just beneath that a link to

+ decimalNumberWithDecimal:
which looked exactly like what the OP was asking for, viz:
<>
Creates and returns an NSDecimalNumber object equivalent to a given  
NSDecimal structure.

+ (NSDecimalNumber *)decimalNumberWithDecimal:(NSDecimal)decimal>

Ah, and look perhaps I don't need to use an alloc
Now with all respect to the writers of this documentation, my first  
question is "what is a decimal structure?".


Typically here I would either click the link to NSDecimal in the  
method declaration, or go to the Companion Guide listed at the top of  
the API reference.

Or ... (see below)


I followed up on  NSDecimal and obtained:
[...]
Scareee and nothing like what I thought it might be.



So either back to NSDecimalNumber, or to the Companion Guide.

I have had reason to think about this quite frequently and have come  
to the conclusion that there is nothing simple or straightforward  
about writing easy to use technical manuals.




Indeed.


One of the main problems it seems to me occurs when I'm trying to  
get quickly to an answer and rather than read and digest every word  
of the manual




I have had reason to think about this quite frequently and have come  
to the conclusion that, when documentation is written, it should be  
padded with extraneous words and phrases that readers can safely ignore.



O.K. lets leave that and go back to  see if we can find something  
that looks a bit more like the OP's number : 23.30.
The next heading beneath "Creating a Decimal Number" is  
"Initializing a Decimal Number" and head of the list is

<>
– initWithDecimal:

That looks promising.. but
<>
initWithDecimal:
Returns an NSDecimalNumber object initialized to represent a given  
decimal.

- (id)initWithDecimal:(NSDecimal)decimal>


No good: there's that NSDecimal again, but note that this time it is  
not described as a structure but as a "decimal" 

Back to the top of the list:
<>
Initializing a Decimal Number
   * – initWithDecimal:
   * – initWithMantissa:exponent:isNegative:
   * – initWithString:
   * – initWithString:locale:


But there is nothing here that looks anything like it would allow me  
to intialise with a numeric value like 23.30.



It's not clear why, throughout, you have ignored:
(a) initWithMantissa:exponent:isNegative:
(b) "Inherits from NSNumber : NSValue : NSObject"

In this case, (b) might have actually lead you astray(*), but it  
should have been in your search path.


(*) 
(You did search the archives as well, didn't you?)



I'll stop here.


Why?
At this stage, although you should actually have found an answer, you  
should have at least looked at the Companion Guide and if that didn't  
address the issue you should have sent in feedback using either the  
form at the bottom of each documentation page or using Radar.



My point is that learning a system via the manual is not the easiest  
thing in the world and just pointing people at specific pages in the  
manual though helpful is not always necessarily the best way of  
doing things.


Looking at just the API reference pages is typically as useful a way  
to learn about Cocoa as using a dictionary to learn a foreign  
language.  If you want to learn about how methods etc. are used in  
context, then turn to the Companion Guides.



One of those imponderable mysteries I guess. But someone must have  
thought it worthwhile so why not say so in the documentation?


All the references to Companion Guide above notwithstanding, as it  
happens, this isn't well addressed in the Guide.  Please either send  
feedback or file a Radar () to have this  
addressed.


mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: .DMG Keeps Getting Bigger After Converting?

2009-01-19 Thread Chunk 1978
i'm really a big fan of DMG Canvas, and i'm surprised the developer is
offering it as donationware, but unfortunately i can't use it... there
seems to be a bug that will automatically set off "internet enabled"
option (even if it's unchecked) when the .DMG is downloaded from my
server, and there's no point in designing a .DMG window, etc., if it's
just going to skip that step and download the files to the user's
downloads folder.

i'm actually curious to know if that's a problem with my server (or
computer) or if everyone else has the same experience with this
software.

On Mon, Jan 19, 2009 at 10:12 AM, Alastair Houghton
 wrote:
> On 17 Jan 2009, at 21:02, Markus Spoettl wrote:
>
>> Totally agreed, scripting the entire process would be wonderful. But: How
>> does one go about scripting a template DMG creation that should open in a
>> certain view mode in Finder (e.g. icon) using a defined icon size and
>> defined icon locations, background image, in a new window with a certain
>> initial window size?
>
> You *can* use AppleScript and shell script to do what you need here.  The
> only problem is that you need to run the script from a window session, which
> may be an issue if you have some kind of build server.
>
> We have a rather substantial chunk of AppleScript that I wrote for exactly
> this purpose, which is called from some shell scripts we use.  Of course, we
> have the additional problem of needing to build bootable CDs, so our set-up
> is rather more complicated than it need be for most people.
>
> If you need more information on this topic, this probably isn't the right
> list.  But you might start by looking at the man pages for "hdiutil" and
> "osascript" and the Finder's Application Dictionary (in Script Editor, or
> better yet, Script Debugger).
>
> Alternatively, as someone else suggested, there are some third-party apps
> that you can use for this exact purpose, which will be much easier if they
> support what you need.
>
> Kind regards,
>
> Alastair.
>
> --
> http://alastairs-place.net
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/chunk1978%40gmail.com
>
> This email sent to chunk1...@gmail.com
>
___

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

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

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

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


Re: File association

2009-01-19 Thread Sean McBride
On 1/19/09 10:19 AM, Mahaboob said:

>Sorry for the late reply.
>When I'm trying like that I got the result as
>kMDItemContentType = "dyn.ah62d4rv4ge81a6xu"
>
>I didn't understand anything from this.

That's a 'dynamic UTI', you can google it.  And if you try the same for
other extensions?

Maybe dump your LS database, and look for other apps that clain your
extension:

/System/Library/Frameworks/CoreServices.framework/Frameworks/
LaunchServices.framework/Support/lsregister -dump > ~/lsdump.txt

--

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: Memory allocation issues with NSObject and NSString

2009-01-19 Thread Michael Ash
On Mon, Jan 19, 2009 at 2:36 AM, Bill Bumgarner  wrote:
> On Jan 18, 2009, at 9:05 PM, Michael Ash wrote:
>>>
>>> For now.  Someday, that might change.
>>
>> I sure hope not! The documentation for the method states:
>>
>> "The init method defined in the NSObject class does no initialization;
>> it simply returns self."
>>
>> Making it do anything else would be a serious breach of the API contract.
>>
>> However I strongly advocate calling it anyway, as it makes your code
>> more robust if you change the superclass later on to something that
>> really does do something in init.
>
> Exactly
>
> I didn't say *who* might change it!
>
> It is quite common to
>
> - create a subclass of NSObject
>
> - create another subclass of NSObject
>
> - realize that A and B have a bit in common...
>
> - ... and create a common superclass from which A and B can share
> functionality
>
> By following the rules with consistency throughout your code, you minimize
> the pain of maintenance and transmogrification over time.

That's sensible, then. I thought you meant that the implementation of
-[NSObject init] might change someday.

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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Michael Ash
On Mon, Jan 19, 2009 at 6:07 AM, Graham Cox  wrote:
> What does appear to help a lot is saving the current context at the top of
> the drawing stack and putting it back explicitly at the end (as per my
> previously posted code snippet). If the save/restores are balanced,
> effectively this is a no-op, as I'm putting back the same context that I
> saved. If an exception occurred, the save/restores are unbalanced, and this
> code forces it to balance - thus, the NSScrollView is no longer badly
> screwed up and things can progress almost normally.
>
> My question is, is this in any way legal?
>
> In other words, the call stack looks like this:
>
>
> @try
> {
>save graphics state
>save graphics state
>save graphics state
>save graphics state
>// normally draw stuff, but may throw
> an exception
>restore graphics state
>restore graphics state
>restore graphics state
>restore graphics state
> }
> @catch
> {
>// if there was an exception, the context stack is unbalanced - how
> to rebalance it in a legal way before exiting?
> }

How about wrapping save/restore in a macro, and expanding them to use
@try/@finally? For example:

#define SAVE_GSTATE @try { [NSGraphicsContext saveGraphicsState];
#define RESTORE_GSTATE } @finally { [NSGraphicsContext restoreGraphicsState]; }

Then use those everywhere instead of the raw calls.

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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Paul Bruneau

On Jan 19, 2009, at 2:49 AM, Kyle Sluder wrote:


3) You've over-architected your drawing code.  Typically the fewer
objects that are responsible for drawing (i.e. view objects) the
better.  Situations like the one you're describing often arise from
making model objects responsible for their own drawing.


I was a little disappointed that Graham didn't address this point.

I'm confused by it, since I have been directed in the past by people  
who know that The Cocoa Way is to have objects know how to draw  
themselves--via a category if desired.


Is there differing opinion on this? (apparently there is...)

I am going to be starting a large app that will have many assemblies  
and sub-assemblies that I want to draw. I had planned on the objects  
drawing themselves. Should I revisit my thinking?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Shawn Erickson
On Mon, Jan 19, 2009 at 9:57 AM, Paul Bruneau
 wrote:
> On Jan 19, 2009, at 2:49 AM, Kyle Sluder wrote:
>
>> 3) You've over-architected your drawing code.  Typically the fewer
>> objects that are responsible for drawing (i.e. view objects) the
>> better.  Situations like the one you're describing often arise from
>> making model objects responsible for their own drawing.
>
> I was a little disappointed that Graham didn't address this point.
>
> I'm confused by it, since I have been directed in the past by people who
> know that The Cocoa Way is to have objects know how to draw themselves--via
> a category if desired.

I think the point that was trying to made is that you should do all
the heavy lifting out side of drawRect: and the only work that takes
place in drawRect: is just what needs to take place to render that
object. In other words process your data outside of drawRect:, create
what objects are needed outside of drawRect:, deal with failures
outside of drawRect:, distill what needs to be distilled outside of
drawRect: and in drawRect: just draw.

IMHO objects that can draw themselves should be NSCell sub-classes or
NSView sub-classes (possibly using some primitive drawing rendering
support from NSImage, NSString, etc.) and not some model object that
has drawing code tacked onto it. These view classes should be told or
be able to ask for the data they need to use at render time, ideally
pre-prepared / pre-fetched as makes sense.

-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: Dealing with exceptions in a drawing stack

2009-01-19 Thread I. Savant

On Jan 19, 2009, at 12:57 PM, Paul Bruneau wrote:

I'm confused by it, since I have been directed in the past by people  
who know that The Cocoa Way is to have objects know how to draw  
themselves--via a category if desired.


Is there differing opinion on this? (apparently there is...)

  This is tough to generalize. There is not only differing opinion,  
but also plenty of room for debate. :-)


  In the Sketch example, there are different shapes (including  
"text"), each of which handles drawing somewhat differently. I suspect  
the decision not to put this into the canvas view is more a matter of  
organization than architecture. I happen to agree with the decision.


  There's nothing about the MVC design pattern that demands all  
drawing code belongs in the view. In the particular case of a drawing  
application where the shapes to be drawn *are* the data model, how to  
draw a shape could be viewed as "business logic" for the model.


  For the organizational argument, having a single view that includes  
the logic to draw every kind of shape (including those added in the  
future) seems messy and difficult to read / maintain. Stepping aside  
from API architecture and design patterns, we would logically expect a  
shape to be responsible for knowing how to represent itself. After  
all, the canvas merely hosts the shapes (however they're drawn) and  
provides UI interaction to manipulate them.


  I'll remind everyone to consider my opening statement (hard to  
generalize) if it seems like I'm contradicting myself. :-)



I am going to be starting a large app that will have many assemblies  
and sub-assemblies that I want to draw. I had planned on the objects  
drawing themselves. Should I revisit my thinking?


  If the assemblies and sub-assemblies are all homogenous (in that  
they all look more or less the same), I'd say yes, you should  
reconsider the Sketch-like approach.


  For an extremely over-simplified example, consider a view that  
draws many labels. The shape, color, font, etc. of the labels are all  
the same; merely the text is different. In that case, I'd have the  
view be 100% responsible for all drawing.


  Just my opinion, not an edict. :-)

--
I.S.


___

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

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

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

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


Re: CALayer unwanted blurring

2009-01-19 Thread David Duncan

On Jan 17, 2009, at 4:30 PM, Joe Wildish wrote:

Anyway, I did find a post on this list that mentions a similar  
problem (http://www.cocoabuilder.com/archive/message/cocoa/2008/12/13/225352 
). However, in my case I am not applying any transforms to the layer  
hierarchy, and I am also ensuring that the frame origin of each  
object is drawn at a "whole number" point (both of these things are  
mentioned as potential causes in that thread).



Your suffering from the same problem as above. The frame origin is not  
what matters, but rather the layer's position (all aspects of the  
frame are synthesized from other properties of the layer). Depending  
on if your layer's dimensions are odd or even the position should be  
on the pixel or on the half pixel to avoid antialiasing like this.

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


Cursor updates - bug or programmer ignorance?

2009-01-19 Thread Luke Evans
I was surprised by some cursor behaviour and whittled down the  
following code (the only code in an NSTableView subclass):


- (void)updateTrackingAreas {
NSLog(@"Tracking update");
for (NSTrackingArea *area in [self trackingAreas]) {
if ([area owner] == self) {
[self removeTrackingArea:area];
}
}
	//NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[self  
bounds] options:NSTrackingCursorUpdate | NSTrackingActiveAlways  
owner:self userInfo:nil];
	NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[self  
bounds] options:NSTrackingCursorUpdate | NSTrackingActiveInActiveApp  
owner:self userInfo:nil];

[self addTrackingArea:area];
}

- (void)cursorUpdate:(NSEvent *)event {
[[NSCursor openHandCursor] set];
NSLog(@"Cursor updated");
}

This code correctly sets the cursor to the open hand cursor when the  
mouse is moved over the table view.  I tried both  
NSTrackingActiveAlways and NSTrackingActiveInActiveApp because of some  
note in the docs that talks about the interaction of  
NSTrackingCursorUpdate and NSTrackingActiveAlways - but the behaviour  
here is the same.


The odd behaviour is that the cursor is reset back to the regular  
arrowCursor after a few seconds, with the cursor still over the view.   
At this point I don't know 'who' is doing this or why; nor how to stop  
it.


The -updateTrackingAreas method is called exactly once in my simple  
test (I wondered if some change in the state of the tracking areas  
would reset the cursor state - but evidently it's not as simple as  
that).


There's a good chance that I'm displaying continued ignorance of Cocoa  
- but I've been through the docs several times for clues without  
enlightenment.  Surely the system should be able to change the cursor  
on you without giving you a chance to reassert the cursor you want  
(even if it does this on some kind of timer to avoid stale cursor  
states from poorly written application code - or whatever).


Is there a parallel mechanism to the tracking areas here that I should  
also be interacting with to ensure that my cursor stays set the way I  
want it?


Cheers

-- Luke




___

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

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

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

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


"Cocoa Fundamentals Guide" Clarification

2009-01-19 Thread Mohan Parthasarathy
Hi,

I am reading the section "Functions, Constants and Other C Types", in the
Cocoa Fundamentals Guide (
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/chapter_2_section_2.html)
and a little confused about the wording in this section.


The following list offers some guidance on using C types in the definition
of a custom class:
 ■ Define a function rather than a method for functionality that is often
requested but doesn't need to be
overridden by subclasses. The reason for doing this is performance. In these
cases, it's best for the function
to be private rather then being part of the class API. You can also
implement functions for behavior that
is not associated with any class (because it is global) or for operations on
simple types (C primitives or
structures). However, for global functionality it might be better―for
reasons of extensibility―to create
a class from which a singleton instance is generated.

I am slowly getting to speed on Objective C and Cocoa programming. I have
written a few classes and is all written completely in objective C. In the
classes that i have written i realize that i have a init method and at most
two other methods that are used by other objects. But there are other
methods in the classes that are mostly private i.e not used by other objects
(i relaize that all methods defined in the .h file are public). I have not
yet subclassed my own classes just the system provided classes.

Does the word private in the guide refers to the same meaning as "interfaces
that are solely used within a class and not used/extended by other "classes"
? Do i have to really care about this while writing my code or just ignore
and write everything in objective C ? If i have a  chunk of code written in
"C" that i want to reuse, i guess i can do that if it is not too much of a
pain to convert to objective C. But then the word "performance" is a little
confusing in the above paragraph. Sorry, if i am reading it too
literally..Any clarification would be appreciated..

thanks
mohan
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Quincey Morris

On Jan 19, 2009, at 10:16, Shawn Erickson wrote:


On Mon, Jan 19, 2009 at 9:57 AM, Paul Bruneau
 wrote:

On Jan 19, 2009, at 2:49 AM, Kyle Sluder wrote:


3) You've over-architected your drawing code.  Typically the fewer
objects that are responsible for drawing (i.e. view objects) the
better.  Situations like the one you're describing often arise from
making model objects responsible for their own drawing.


I was a little disappointed that Graham didn't address this point.

I'm confused by it, since I have been directed in the past by  
people who
know that The Cocoa Way is to have objects know how to draw  
themselves--via

a category if desired.


I think the point that was trying to made is that you should do all
the heavy lifting out side of drawRect: and the only work that takes
place in drawRect: is just what needs to take place to render that
object. In other words process your data outside of drawRect:, create
what objects are needed outside of drawRect:, deal with failures
outside of drawRect:, distill what needs to be distilled outside of
drawRect: and in drawRect: just draw.


I don't get this at all (not just the quoted comments, but going all  
the way back to Graham's original statement).


-- If a failure in the drawing code destroys the *data model* (thereby  
preventing it from being saved) then there's something terribly wrong  
with the drawing code's design. (Surely, being *drawing* code it only  
needs read-only access to the data model. Or, if it has drawing- 
related status to update in the data model, it shouldn't be making  
structural alterations to the data model whose failure could leave the  
model in an un-savable state.)


In this case, the location of the drawing is irrelevant. Its design is  
dangerous to the data model no matter where it's implemented.


-- If a failure in the drawing code doesn't hurt the data model, but  
leads to an unending cascade of exceptions from the inconsistent  
drawing state, then the problem is more about suppressing exceptions  
so that the document can be saved before the application crashes.


In this case, the location of the drawing is irrelevant. The data  
model is safe no matter where the drawing is implemented.


So why are we discussing whether model objects should draw themselves?

IMO, the issue is (at least initially) a matter of documentation. The  
NSGraphicsContext class reference is ambiguous and incomplete -- it's  
not clear whether the current context is saved *in* each state on the  
state stack, or whether the state stack is *in* the current context,  
or whether the state *is* the context. There's apparently a  
setGraphicsState: method which *looks* like it might be what Graham  
needs to set things back to a known state, but the parameter to this  
method isn't documented anywhere I could find.


The header file is no help at all. The comments refer to save/restore  
*context* methods (as opposed to save/restore *state* methods) which  
apparently don't exist anywhere.


If the documentation was clear, I think Graham's strategy for dealing  
with exceptions would also become clear.


FWIW. (Excuse the rant, please.)

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Paul Bruneau

On Jan 19, 2009, at 2:08 PM, Quincey Morris wrote:

I don't get this at all (not just the quoted comments, but going all  
the way back to Graham's original statement).


-- If a failure in the drawing code destroys the *data model*  
(thereby preventing it from being saved) then there's something  
terribly wrong with the drawing code's design. (Surely, being  
*drawing* code it only needs read-only access to the data model. Or,  
if it has drawing-related status to update in the data model, it  
shouldn't be making structural alterations to the data model whose  
failure could leave the model in an un-savable state.)


In this case, the location of the drawing is irrelevant. Its design  
is dangerous to the data model no matter where it's implemented.


-- If a failure in the drawing code doesn't hurt the data model, but  
leads to an unending cascade of exceptions from the inconsistent  
drawing state, then the problem is more about suppressing exceptions  
so that the document can be saved before the application crashes.


I assumed that Graham meant that if his user is creating stuff, then  
during a draw the graphics get hosed to the point where the user can't  
save, he will lose the data that he as created in that session.


When I worked in graphics, this type of problem was all too common in  
Illustrator 5.0 I can assure you.

___

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

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

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

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


Re: Cursor updates - bug or programmer ignorance?

2009-01-19 Thread Quincey Morris

On Jan 19, 2009, at 11:00, Luke Evans wrote:

The odd behaviour is that the cursor is reset back to the regular  
arrowCursor after a few seconds, with the cursor still over the  
view.  At this point I don't know 'who' is doing this or why; nor  
how to stop it.


The -updateTrackingAreas method is called exactly once in my simple  
test (I wondered if some change in the state of the tracking areas  
would reset the cursor state - but evidently it's not as simple as  
that).


There's a good chance that I'm displaying continued ignorance of  
Cocoa - but I've been through the docs several times for clues  
without enlightenment. Surely the system should be able to change  
the cursor on you without giving you a chance to reassert the cursor  
you want (even if it does this on some kind of timer to avoid stale  
cursor states from poorly written application code - or whatever).


Is there a parallel mechanism to the tracking areas here that I  
should also be interacting with to ensure that my cursor stays set  
the way I want it?


It's poorly documented, but a NSScrollView (or perhaps its NSClipView)  
will sometimes reset the cursor, and your NSTableView is of course  
embedded in a NSScrollView. However, I've only seen it change the  
cursor like this when the mouse is down (e.g. autoscrolling or  
interacting with the scroll bars).


If you're only seeing the problem while the mouse is down, you can  
call [NSScrollView setDocumentCursor: [NSCursor openHandCursor]] on  
mouseDown, and set it back to the standard cursor on mouseUp.


There's also an easy experiment you can try. In your subclass  
initialization, call [NSScrollView setDocumentCursor:] with an easily  
recognizable cursor that you don't otherwise use. Then if your problem  
is NSScrollView's fault, the cursor will switch to that cursor instead  
of the arrow.


HTH


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Fundamentals Guide" Clarification

2009-01-19 Thread Mike Abdullah
Just write your code in Obj-C. When you have a finished application,  
then start profiling performance. If this shows that calling some  
methods is slowing things down, consider changing them to a function.  
However, note that you are rather unlikely to run into this. Message  
dispatch is pretty damn fast, and is fairly rarely the cause of  
performance bottlenecks.


i.e. DO NOT ATTEMPT TO OPTIMISE PERFORMANCE TOO EARLY!

Mike.

On 19 Jan 2009, at 19:00, Mohan Parthasarathy wrote:


Hi,

I am reading the section "Functions, Constants and Other C Types",  
in the

Cocoa Fundamentals Guide (
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/chapter_2_section_2.html)
and a little confused about the wording in this section.


The following list offers some guidance on using C types in the  
definition

of a custom class:
■ Define a function rather than a method for functionality  
that is often

requested but doesn't need to be
overridden by subclasses. The reason for doing this is performance.  
In these

cases, it's best for the function
to be private rather then being part of the class API. You can also
implement functions for behavior that
is not associated with any class (because it is global) or for  
operations on

simple types (C primitives or
structures). However, for global functionality it might be  
better―for

reasons of extensibility―to create
a class from which a singleton instance is generated.

I am slowly getting to speed on Objective C and Cocoa programming. I  
have
written a few classes and is all written completely in objective C.  
In the
classes that i have written i realize that i have a init method and  
at most

two other methods that are used by other objects. But there are other
methods in the classes that are mostly private i.e not used by other  
objects
(i relaize that all methods defined in the .h file are public). I  
have not

yet subclassed my own classes just the system provided classes.

Does the word private in the guide refers to the same meaning as  
"interfaces
that are solely used within a class and not used/extended by other  
"classes"
? Do i have to really care about this while writing my code or just  
ignore
and write everything in objective C ? If i have a  chunk of code  
written in
"C" that i want to reuse, i guess i can do that if it is not too  
much of a
pain to convert to objective C. But then the word "performance" is a  
little

confusing in the above paragraph. Sorry, if i am reading it too
literally..Any clarification would be appreciated..

thanks
mohan
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to cocoa...@mikeabdullah.net


___

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

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

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

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


Re: CALayer unwanted blurring

2009-01-19 Thread Gustavo Pizano
Hello, I had similar problem when making a layer rotation over the z  
axis, so if I understood good, if I Have an even Width/Height of the  
layer, I should reposition it after the rotation on a pixel, and if I  
have an odd Width/Height, then in a half pixel?. Am I right, maybe I  
can apply this theory to my problem when rotating the layer, which in  
fact would be simply modifying the layer by +/- 1 pixel to make it  
even in both dimensions.



Gustavo


On 19.1.2009, at 19:21, David Duncan wrote:


On Jan 17, 2009, at 4:30 PM, Joe Wildish wrote:

Anyway, I did find a post on this list that mentions a similar  
problem (http://www.cocoabuilder.com/archive/message/cocoa/2008/12/13/225352 
). However, in my case I am not applying any transforms to the  
layer hierarchy, and I am also ensuring that the frame origin of  
each object is drawn at a "whole number" point (both of these  
things are mentioned as potential causes in that thread).



Your suffering from the same problem as above. The frame origin is  
not what matters, but rather the layer's position (all aspects of  
the frame are synthesized from other properties of the layer).  
Depending on if your layer's dimensions are odd or even the position  
should be on the pixel or on the half pixel to avoid antialiasing  
like this.

--
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/gustavxcodepicora%40gmail.com

This email sent to gustavxcodepic...@gmail.com


___

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

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

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

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


Re: NSOutlineView, tracking in a custom NSTextFieldCell, & Shift&Cmd Keys

2009-01-19 Thread Eric Gorr


On Jan 19, 2009, at 10:40 AM, Eric Gorr wrote:

The problem appears to be that my trackMouse code consumes the  
mouseUp event and that is preventing [super mouseDown:theEvent] from  
terminating.


One possible solution is to add a method to my custom cell class to  
set a flag which tells the trackMouse method that it was being  
called due to the shift or cmd key being held down. And, when this  
is the case, I don't dequeue the mouseUP event...calling NSApp's  
nextEventMatchingMask instead of NSWindow's, which was originally  
suggested.


theEvent = [NSApp nextEventMatchingMask:(NSLeftMouseUpMask |  
NSLeftMouseDraggedMask | NSMouseEnteredMask | NSMouseExitedMask)
 untilDate:[NSDate  
dateWithTimeIntervalSinceNow:20]

inMode:NSEventTrackingRunLoopMode
   dequeue:shouldDequeue];

This seems a bit hackish and am thinking there would be a better  
solution.


Actually, there may be.

Since this is all about selection, going down a different, but related  
path, I am working with outlineViewSelectionDidChange. In my delegate,  
my method currently looks like:


- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
static BOOL reentry = NO;

if ( reentry == NO ) {
reentry = YES;

[resourcesThumbnails deselectAll:self];

NSEvent *currentEvent   = [NSApp currentEvent];
NSPoint point   = [resourcesThumbnails  
convertPoint:[currentEvent locationInWindow] fromView:nil];
NSInteger   row = [resourcesThumbnails  
rowAtPoint:point];
id  item= [resourcesThumbnails  
itemAtRow:row];
BOOLisGroupItem = [self  
outlineView:resourcesThumbnails isGroupItem:item];


if ( !isGroupItem ) {

NSUInteger  modifierFlags   = [currentEvent modifierFlags];
BOOLwithShiftKey= ( modifierFlags &  
NSShiftKeyMask ) == NSShiftKeyMask;
BOOLwithCmdKey  = ( modifierFlags &  
NSCommandKeyMask ) == NSCommandKeyMask;


MyCell *aCell   = (MyCell *)[resourcesThumbnails  
preparedCellAtColumn:0 row:row];
NSRect cellRect = [resourcesThumbnails  
frameOfCellAtColumn:0 row:row];


NSInteger   resourceIndex = [aCell  
subItemHitTest:currentEvent inRect:cellRect  
ofView:resourcesThumbnails ];


NSDictionary*itemData   = [item  
objectAtIndex:resourceIndex];
NSValue *itemPointer= [itemData  
objectForKey:@"Name"];
TSBResourceItem *itemInfo   = (TSBResourceItemPtr) 
[itemPointer pointerValue];


[resourcesThumbnails deselectedAllResources];
[resourcesThumbnails selectResource:itemInfo->fGroupID  
itemID:itemInfo->fItemID];

[resourcesThumbnails setNeedsDisplay:YES];
[resourcesThumbnails display];
}

reentry = NO;
}
}


The hackish part is the need to use the static variable since  
deselecting everything in the table causes the notification to be sent  
again.


The nice part is that I don't have to do anything special to handle  
the shift or cmd key, don't have to alter the NSOutlineView's  
mouseDown method, and can still determine exactly which item in the  
table was hit.


Now, I still have to write all of the anchor selection code, etc., but  
that's fairly straightforward.


I think I'm happy with this solution, given my other options, but  
always welcome comments.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [NOOB] Finding Information (was: real noob question)

2009-01-19 Thread Brian Slick


On Jan 19, 2009, at 11:17 AM, mmalc Crawford wrote:



On Jan 19, 2009, at 6:10 AM, julius wrote:


But there is nothing here that looks anything like it would allow  
me to intialise with a numeric value like 23.30.



It's not clear why, throughout, you have ignored:
(a) initWithMantissa:exponent:isNegative:


In my case, when I went through almost exactly the same gyration that  
julius describes a while ago, I didn't know what a mantissa was, and I  
have a decent math and engineering background.  I'm sure it is buried  
in the depths of some textbook that I haven't seen for 10 years, but  
it's not something that springs to mind.


I'm not sure this is a documentation failure as much as a language  
failure, at least in this case.  Why isn't there an initWithInt: or  
initWithFloat: like in some other cases?  THAT would have resulted in  
the documentation page leading to the correct answer.  Mantissa?  Come  
on.  I guess the initWithString: is easy enough, but my brain doesn't  
mix-n-match strings and numbers very well, so it didn't occur to me to  
try.


Brian

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Fundamentals Guide" Clarification

2009-01-19 Thread glenn andreas


On Jan 19, 2009, at 1:44 PM, Mike Abdullah wrote:

Just write your code in Obj-C. When you have a finished application,  
then start profiling performance. If this shows that calling some  
methods is slowing things down, consider changing them to a  
function. However, note that you are rather unlikely to run into  
this. Message dispatch is pretty damn fast, and is fairly rarely the  
cause of performance bottlenecks.


i.e. DO NOT ATTEMPT TO OPTIMISE PERFORMANCE TOO EARLY!



Except for doing the one single greatest optimization possible - going  
from "not-working" to "working".



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


___

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

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

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

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


Re: mergeChangesFromContextDidSaveNotification effects

2009-01-19 Thread Nathan Vander Wilt
I figured this out. Core Data sends out several separate  
ContextDidChange notifications in response to a single - 
mergeChangesFromContextDidSaveNotification call. I had a dumb bug in  
my code that resulted in me only seeing the first one.


The object where I was debugging ContextDidChange notifications (and  
doing my caching) was the very one I was getting the first "refreshed"  
notification for — and I was removing it as a notification observer in  
its -didTurnIntoFault. So it would get turned to a fault first thing  
when merging the save notification, unregister itself as a result, and  
then no longer behave as intended. I moved the notification center  
unregistration to -dealloc, and now I can see that my merge does  
result in all the expected insertions, just with separate notifications.


Hope this can help someone else realize that Core Data doesn't  
(necessarily) hate them if they come across my original post.


-natevw


On Jan 16, 2009, at 2:02 PM, Nathan Vander Wilt wrote:
My application imports into an NSManagedObjectContext created on a  
background thread. As the last stage of this import, I save the  
background context to the persistent store. All my UI code uses a  
managed object context on the main thread, and expects to be  
notified via NSManagedObjectContextObjectsDidChangeNotification to  
update caches and redisplay.


So... in my background thread I catch the  
NSManagedObjectContextDidSaveNotification and pass it to a method  
called on the main thread to - 
mergeChangesFromContextDidSaveNotification: in the main context. Now  
I would expect that all the objects I inserted into the background  
context would get inserted into the main context, and I would see  
evidence of this in the ObjectsDidChange notification. While the  
save notification has @"inserted" and @"updated" sets with the  
expected objects, the change notification only contains the updated  
object in its @"refreshed" set, and no inserted objects.


Is this what I should expect? Is there a better way I can trigger  
the ObjectsDidChange notification on my main context after another  
context updates the persistent store? Or, taking things a step back,  
what's the best way to keep Core Data fetch request results up-to- 
date?


thanks,
-natevw

___

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

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

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

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


Binding of invisible controls: is lazy data loading possible?

2009-01-19 Thread Vitaly Ovchinnikov
Hello all,

I have a grid, array controller and a property of document that
returns array. Grid is bound to controller, controller uses property
as -contentArray. All works fine, but grid asks for data even if it is
not visible. The problem is that document's property performs a lot of
work to compute the data it returns, so I want to call it only if I
really need this data.

I cache those data, but when I change something that affects them, I
need to reset the cache. And to let everyone know that something
changed, I call -will/didChangeValueForKey for my property. And
controller immediately call this property even if grid is not visible.
And I have to do a lot of unnecessary work again.

Is there a TRUE Cocoa-way to force grid or controller to ask for data
only when they are really needed? I can remove bindings and do all
manually, but I still believe in a better and easier way.

Any ideas?

Thank you.
___

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

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

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

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


Re: [NOOB] Finding Information (was: real noob question)

2009-01-19 Thread mmalc Crawford


On Jan 19, 2009, at 11:57 AM, Brian Slick wrote:

On Jan 19, 2009, at 11:17 AM, mmalc Crawford wrote:

On Jan 19, 2009, at 6:10 AM, julius wrote:
But there is nothing here that looks anything like it would allow  
me to intialise with a numeric value like 23.30.

It's not clear why, throughout, you have ignored:
(a) initWithMantissa:exponent:isNegative:
In my case, when I went through almost exactly the same gyration  
that julius describes a while ago, I didn't know what a mantissa  
was, and I have a decent math and engineering background.



Discussion
The arguments express a number in a type of scientific notation that  
requires the mantissa to be an integer. So, for example, if the number  
to be represented is 1.23, it is expressed as 123x10^–2—mantissa is  
123; exponent is –2; and isNegative, which refers to the sign of the  
mantissa, is NO.








-> 

mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSPredicateEditorRowTemplate for NSDate

2009-01-19 Thread Vitaly Ovchinnikov
Hey, boys and girls?
Am I the first, who use NSPredicateEditor?
I just found that there is no default template for time values...

Please somebody confirm that miracle is over and I need to code all
this data/time stuff myself :(


On Sun, Jan 18, 2009 at 7:22 PM, Vitaly Ovchinnikov
 wrote:
> Hello list,
>
> When I add a row template that edits date to predicate editor, it
> allows to perform simple comparisons. Like less or greater or equal
> etc. Smart folders in Finder allow to add clauses like "Date is within
> last X weeks". I can't find a simple way to do the same. It seems that
> the only way is to use custom view with that implements what I want,
> but want to make sure that it is correct before I start.
>
> Maybe I missed something? Or maybe some standard implementation
> already exists? I googled the Internet and this list - nothing.
> Any ideas?
>
> Thank you.
>
___

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

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

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

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


Re: [NOOB] Finding Information (was: real noob question)

2009-01-19 Thread Gary L. Wade
On 01/19/2009 11:57 AM, "Brian Slick"  wrote:

> I'm not sure this is a documentation failure as much as a language
> failure, at least in this case.  Why isn't there an initWithInt: or
> initWithFloat: like in some other cases?  THAT would have resulted in
> the documentation page leading to the correct answer.  Mantissa?  Come
> on.  I guess the initWithString: is easy enough, but my brain doesn't
> mix-n-match strings and numbers very well, so it didn't occur to me to
> try.
> 
> Brian

NSDecimalNumber inherits from NSNumber.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [NOOB] Finding Information (was: real noob question)

2009-01-19 Thread julius


On 19 Jan 2009, at 16:17, mmalc Crawford wrote:



On Jan 19, 2009, at 6:10 AM, julius wrote:

I too followed up on the example link which took me to the top of  
the NSDecimalNumber Class reference document. Scrolling down the  
first thing I came accross under Tasks was "Creating a Decimal  
Number" and just beneath that a link to

+ decimalNumberWithDecimal:
which looked exactly like what the OP was asking for, viz:
<>
Creates and returns an NSDecimalNumber object equivalent to a given  
NSDecimal structure.

+ (NSDecimalNumber *)decimalNumberWithDecimal:(NSDecimal)decimal>

Ah, and look perhaps I don't need to use an alloc
Now with all respect to the writers of this documentation, my first  
question is "what is a decimal structure?".


Typically here I would either click the link to NSDecimal in the  
method declaration, or go to the Companion Guide listed at the top  
of the API reference.

Or ... (see below)


I followed up on  NSDecimal and obtained:
[...]
Scareee and nothing like what I thought it might be.



So either back to NSDecimalNumber,



or to the Companion Guide.

True, I don't go there as often as perhaps I should.
Following up on your suggestion I just did and went directly to the  
“Using Decimal Numbers” part of the document
http://developer.apple.com/documentation/Cocoa/Conceptual/NumbersandValues/Articles/DecimalNumbers.html#/ 
/apple_ref/doc/uid/2176-CJBCAGDI


where it says
<>
Using Decimal Numbers

NSDecimalNumber is an immutable subclass of NSNumber that provides an  
object-oriented wrapper for doing base-10 arithmetic. An instance can  
represent any number that can be expressed as mantissa x 10 exponent  
where mantissa is a decimal integer up to 38 digits long, and exponent  
is an integer between -128 and 127.


and goes on to talk of calculation errors and the  
NSDecimalNumberBehaviors protocol. It does not however illuminate what  
I perceived as the OP's need for a way of doing something essentially  
like [myDecimalNumberObj setValue: 23.3].



I have had reason to think about this quite frequently and have  
come to the conclusion that there is nothing simple or  
straightforward about writing easy to use technical manuals.




Indeed.


One of the main problems it seems to me occurs when I'm trying to  
get quickly to an answer and rather than read and digest every word  
of the manual




I have had reason to think about this quite frequently and have come  
to the conclusion that, when documentation is written, it should be  
padded with extraneous words and phrases that readers can safely  
ignore.
I appreciate the irony but it misses the point that on many occasions  
we really do just need a straight answer to a simple question.  
Sometimes such an answer exists and sometimes it does not. Sometimes  
to ask a particular question demonstrates sufficient ignorance to  
suppose that it is a text book and not a manual one should be reading.  
In the case of a text book a bit of redundancy is very useful  
especially if it addresses the fact that each person has their own way  
of learning. One would not expect much redundancy in a technical  
manual but an excellently designed manual would consider the different  
users and the different ways in which the information it contains  
might be needed. For instance, one may contrast the need to understand  
how something works from the need to find the correct switch to turn  
the thing on.


I suppose there must be a good reason for there not being a simple way  
of assigning a value to one of these NSDecimalNumber objects but I  
could find no such reason in the documentation and its absence just  
appears so intuitively unreasonable that one is loth to stop searching  
(see below for why in this case a search would ultimately have been  
successful). NSDecimalNumber appears to be used for arithmetic and as  
a wrapper. I've had sufficient similar difficulties in the past with  
wanting to wrap numbers to have ended up writing my own wrappers. So I  
have a notion of the frustration one might feel in such cases.






O.K. lets leave that and go back to  see if we can find something  
that looks a bit more like the OP's number : 23.30.
The next heading beneath "Creating a Decimal Number" is  
"Initializing a Decimal Number" and head of the list is

<>
– initWithDecimal:

That looks promising.. but
<>
initWithDecimal:
Returns an NSDecimalNumber object initialized to represent a given  
decimal.

- (id)initWithDecimal:(NSDecimal)decimal>


No good: there's that NSDecimal again, but note that this time it  
is not described as a structure but as a "decimal" 

Back to the top of the list:
<>
Initializing a Decimal Number
  * – initWithDecimal:
  * – initWithMantissa:exponent:isNegative:
  * – initWithString:
  * – initWithString:locale:


But there is nothing here that looks anything like it would allow  
me to intialise with a numeric value like 23.30.



It's not clear why, throughout, you have ig

Re: NSPredicateEditorRowTemplate for NSDate

2009-01-19 Thread Jim Turner
The miracle is over.  The out-of-the-box templates in IB only provide
three-view templates (left expression, operator, right expression).
You'll need to subclass NSPredicateEditorRowTemplate and provide the
views and logic you want to use in your template.

I did a presentation for the local CocoaHeads a while back on
NSPredicateEditor and my sample code does show a basic "Date is within
N days/weeks/months/years" if you'd like a starting point.

Go to http://groups.google.com/group/des-moines-cocoaheads/files   and
look for "NSPredicateEditor.zip" (I'd direct link but the URL is a
monster).

-- 
Jim
http://nukethemfromorbit.com


On Mon, Jan 19, 2009 at 2:13 PM, Vitaly Ovchinnikov
 wrote:
> Hey, boys and girls?
> Am I the first, who use NSPredicateEditor?
> I just found that there is no default template for time values...
>
> Please somebody confirm that miracle is over and I need to code all
> this data/time stuff myself :(
>
>
> On Sun, Jan 18, 2009 at 7:22 PM, Vitaly Ovchinnikov
>  wrote:
>> Hello list,
>>
>> When I add a row template that edits date to predicate editor, it
>> allows to perform simple comparisons. Like less or greater or equal
>> etc. Smart folders in Finder allow to add clauses like "Date is within
>> last X weeks". I can't find a simple way to do the same. It seems that
>> the only way is to use custom view with that implements what I want,
>> but want to make sure that it is correct before I start.
>>
>> Maybe I missed something? Or maybe some standard implementation
>> already exists? I googled the Internet and this list - nothing.
>> Any ideas?
>>
>> Thank you.
>>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jturner.lists%40gmail.com
>
> This email sent to jturner.li...@gmail.com
>
___

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

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

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

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


Re: NSPredicateEditorRowTemplate for NSDate

2009-01-19 Thread Markus Spoettl

On Jan 19, 2009, at 9:13 PM, Vitaly Ovchinnikov wrote:

Hey, boys and girls?
Am I the first, who use NSPredicateEditor?
I just found that there is no default template for time values...



I basically use this code for a date value row template (simplified  
version not tested):


NSArray *operators = [NSArray arrayWithObjects:
[NSNumber numberWithInteger:NSEqualToPredicateOperatorType],
[NSNumber numberWithInteger:NSLessThanPredicateOperatorType],
[NSNumber  
numberWithInteger:NSGreaterThanPredicateOperatorType],
[NSNumber  
numberWithInteger:NSLessThanOrEqualToPredicateOperatorType],
[NSNumber  
numberWithInteger:NSGreaterThanOrEqualToPredicateOperatorType],

nil];

   NSExpression *equipmentExpr =
[NSExpression expressionForKeyPath:@"date"]; <<-- use the key  
path appropriate for your object


   NSPredicateEditorRowTemplate *dateTemplate =
   [[[NSPredicateEditorRowTemplate alloc]
   initWithLeftExpressions:expressions
  rightExpressionAttributeType:NSDateAttributeType
  modifier:NSDirectPredicateModifier
 operators:operators
   options:0] autorelease];


NSArray *templates = [NSArray arrayWithObjects:
...
dateTemplate,
...
nil];


[editor setRowTemplates:templates];  <<-- editor is a  
NSPredicateEditor ivar


All is needed now is a predicate that matches the templates you  
defined and it should work. If you give the editor a predicate it  
cannot resolve using the row template you will get a console log entry  
telling you details (at least on Leopard).


Hope this helps!

Regards
Markus
--
__
Markus Spoettl



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: Binding of invisible controls: is lazy data loading possible?

2009-01-19 Thread Quincey Morris

On Jan 19, 2009, at 12:11, Vitaly Ovchinnikov wrote:


I cache those data, but when I change something that affects them, I
need to reset the cache. And to let everyone know that something
changed, I call -will/didChangeValueForKey for my property. And
controller immediately call this property even if grid is not visible.


This sounds like the relevant issue. If you call will/ 
didChangeValueForKey for a *collection* property, observers of the  
property (the array controller and, indirectly, the grid, in this  
case) must assume that everything has changed.


The solution is to *not* call will/didChangeValueForKey, which often  
indicates a poor coding solution anyway. Instead, update your data  
model KVO compliantly. This means:


1. If some change affects a cached object's properties, update it KVO  
compliantly. (Use setters to change its properties, or use  
keyPathsForValuesAffecting class methods to indicate which keys  
its properties depend on, and update *those* keys KVO compliantly.)


2. If some change affects which objects are cached, update the cache  
array KVO-compliantly. (Use standard NSMutableArray methods on  
[yourCacheOwner mutableArrayValueForKey: @"yourCacheArray"] instead of  
yourCacheArray.) That will let the array controller know just what  
changed, and allow it to be selective about what it queries as a result.





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSPredicateEditorRowTemplate for NSDate

2009-01-19 Thread Peter Ammon

Hello Vitaly,

The Cocoa frameworks do not yet have any classes for specifying a  
relative date, so you will have to handle this yourself with a  
subclass of NSPredicateEditorRowTemplate.  You can leverage the  
superclass to do much of the work for you: your responsibility is  
limited to turning a RelativeDate into units (days, weeks) and a  
value in those units, and going the other direction as well.


I wrote a sample showing one way to handle relative dates.  For now it  
is at http://homepage.mac.com/gershwin/RelativeDatesPredicateEditor.zip


As to "no default template for time values," this is a limitation of  
IB's support for NSPredicateEditor.  You can set up a time-editing  
NSDatePicker programmatically like so:


* Create an NSPredicateEditorRowTemplate that edits dates in IB
* Make an outlet to it
* When your code starts, set the date picker elements to what you  
want: [[[template templateViews] objectAtIndex:2]  
setDatePickerElements:elements];


This is a mechanism that NSPredicateEditor supports.

Hope this helps,
-Peter

On Jan 18, 2009, at 8:22 AM, Vitaly Ovchinnikov wrote:


Hello list,

When I add a row template that edits date to predicate editor, it
allows to perform simple comparisons. Like less or greater or equal
etc. Smart folders in Finder allow to add clauses like "Date is within
last X weeks". I can't find a simple way to do the same. It seems that
the only way is to use custom view with that implements what I want,
but want to make sure that it is correct before I start.

Maybe I missed something? Or maybe some standard implementation
already exists? I googled the Internet and this list - nothing.
Any ideas?

Thank you.
___

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

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

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

This email sent to pam...@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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Graham Cox


On 20 Jan 2009, at 5:24 am, I. Savant wrote:


On Jan 19, 2009, at 12:57 PM, Paul Bruneau wrote:

I'm confused by it, since I have been directed in the past by  
people who know that The Cocoa Way is to have objects know how to  
draw themselves--via a category if desired.


Is there differing opinion on this? (apparently there is...)

 This is tough to generalize. There is not only differing opinion,  
but also plenty of room for debate. :-)


 In the Sketch example, there are different shapes (including  
"text"), each of which handles drawing somewhat differently. I  
suspect the decision not to put this into the canvas view is more a  
matter of organization than architecture. I happen to agree with the  
decision.


 There's nothing about the MVC design pattern that demands all  
drawing code belongs in the view. In the particular case of a  
drawing application where the shapes to be drawn *are* the data  
model, how to draw a shape could be viewed as "business logic" for  
the model.



My design follows this approach - the objects draw themselves,  
because, as you say, the objects *are* the data model. Where an object  
"carries" additional data that isn't directly part of the drawing, it  
does so by referencing a separate structure which is handled through  
conventional controllers and other views as necessary.


Since all of this is handled through DrawKit (http://apptree.net/drawkitmain.htm 
), you can download it and take it apart if you like - no part of the  
data model of my app that is not part of the business of rendering  
objects is called at drawRect: time. If I gave that impression I  
didn't intend to! However the drawing methodology itself is fairly  
complex, involving as it does multiple layers, different kinds of  
objects within a layer, and each object having different methodologies  
for editing its geometry (e.g. editing the control points of a path  
versus changing its bounding rect, etc) and the visual appearance of  
each object handed off to a "style" object that is built up from lists  
of stroke, fill, gradient, image, text and other operations. The point  
is that it's very versatile and powerful. I'm also working on making  
the drawing storage scalable, which adds a further degree of  
complexity, since storing tens of thousands of objects in a simple  
array starts to become inefficient (to clarify - nothing is drawn that  
doesn't need to be drawn according to the view's update rectangles,  
but at some point you need to decide which objects are affected by an  
update. Iterating a long list and testing every object is inefficient,  
so I'm experimenting with BSP storage where given an update region a  
much smaller subset of objects can be instantly returned).


It's also, for the most part, robust - and getting more so. Where  
different objects are involved in the rendering process, I'm  
introducing formal protocols in place of informal ones so that non- 
conformance is easier to detect. This has already realised benefits of  
eliminating a couple of places where the wrong objects ended up  
getting accidentally passed to rendering code which was then throwing  
exceptions - so the proper handling of try/catch is only one strategy  
among several for making the drawing architecture as solid as possible.


Incidentally, if this seems like overkill, a glance at the larger  
screen shot here might help: http://mapdiva.com. This shows what I'm  
working on and why simple handling of stroke/fill a la Sketch just  
doesn't cut it! (and even this screenshot barely scratches the surface  
of what's possible). I would also mention that currently the drawing  
time is still hugely dominated by Core Graphics, so it's not like my  
drawing approach is causing poor performance.




IMHO objects that can draw themselves should be NSCell sub-classes or
NSView sub-classes (possibly using some primitive drawing rendering
support from NSImage, NSString, etc.) and not some model object that
has drawing code tacked onto it. These view classes should be told or
be able to ask for the data they need to use at render time, ideally
pre-prepared / pre-fetched as makes sense.


Here I'd disagree. My drawing objects are based neither on NSView nor  
NSCell, they start from NSObject and gradually specialise, first with  
properties that are common to all "drawables" and then subclassing for  
more esoteric variations. NSView is too heavyweight, especially when  
you could end up with tens of thousands of objects, and NSCell, while  
lightweight, is also very much designed for use in framework tables,  
matrixes and controls. Objects that are part of a drawing are not  
really "control-like" so the NSCell model isn't really that good a  
fit. It also means a lot of code isn't directly available to the  
application developer so often behaviours have to be inferred, whereas  
by writing your own "drawable" object you have complete control over  
its code and behaviour.


In my case the

Re: CALayer unwanted blurring

2009-01-19 Thread Matt Long

How very interesting...

I wanted to confirm this so I wrote a little code. Here's an image of  
the results.


http://cimgf.com/files/BlurryLayer.png

And here's the Xcode project:

http://cimgf.com/files/BlurryLayer.zip

Thanks for pointing that out David.

-Matt


On Jan 19, 2009, at 11:21 AM, David Duncan wrote:


On Jan 17, 2009, at 4:30 PM, Joe Wildish wrote:

Anyway, I did find a post on this list that mentions a similar  
problem (http://www.cocoabuilder.com/archive/message/cocoa/2008/12/13/225352 
). However, in my case I am not applying any transforms to the  
layer hierarchy, and I am also ensuring that the frame origin of  
each object is drawn at a "whole number" point (both of these  
things are mentioned as potential causes in that thread).



Your suffering from the same problem as above. The frame origin is  
not what matters, but rather the layer's position (all aspects of  
the frame are synthesized from other properties of the layer).  
Depending on if your layer's dimensions are odd or even the position  
should be on the pixel or on the half pixel to avoid antialiasing  
like this.

--
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: CALayer unwanted blurring

2009-01-19 Thread Joe Wildish

Many thanks David, this seems to have solved my problem!

Regards,
-Joe

On 19 Jan 2009, at 18:21, David Duncan wrote:

Your suffering from the same problem as above. The frame origin is  
not what matters, but rather the layer's position (all aspects of  
the frame are synthesized from other properties of the layer).  
Depending on if your layer's dimensions are odd or even the position  
should be on the pixel or on the half pixel to avoid antialiasing  
like 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


Re: Binding of invisible controls: is lazy data loading possible?

2009-01-19 Thread Ken Thomases

On Jan 19, 2009, at 3:27 PM, Quincey Morris wrote:

2. If some change affects which objects are cached, update the cache  
array KVO-compliantly. (Use standard NSMutableArray methods on  
[yourCacheOwner mutableArrayValueForKey: @"yourCacheArray"] instead  
of yourCacheArray.)


This is common advice, but in my opinion it's misguided.

While directly mutating an array ivar doesn't generate KVO  
notifications, and mutating the proxy returned by - 
mutableArrayValueForKey: does, that's not the best means to gain KVO  
compliance.  You should instead implement the indexed to-many  
accessors[1] for any to-many property.  Then, you should use them to  
mutate the property in your own code.


What's wrong with -mutableArrayValueForKey:?

Here's one good guideline: in general, KVC is for accessing a property  
based on dynamic data rather than compile-time identifier.  If you  
find yourself hard-coding string literals with property names, then  
You're Doing It Wrong(tm).


More importantly, -mutableArrayValueForKey: doesn't magically allow  
for mutations to the property that aren't already allowed by your  
class's interface.  In particular, if you don't provide the indexed to- 
many accessors, then mutating the proxy returned by - 
mutableArrayValueForKey: ends up doing the inefficient call to  
set: that you were trying to avoid.  (In other words, it has the  
same negative implications as will/didChangeValueForKey:.)  Since  
that's the case, why not just call -set: yourself rather than  
having the proxy do it?


(There is an exception to the above, but it's hardly worth  
mentioning.  If your property has neither indexed to-many mutator  
methods nor the simple setter method, and  
+accessInstanceVariablesDirectly returns YES, then the proxy may  
directly access the NSMutableArray-like ivar.  In that case, the proxy  
can do efficient operations on the property along with efficient KVO  
notifications using did/willChange:valuesAtIndexes:forKey:.  However,  
except for cases of backward compatibility, you should always override  
+accessInstanceVariablesDirectly to return NO for your classes.   
Allowing KVC to directly modify your internal state without going  
through your methods is bad mojo.)


Regards,
Ken

[1] The indexed to-many accessors for array properties are described  
here:


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ 
/apple_ref/doc/uid/20002174-178830-BAJEDEFB


See also the documentation for -mutableArrayValueForKey: although some  
additional methods are only documented in NSKeyValueCoding.h at the  
declaration of -mutableArrayValueForKey:.


The (non-indexed) to-many accessors for set properties are described  
in the documentation for -mutableSetValueForKey:.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Memory allocation issues with NSObject and NSString

2009-01-19 Thread Ben Trumbull

On Sun, Jan 18, 2009 at 11:21 PM, Bill Bumgarner  wrote:
2. If I have an NSObject class and I define an init messge, do I  
have
to do self = [super init] or is that not important when extending  
from

NSObject.


Yes, it is important.

But it does next to nothing.

For now.  Someday, that might change.


I sure hope not! The documentation for the method states:

"The init method defined in the NSObject class does no initialization;
it simply returns self."

Making it do anything else would be a serious breach of the API  
contract.


That is a matter of perspective.  And why lawyers plague the world.   
"no initialization" is not the same as "absolutely not a single CPU  
instruction".  For example, this tech writer might have meant "no  
initialization of this object", which would be obvious, not realizing  
that someone else would read that and wrongly infer that they could  
safely skip using it correctly as demonstrated in the code box right  
next to the words.


The NSObject alloc/init pair is responsible for implementing NSZombie  
support, and ObjectAlloc integration.  They also call into the ObjC  
runtime, so fundamental changes to class or object initialization are  
possible beyond the literal implementation of NSObject.  An example of  
that would be the compile flag 'Call C++ Default Ctors/Dtors in  
Objective-C' for properly initializing ivars of an Objective-C object  
that are themselves C++ objects.


Now that happens courtesy of +alloc, so you may get away with abusing - 
init.  Still, if you read the documentation and conclude based on the  
English verbiage that you are free to ignore the documented code  
patterns right there next to it in the -init method documentation  
(which call super and assign to self), you're liable to hurt yourself.


There are times and places to not use +alloc, or even cheat with - 
init.  But then, you get what you get and roll an SU when you're  
wrong.  caveat emperor.


Future proof software should follow the documented coding patterns.   
Several AppKit and Core Data classes unmercifully require it.


- Ben

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


Crash trying to create Webarchive

2009-01-19 Thread Reza Farhad

Dear All

I am trying to get a WebArchive from a webview:

[[[webView mainFrame] dataSource] webArchive]

For some pages I get the following Exception

NSExceptionHandler has recorded the following exception:
NSInvalidArgumentException -- *** -[NSCFArray insertObject:atIndex:]:  
attempt to insert nil


Now is there a way to be able to detect this and hence react to it so  
that the app does not crash.


Thanks in advance

Reza
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Dealing with exceptions in a drawing stack

2009-01-19 Thread Quincey Morris

On Jan 19, 2009, at 14:54, Graham Cox wrote:

Well, it's not really in an unsaveable state. The data model itself  
isn't damaged by exceptions thrown from the drawing code. However,  
the visual appearance of the document is badly upset (scrollbars  
suddenly disappear, rulers get drawn in the middle of the view,  
etc). The user *thinks* something has gone terribly wrong, panics,  
and typically closes the document without saving. In fact saving at  
that point will work OK, but we're finding that users typically  
think it's become "corrupt" and are loth to save over an earlier  
version of the document because they think that what they see is  
what they will get - i.e. saving the document with a corrupted view  
will make the problem permanent. The end result is the same though -  
the user has "lost" their data, even though in fact they didn't need  
to. This is why I need to ensure that a minor glitch when drawing  
doesn't get blown out of all proportion.


So Plan A would be to try to recover the drawing state, turn off your  
drawing (because presumably the same exception would occur if the  
window redrew), get safely back to the main event loop, and put up a  
Save As dialog with a message that the application needs to quit  
because of an internal error and asking for a place to save a copy of  
the document? As a user, I'd be sold on that idea, I think.


IMO, the issue is (at least initially) a matter of documentation.  
The NSGraphicsContext class reference is ambiguous and incomplete  
-- it's not clear whether the current context is saved *in* each  
state on the state stack, or whether the state stack is *in* the  
current context, or whether the state *is* the context. There's  
apparently a setGraphicsState: method which *looks* like it might  
be what Graham needs to set things back to a known state, but the  
parameter to this method isn't documented anywhere I could find.


The header file is no help at all. The comments refer to save/ 
restore *context* methods (as opposed to save/restore *state*  
methods) which apparently don't exist anywhere.


If the documentation was clear, I think Graham's strategy for  
dealing with exceptions would also become clear.


Yep, I guess this is getting at the heart of my problem (Thanks for  
putting it so much more succinctly than I have managed so far!). I  
guess I'm hoping someone familiar with NSGraphicsContext can help me  
understand if saving and restoring a context explictly is legal  
(what happens to all the saved states that were stacked up in the  
process?) or if not, what is an appropriate alternative. In practice  
it seems to work, but I need to know that I'm not storing up trouble  
for myself.


The question is whether you're really saving and restore a context, or  
just states. According to my reading of the documentation, you're not  
actually going to switch NSGraphicsContext unless you need to do (say)  
buffered drawing into a NSBitmapImageRep-based context. There's no  
stack of contexts to reset unless (a) the state save/restore includes  
the current context or (b) states and contexts are really the same  
thing.


My reading of (most parts of) the documentation suggest that the state  
consists of the drawing parameters of the context, but not the context  
itself.


So it's unclear why recovering by setting the context (as you tried)  
has any effect at all (unless you had changed contexts yourself).


Now would be a good time for someone who really knows something to  
jump in and enlighten us. :)


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSPredicateEditorRowTemplate for NSDate

2009-01-19 Thread Vitaly Ovchinnikov
Thanks to all for answers, now I need a few days to sleep with all these data.
Thank you.

On Tue, Jan 20, 2009 at 12:04 AM, Jim Turner  wrote:
> The miracle is over.  The out-of-the-box templates in IB only provide
> three-view templates (left expression, operator, right expression).
> You'll need to subclass NSPredicateEditorRowTemplate and provide the
> views and logic you want to use in your template.
>
> I did a presentation for the local CocoaHeads a while back on
> NSPredicateEditor and my sample code does show a basic "Date is within
> N days/weeks/months/years" if you'd like a starting point.
>
> Go to http://groups.google.com/group/des-moines-cocoaheads/files   and
> look for "NSPredicateEditor.zip" (I'd direct link but the URL is a
> monster).
>
> --
> Jim
> http://nukethemfromorbit.com
>
>
> On Mon, Jan 19, 2009 at 2:13 PM, Vitaly Ovchinnikov
>  wrote:
>> Hey, boys and girls?
>> Am I the first, who use NSPredicateEditor?
>> I just found that there is no default template for time values...
>>
>> Please somebody confirm that miracle is over and I need to code all
>> this data/time stuff myself :(
>>
>>
>> On Sun, Jan 18, 2009 at 7:22 PM, Vitaly Ovchinnikov
>>  wrote:
>>> Hello list,
>>>
>>> When I add a row template that edits date to predicate editor, it
>>> allows to perform simple comparisons. Like less or greater or equal
>>> etc. Smart folders in Finder allow to add clauses like "Date is within
>>> last X weeks". I can't find a simple way to do the same. It seems that
>>> the only way is to use custom view with that implements what I want,
>>> but want to make sure that it is correct before I start.
>>>
>>> Maybe I missed something? Or maybe some standard implementation
>>> already exists? I googled the Internet and this list - nothing.
>>> Any ideas?
>>>
>>> Thank you.
>>>
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/jturner.lists%40gmail.com
>>
>> This email sent to jturner.li...@gmail.com
>>
>
___

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

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

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

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


Anybody using Fix and Continue and Objective-C++?

2009-01-19 Thread m
Is anyone able to use fix and continue with Objective-C++ source  
files? I can't get it to work.


The error I get is:

"Error fixing Controller.mm: Changing the type of global variable  
'_DefaultRuneLocale' from '		' to 'struct $_10' is not supported."


It works great if I change my source file's extension from ".mm" to  
".m".


_murat 
___


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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: ObjC in time-critical parts of the code

2009-01-19 Thread William Jon Shipley
Simple question:  Is it better to pursue a 20%, or even 50%,  
improvement in drawing speed by rewriting in C++ or C than, say,  
preventing the 2, 3, 4, or more extra redraws that are happening  
prior to window flush?   Don't laugh -- I have seen it happen.  Often.


I subscribed to this list just to agree with Bill, here. Every good  
developer I know has found a speed-up in completely adopting Objective- 
C and Cocoa, NOT a slowdown. Of COURSE you can write bad code in  
Objective-C. But it encourages you not to.


In my experience, MOST programs out there suffer from performance  
problems that are caused by large-scale inefficiencies, NOT small- 
scale inefficiencies:


For example, a large-scale inefficiency would be a database interface  
where you malloc() and copy the data six times before the user sees  
it, instead of just retaining it and passing around the same pointer.  
(This was really the case with the original DBKit (predecessor to EOF,  
predecessor to CoreData), except I think it was more than 6, it was,  
like, 15.) Method calls are nothing compared to memory allocation, yet  
people spend most of their time freaking out about the overhead of a  
method, and none thinking, "Damn, it's nice to have a coherent  
strategy for handling memory."


Using Cocoa means those kinds of problems are avoided from the start.

On the other hand, a small-scale inefficiency would be, like, a tight  
loop where you run through a buffer and increment each byte by two.  
And honestly (a) compilers are good at optimizing this kind of thing,  
(b) it's really not very common, and (c) processors are super-fast  
anyhow. And usually the best answer is to go higher-level with these  
problems, anyways (eg, use vecLib).


--

Think about the kinds of problems that are slow. What do they involve?  
Usually, large data sets. I mean, if you're doing only one operation,  
it's REALLY hard to make that slow, nowadays.


Apple's spent a TON of time optimizing their collection classes.  
NSArray, NSSet, NSDictionary -- they are all on their, like, fifth  
iteration. You're not going to do better straight out of the gate,  
certainly not re-writing them in straight-C.


--

I will go this far: I would never hire anyone who complains seriously  
about Objective-C being slow, because what you have there is someone  
who hasn't written a complete system. She's a theoretical programmer,  
not a real one. "In THEORY, straight C should be faster." Yes, if  
*you* were a perfect programmer, and could rewrite very complex  
systems from scratch in a low-level language without introducing any  
bugs on inefficiencies... but the last 50 years of computer  
programming have proven that there are maybe four or five programmers  
in the world like this. (John Carmack, for instance.)


-Wil
___

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

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

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

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


Trying to display a simple sheet

2009-01-19 Thread Harry Plate
This is a newbie question I am certain. I am experimenting with sheets with
a simple application (1st cocoa app) and want to display a simple alert
message as a sheet.

1) So my first mistake was to use NSRunAlertPanel(). Did its thing but gave
me an independent window.

2) Further reading disclosed NSBeginAlertSheet(). Again an independent
window! Here is my code fragment:

...
//NSRunAlertPanel( @"TITLE", @"MESSAGE", @"BUTTON1", @"BUTTON2",
@"BUTTON OTHER") ;
NSBeginAlertSheet(@"TITLE", @"DFLT BUTTON", @"ALT BUTTON", @"OTHER
BUTTON",
[sourceTableView window],
self, // modal delegate
@selector(sheetDidEnd:returnCode:contextInfo:),
nil, // didDismissSelector
nil, // contextInfo
@"MESSAGE") ;
...

3) I then tried to create an NSPanel and use NSApp::beginSheet: do get the
job done. Again an independent window

...
// create a new panel
NSPanel* sheet = [[NSPanel new] init] ;
// now run the panel/sheet
[NSAppbeginSheet:sheet
modalForWindow: [sourceTableView window]
modalDelegate: nil
didEndSelector: nil
contextInfo: nil] ;

[NSApp runModalForWindow:[sourceTableView window]] ;
[NSApp endSheet:[sourceTableView window]];
[[sourceTableView window] orderOut:self] ;
...

I guess I would have expected that #2 or #3 would have resulted in a sheet
on my main application window. What obvious detail did I miss?

TIA,

-harry


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: real noob question

2009-01-19 Thread Richard Dammkoehler

Try this;
On Jan 17, 2009, at 7:18 PM, Darren Stuart wrote:

Hi there, sorry for the real noobish question but I can't figure  
this out or find an answer.


I have a variable called myMoney and its a NSDecimalNumber and I  
want to set init it with the value of 23.30.


NSDecimalNumber *myMoney =  [[NSDecimalNumber alloc] init];



NSDecimalNumber *num = [[NSDecimalNumber alloc] initWithString:"23.30"];
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


CoreData entity mutability

2009-01-19 Thread Antoine Maillard
Hi,
I'm using CoreData in one of my projects and I designed an object model with
2 entities : A and B in which B inherits from A.
How can I convert a NSManagedObject of type A into type B ?

Thanks,

Antoine
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


Test for typeName failing

2009-01-19 Thread Walker Argendeli
In my readFromURL:ofType:error: method, I'm testing to see if typeName  
is equal to a string representing zip, and then taking action based  
off of that.  The problem is that even when I load a zip, the  
statement fails.  I logged tpeName to the console to get what it was  
for zip, so I don't understand why, when I test for that, it fails.   
What's going on?

Here's the code:
if (typeName == @"public.zip-archive")
[task setLaunchPath:@"/usr/bin/zipinfo"];

Thanks,
- Walker Argendeli

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Test for typeName failing

2009-01-19 Thread Stephen J. Butler
On Mon, Jan 19, 2009 at 6:01 PM, Walker Argendeli
 wrote:
> In my readFromURL:ofType:error: method, I'm testing to see if typeName is
> equal to a string representing zip, and then taking action based off of
> that.  The problem is that even when I load a zip, the statement fails.  I
> logged tpeName to the console to get what it was for zip, so I don't
> understand why, when I test for that, it fails.  What's going on?
> Here's the code:
> if (typeName == @"public.zip-archive")
>[task setLaunchPath:@"/usr/bin/zipinfo"];

Objective-C, just like C, does not have overloaded operators. You are
comparing the POINTER of typeName to the POINTER of the NSString
constant. Not going to work. What you want to do is this:

[typeName isEqualToString:@"public.zip-archive"]
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: ObjC in time-critical parts of the code

2009-01-19 Thread Kyle Sluder
On Sun, Jan 18, 2009 at 7:10 PM, Bill Bumgarner  wrote:
> Simple question:  Is it better to pursue a 20%, or even 50%, improvement in
> drawing speed by rewriting in C++ or C than, say, preventing the 2, 3, 4, or
> more extra redraws that are happening prior to window flush?   Don't laugh
> -- I have seen it happen.  Often.

This just got posted to programming.reddit.com: "My iPhone is not a
Mac Pro": 
http://www.reddit.com/r/programming/comments/7qxuv/my_iphone_is_not_a_mac_pro_speeding_up_iphone/

In it, the author discusses improving the speed of his iPhone app.
Importantly, he starts by improving the data structure in which he
stores the app's data, and then improving the algorithms used to
access that data.  Eventually he employs some C++ to get a significant
speed boost, but the decision has *nothing* to do with non-virtual
member functions or other such oft-touted C++ speed improvements -- in
fact, he compares it to using -[NSArray
sortedArrayUsingFunction:context:], which doesn't incur the ObjC
dispatch overhead.  It's all about the algorithm, and C++ happened to
have one he could use that improved his code's speed.

--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: ObjC in time-critical parts of the code

2009-01-19 Thread Bill Bumgarner

On Jan 19, 2009, at 4:21 PM, Kyle Sluder wrote:

On Sun, Jan 18, 2009 at 7:10 PM, Bill Bumgarner  wrote:
Simple question:  Is it better to pursue a 20%, or even 50%,  
improvement in
drawing speed by rewriting in C++ or C than, say, preventing the 2,  
3, 4, or
more extra redraws that are happening prior to window flush?
Don't laugh

-- I have seen it happen.  Often.

This just got posted to programming.reddit.com: "My iPhone is not a
Mac Pro": 
http://www.reddit.com/r/programming/comments/7qxuv/my_iphone_is_not_a_mac_pro_speeding_up_iphone/

In it, the author discusses improving the speed of his iPhone app.
Importantly, he starts by improving the data structure in which he
stores the app's data, and then improving the algorithms used to
access that data.  Eventually he employs some C++ to get a significant
speed boost, but the decision has *nothing* to do with non-virtual
member functions or other such oft-touted C++ speed improvements -- in
fact, he compares it to using -[NSArray
sortedArrayUsingFunction:context:], which doesn't incur the ObjC
dispatch overhead.  It's all about the algorithm, and C++ happened to
have one he could use that improved his code's speed.


Which, of course, would be an utterly pointless optimization if it  
were merely to make the extra-3-unnecessary-redraws fast enough to  
boost his framerate to something acceptable (which was the point of  
the part of my post that you excerpted :).


Fortunately, it sounds like the author of the original article  
actually figured out that they had eked out ever last bit of  
performance from the APIs and, thus, pursued a hybrid solution  
leveraging C++.


Nice article.

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: Anybody using Fix and Continue and Objective-C++?

2009-01-19 Thread Scott Ribe
> Is anyone able to use fix and continue with Objective-C++ source
> files? I can't get it to work.

It only works with Objective-C. Known limitation...

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


___

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

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

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

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


Re: Binding of invisible controls: is lazy data loading possible?

2009-01-19 Thread Quincey Morris

On Jan 19, 2009, at 15:11, Ken Thomases wrote:


On Jan 19, 2009, at 3:27 PM, Quincey Morris wrote:

2. If some change affects which objects are cached, update the  
cache array KVO-compliantly. (Use standard NSMutableArray methods  
on [yourCacheOwner mutableArrayValueForKey: @"yourCacheArray"]  
instead of yourCacheArray.)


This is common advice, but in my opinion it's misguided.

While directly mutating an array ivar doesn't generate KVO  
notifications, and mutating the proxy returned by - 
mutableArrayValueForKey: does, that's not the best means to gain KVO  
compliance.  You should instead implement the indexed to-many  
accessors[1] for any to-many property.  Then, you should use them to  
mutate the property in your own code.


What's wrong with -mutableArrayValueForKey:?

Here's one good guideline: in general, KVC is for accessing a  
property based on dynamic data rather than compile-time identifier.   
If you find yourself hard-coding string literals with property  
names, then You're Doing It Wrong(tm).


More importantly, -mutableArrayValueForKey: doesn't magically allow  
for mutations to the property that aren't already allowed by your  
class's interface.  In particular, if you don't provide the indexed  
to-many accessors, then mutating the proxy returned by - 
mutableArrayValueForKey: ends up doing the inefficient call to  
set: that you were trying to avoid.  (In other words, it has  
the same negative implications as will/didChangeValueForKey:.)   
Since that's the case, why not just call -set: yourself rather  
than having the proxy do it?


Sorry, you are correct. Assuming you're not depending on direct  
instance variable access, my statement should have been:


Use standard NSMutableArray methods on [yourCacheOwner  
mutableArrayValueForKey: @"yourCacheArrayProperty"] instead of  
yourCacheArray, and implement the 2 or 3 required indexed accessor  
methods to make it work.


In that case, using those indexed accessor methods directly *may* be  
more convenient than using the mutableArrayValueForKey proxy, but they  
are only a limited subset of the methods available to NSArray and  
NSMutableArray. If you want to use addObject: or removeAllObjects or  
addObjectsFromArray: etc, you're going to have to provide boilerplate  
implementations of all of them, which translate them into the few  
basic accessors. It's easy, but tedious to do over and over, for each  
new property. (I tried that, and decided to go back to using the proxy  
before long.)


You can easily hide the ugly compile time string by corralling it into  
a single method: define a @property (readonly) NSMutableArray*  
mutableYourCacheArrayProperty that returns the proxy object.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Crash trying to create Webarchive

2009-01-19 Thread Corbin Dunn


On Jan 19, 2009, at 3:30 PM, Reza Farhad wrote:


Dear All

I am trying to get a WebArchive from a webview:

[[[webView mainFrame] dataSource] webArchive]

For some pages I get the following Exception

NSExceptionHandler has recorded the following exception:
NSInvalidArgumentException -- *** -[NSCFArray  
insertObject:atIndex:]: attempt to insert nil


Now is there a way to be able to detect this and hence react to it  
so that the app does not crash.


Break on objc_exception_throw. Investigate from there...

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: ObjC in time-critical parts of the code

2009-01-19 Thread Scott Ribe
> but the decision has *nothing* to do with non-virtual
> member functions or other such oft-touted C++ speed improvements

But actually, it does. The fact is that std::lower_bound is a template that
specializes on the types of the iterators, so what you get is different code
generated depending on the iterator types, and in the case where the
iterators are simple pointers, a whole lot of "functions" that wind up
incurring no function calls at all, but reducing to simple pointer
increments and comparisons, inline--all made possible by static typing
information and C++'s ability to exploit that info. (And even in the cases
where the iterators are more complex, such as maps or sets, the functions
are probably only a line or two and also wind up inlined.)

Exactly the kind of thing I was talking about much earlier in the thread.
There's nothing wrong with NSArray, NSSet & NSDictionary--but the library of
data structures & algorithms in C++ is far more extensive.

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


___

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

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

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

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


Re: ObjC in time-critical parts of the code

2009-01-19 Thread Scott Ribe
> You're not going to do better straight out of the gate,
> certainly not re-writing them in straight-C.

Of course not. I'm not sure anybody has suggested that (long thread,
could've missed it if it happened). But some of us have suggested not being
automatically averse to C++/STL. Those containers are also highly optimized,
and are able to take advantage of static type info to enable optimization
that you simply cannot get with Objective-C objects & containers.

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


___

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

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

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

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


Re: Trying to display a simple sheet

2009-01-19 Thread Scott Ribe
NSApp beginSheet is the correct method, without any runModalForWindow.

The modalForWindow argument is *not* the sheet window, it is the window on
which to display the sheet. And of course you don't create an empty sheet to
display it...

I'm guessing that [sourceTableView window] is the window you want to display
as a sheet, and the window on which you want to display is not shown in your
code--but your code sample doesn't provide enough context to really see
what's going on.

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


___

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

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

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

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


Coredate: change source Entity in IB

2009-01-19 Thread Alejandro Rodriguez

Hello,

I have a source list populated with some data. Those entities children  
are shown on a separate table where one of the columns is the name of  
the source. I would like that column to use an NSComboCell with the  
available sources so when the user pricks one from the list then his  
source should change and the item moved. I am sure this is pretty  
standard so maybe there is something I'm overlooking.


I appreciate any guidance.

Regards
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 Fundamentals Guide" Clarification

2009-01-19 Thread Scott Ribe
> Just write your code in Obj-C. When you have a finished application,
> then start profiling performance.

Exactly, I'd have to disagree with the advice quoted by OP. The real reason
to use plain functions is to keep them out of the class's API/contract
and/or global namespace if they don't need to be there--and that is not what
I would call "beginner friendly" advice at all.

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


___

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

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

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

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


Re: Binding of invisible controls: is lazy data loading possible?

2009-01-19 Thread Quincey Morris

On Jan 19, 2009, at 15:11, Ken Thomases wrote:

[1] The indexed to-many accessors for array properties are described  
here:


http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ 
/apple_ref/doc/uid/20002174-178830-BAJEDEFB


Incidentally ...

If anyone can find a place in any documentation or header files that  
*says* the indexed to-many accessors (such as  
insertObject:inAtIndex: and removeObjectFromAtIndex:) are  
KVO-compliant when used directly, you'd be doing a public service by  
posting a link.


I can find nothing that says that these methods generate KVO  
notifications when called. AFAICT they are described only as part of  
the implementation of mutableArray/SetValueForKey/KeyPath:, and it  
would be possible to conclude from the documentation that the  
notifications are generated by the proxy class, not by the indexed  
accessors.


Yes, I know that the indexed accessors *do* generate KVO notifications  
(I wrote code to be sure), but the question is whether they're  
*documented* to do so, and if therefore that behavior is API-guaranteed.



___

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

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

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

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


Re: Binding of invisible controls: is lazy data loading possible?

2009-01-19 Thread mmalc Crawford


On Jan 19, 2009, at 5:25 PM, Quincey Morris wrote:

If anyone can find a place in any documentation or header files that  
*says* the indexed to-many accessors (such as  
insertObject:inAtIndex: and removeObjectFromAtIndex:) are  
KVO-compliant when used directly, you'd be doing a public service by  
posting a link.






In order to be considered KVO-compliant for a specific property, a  
class must ensure the following;


* The class must be key-value coding compliant for the property as  
specified in “Ensuring KVC Compliance”.


->





mmalc

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: CoreData entity mutability

2009-01-19 Thread Kyle Sluder
On Mon, Jan 19, 2009 at 8:39 AM, Antoine Maillard
 wrote:
> How can I convert a NSManagedObject of type A into type B ?

How often do you do this in regular code?  Is it common for a method
to change the identity of the receiver before returning?  Hopefully
the answer is no (KVO trickery aside ;) ).

Just remove the object and replace it with an managed object of entity B.

--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: Using the security framework

2009-01-19 Thread Joe Turner

On Jan 6, 2009, at 10:45 AM, Nick Zitzmann wrote:



On Jan 3, 2009, at 6:50 PM, Joe Turner wrote:

I am making a hard drive cloner/backuper, and to do some deleting  
and copying, I need to use the security framework. What I need to  
be able to do is have the user type in their password one time, and  
then it would give me system.privilege.admin rights until a time  
that they want to unauthorized it (could be days, weeks, months,  
years). I have looked through the security framework, but have not  
really found how to have one system.privilege.admin authorization,  
and have it last a long time. So, if anyone could point me in the  
right direction with this, like what methods to use, and what  
parameters to use.


If you pre-authorize an admin authorization, then it will last for  
300 seconds and then must be renewed. This is not something you can  
programmatically change; it's set in the computer's /etc/ 
authorization file.


That makes sense, but then how does an app like SuperDuper! do it. You  
click the lock, enter your password, and then you don't need to enter  
your password again until you lock it again. And, it is the regular  
security framework password window, so the developer must be doing  
some sort of authorization that lasts forever. And I checked, it does  
authorize system.privilege.admin.



I'm also wondering another thing. To delete the files, I need admin  
privileges, but, do I need to create a new target (e.g. a shell  
script) to do the copying and then run the command (blanking on the  
name) that runs the script at a given path with admin privileges.  
Or, could I somehow use NSFileManager in an authorized state.



You have to have something else do the work, since the security  
model of Mac OS X (and all Unix-like OSes) do not allow the  
escalation of privileges in an existing task.
Makes sense. So, if I create a separate target for the unix script, do  
I need to add something to it that takes the authorization? Or will  
anything it does that uses admin files be allowed?


Thanks a lot!

Joe



Nick Zitzmann






___

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

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

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

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


Re: Using the security framework

2009-01-19 Thread Rob Keniger


On 20/01/2009, at 12:56 PM, Joe Turner wrote:

That makes sense, but then how does an app like SuperDuper! do it.  
You click the lock, enter your password, and then you don't need to  
enter your password again until you lock it again. And, it is the  
regular security framework password window, so the developer must be  
doing some sort of authorization that lasts forever. And I checked,  
it does authorize system.privilege.admin.



The padlock is an SFAuthorizationView and it handles some of this,  
although I've not used it myself.


--
Rob Keniger



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


NSView behaves different on 10.4 vs 10.5?

2009-01-19 Thread Adam Gerson
I am trying to help someone solve a problem with their code. I did not
write the code myself. As far as I can tell they have a custom NSView
subclass that has some subviews. The view represents a hand of playing
cards. The subviews themselves are custom NSButton subclasses that
represent individual playing cards.

The cards in the hand are drawn overlapping. Everything works fine
under 10.5. Which is to say that when you click on a playing card
nothing happens. We want NOTHING to happen when we click on a card.
Under 10.4 when you click on a card the individual playing card
appears to get redrawn on top of the other cards. You can see an
example in this short screen capture:

https://dl.getdropbox.com/u/30035/cards.swf

I have tested this with a verity of built in views and buttons and
cant recreated the mouseDown event causing the subview/NSButton to get
redrawn ontop of other views or buttons layered beneath it.

Could anyone shed some slight on what could be occurring?

Thanks,
Adam
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSView behaves different on 10.4 vs 10.5?

2009-01-19 Thread Jim Correia

On Jan 19, 2009, at 10:36 PM, Adam Gerson wrote:


The cards in the hand are drawn overlapping.


[...]


Could anyone shed some slight on what could be occurring?


Overlapping sibling views are supported on 10.5 and later.

If you need to support 10.4, you'll have to use a different strategy  
for your cards.


- 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


NsCollectionView Selection

2009-01-19 Thread Sandro Noel


Greetings.

I'm using NSCollectionView in my application.
I've defined the represented object's layout in interface builder.
and now everything displays nicely on screen
with a couple of exceptions.

When I select an element, there is no selection indicator to show the  
selected item.
( blue color in the background ) like all the other applications on my  
Mac.


and when i click on one of the elements in the represented object,
wether it might be an image or a Label the selection does not happen.
How can i avoid that?

I've looked at apple's documentation on NSCollectionView and well,  
it's kind of thin.


I've also looked at the example provided by apple, but they use and  
NSBox as the represented object view and

the transparent property to show selection, witch is kind of cheep.

I was wondering, if i want to have a nice selection indicator, with  
the common colors of the current system

what is it that i have to do ?

do I have to subclass the NSView and implement my own drawing routines?
do I have to implement a controller for the view?

Can someone point me in he right direction :) please?

regards
Sandro Noel.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSView behaves different on 10.4 vs 10.5?

2009-01-19 Thread Graham Cox


On 20 Jan 2009, at 2:36 pm, Adam Gerson wrote:


The cards in the hand are drawn overlapping.

Could anyone shed some slight on what could be occurring?



10.4 doesn't support overlapping views.

Using a separate view for each card is a bad idea anyway. Instead,  
just use a custom object and get the main view to draw each one.


I recall seeing some Apple sample code that implements a variety of  
card games in a very adaptable way, and also does lots of cool  
animation. That would probably be a great base for a game like this.  
Google for 'geekgameboard'.


hth, 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: NsCollectionView Selection

2009-01-19 Thread Graham Cox


On 20 Jan 2009, at 2:42 pm, Sandro Noel wrote:

When I select an element, there is no selection indicator to show  
the selected item.


True, you have to arrange this.

I've also looked at the example provided by apple, but they use and  
NSBox as the represented object view and

the transparent property to show selection, witch is kind of cheep.


The great advantage of this approach is that you can simply bind the  
"visible" property of the box to the selection and it just works.  
Cheap? Yes, that's what's good about it!


I was wondering, if i want to have a nice selection indicator, with  
the common colors of the current system

what is it that i have to do ?


You could use the custom NSBox approach and set its background colour  
to your system highlight colour. That would require a very minimal  
amount of code and no subclassing.


--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: NsCollectionView Selection

2009-01-19 Thread Sandro Noel

Thank you Graham,

But I'm not looking for the lazy approach,
I really want the app to be good looking, I like Mac apps because they  
are fancy, I want my app to be fancy too :)


Besides I'm learning, so I might as well learn to do it the right way :)
that's why i ask :))

So i hear that if i want something to look good i have to subclass it ?

Sandro Noel.

On 19-Jan-09, at 10:50 PM, Graham Cox wrote:



On 20 Jan 2009, at 2:42 pm, Sandro Noel wrote:

When I select an element, there is no selection indicator to show  
the selected item.


True, you have to arrange this.

I've also looked at the example provided by apple, but they use and  
NSBox as the represented object view and

the transparent property to show selection, witch is kind of cheep.


The great advantage of this approach is that you can simply bind the  
"visible" property of the box to the selection and it just works.  
Cheap? Yes, that's what's good about it!


I was wondering, if i want to have a nice selection indicator, with  
the common colors of the current system

what is it that i have to do ?


You could use the custom NSBox approach and set its background  
colour to your system highlight colour. That would require a very  
minimal amount of code and no subclassing.


--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: NsCollectionView Selection

2009-01-19 Thread Graham Cox


On 20 Jan 2009, at 3:10 pm, Sandro Noel wrote:


But I'm not looking for the lazy approach,
I really want the app to be good looking, I like Mac apps because  
they are fancy, I want my app to be fancy too :)


Besides I'm learning, so I might as well learn to do it the right  
way :)

that's why i ask :))

So i hear that if i want something to look good i have to subclass  
it ?



Can you be more specific about what doesn't look good with the NSBox  
approach? Most collection views I've seen (and those I've implemented  
myself) use this approach and they look fine. Apple appear to be  
adopting a round-cornered selection for standard UI (such as  
IKImageBrowserView) and a custom NSBox provides this functionality  
perfectly. (Note, depending on your needs you might find that  
IKImageBrowserVIew might do what you want - it's higher level than  
NSCollectionView and takes care of a lot of the ugly details for you.).


The only thing I can think of that you might be after is a selection  
that contained a gradient or background other than a flat colour (note  
NSBox can have a semi-transparent background also). In this case you'd  
probably need to subclass.


As for it being a lazy approach, I don't see that. If you want to  
spend all your time implementing a selection highlight go ahead, but  
most of us have better things to do! Lazy it may (arguably) be, but  
it's definitely not the wrong way.


--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: NSView behaves different on 10.4 vs 10.5?

2009-01-19 Thread Adam Gerson
"For performance reasons, Cocoa does not enforce clipping among
sibling views or guarantee correct invalidation and drawing behavior
when sibling views overlap."

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaViewsGuide/WorkingWithAViewHierarchy/chapter_5_section_5.html

On Mon, Jan 19, 2009 at 10:36 PM, Adam Gerson  wrote:
> I am trying to help someone solve a problem with their code. I did not
> write the code myself. As far as I can tell they have a custom NSView
> subclass that has some subviews. The view represents a hand of playing
> cards. The subviews themselves are custom NSButton subclasses that
> represent individual playing cards.
>
> The cards in the hand are drawn overlapping. Everything works fine
> under 10.5. Which is to say that when you click on a playing card
> nothing happens. We want NOTHING to happen when we click on a card.
> Under 10.4 when you click on a card the individual playing card
> appears to get redrawn on top of the other cards. You can see an
> example in this short screen capture:
>
> https://dl.getdropbox.com/u/30035/cards.swf
>
> I have tested this with a verity of built in views and buttons and
> cant recreated the mouseDown event causing the subview/NSButton to get
> redrawn ontop of other views or buttons layered beneath it.
>
> Could anyone shed some slight on what could be occurring?
>
> Thanks,
> Adam
>
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NSView behaves different on 10.4 vs 10.5?

2009-01-19 Thread Kyle Sluder
On Mon, Jan 19, 2009 at 10:45 PM, Graham Cox  wrote:
> Using a separate view for each card is a bad idea anyway. Instead, just use
> a custom object and get the main view to draw each one.

I'd recommend abstracting out the card-drawing code into a subclass of
NSButtonCell and using that cell to draw the hand inside an NSView
subclass.  Then you don't have to worry about sibling view clipping
issues, and you minimize the number of views you have to boot.

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


NSData release seg fault. Whoops.

2009-01-19 Thread nik heger
I figured out how to make this code "work" but I still don't know what  
the problem was. Can someone enlighten me?


- (void)testSegFault {
int size = 8;
uint8_t *bytes = malloc( size * sizeof(uint8_t) );
NSData *data = [NSData dataWithBytesNoCopy:bytes length:size];
		[data release];// this causes a seg fault comment it out and  
everything works.

}

According to the NSData documentation, the NSData object will take  
ownership of the array I created with malloc. So far so good but why  
don't I have to release it? Or is there something sinister going on  
with the uint8_t data type vs. size of the byte(?) array?


thanks,

Nik
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: real noob question

2009-01-19 Thread Kyle Sluder
On Sat, Jan 17, 2009 at 11:41 PM, Richard Dammkoehler  wrote:
> NSDecimalNumber *num = [[NSDecimalNumber alloc] initWithString:"23.30"];

1) That's not an ObjC string, it's a C string.  That will crash unless
you replace it with @"23.30".
2) If the current locale isn't one that uses a period as the decimal
separator, that is not a valid number.
3) You are invoking the parser to convert hard-coded digits into an
NSDecimalNumber instance.  Why not just provide the number directly,
avoiding the parser altogether?  It's a constant, there's no need to
make the framework do more interpretation on it than necessary.

--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: NSData release seg fault. Whoops.

2009-01-19 Thread Kyle Sluder
On Mon, Jan 19, 2009 at 11:39 PM, nik heger  wrote:
> I figured out how to make this code "work" but I still don't know what the
> problem was. Can someone enlighten me?

+dataWithBytesNoCopy:length: is not +alloc.  Therefore you don't own
it.  If you turn around and release it, you are violating the memory
management rules.

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


Custom Cocoa Component/Control

2009-01-19 Thread Paul Franz
I know this is a noob question but I do not know where to look. I come for a 
Java background. So I know what to do there, but I look at Cocoa and I have no 
clue where to start since the object model is quite a bit different.


Should I create a sub-class of NSControl or do something else?

I want to have a bunch of icons (like the Finder images including the text 
underneath it) in a window. These would be used to traverse a hierarchy of 
objects (i.e. double click and it shows another list of icons). Originally, I 
was going to implement this all in my NSView class. But I was thinking that this 
does not seem to be the correct way implementing it.


I looked and found something about "Subclassing NSControl" (URL: 
http://developer.apple.com/documentation/Cocoa/Conceptual/ControlCell/Tasks/SubclassingNSControl.html 
) but I am not sure if this is the correct approach. If so, what are the methods 
I need to override to make sure that the size is maintained? The 
control/component will need to react to mouse clicks but the NSView will be 
handling the dragging of the position of this control/component.


Paul Franz
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


Problem setting up custom toolbar item in IB

2009-01-19 Thread Graham Cox
I'm having trouble setting up a custom toolbar item. It looks like it  
should work and appears in IB OK but doesn't come up correctly at  
runtime. I  must be doing something wrong:


The toolbar item consists of a pair of NSTextFields and some labels.  
They must be grouped together as a single toolbar item so I have  
created a custom view that holds the items. I can drag the custom view  
into the toolbar items panel in IB and they appear there OK. I can  
hook up the fields to my controller.


At runtime I only see the toolbar item label and not the text fields  
or other labels. I can drag the item to the toolbar but it still just  
shows the label.


When my controller tries to set one of the field's values I get either  
a EXC_BAD_ACCESS, or an exception that NSData doesn't implement - 
setFloatValue:, but at awakeFromNib time I can see the text field  
outlets are set and are indeed NSTextFields. By the time the method is  
called to update the fields (a notification callback), the outlets  
have the same addresses but they point to garbage.


The controller isn't referenced from any other object in the nib, but  
that should be OK, right? Not using garbage collection.


Any ideas?

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


Search Fields, Array Controllers and Multiple NIBs

2009-01-19 Thread Brad Gibbs
I'm having a fundamental disagreement with Cocoa and I'm really hoping  
someone can help me see it her way...


I have a Core Data app with a container view controller and multiple  
subviews, each with a view controller and a separate NIB.  Subview  
switching is done via a segmented control.  The subviews each display  
the same data, but in different ways -- one is a table view, another  
is an image view and the third is a cover flow view.


The container view displays the segmented control that does the  
switching and a search field that is used to filter what is shown in  
the subviews.  My aim is to have the search field filter the three  
views equally, such that if the user performs a search, all three  
subviews will show the filtered results of that search.  So, the user  
the perform the search and each of the three views will display the  
filtered results of the same search.


I've tried a number of approaches.  To me, it seems the most logical  
approach is to have the container view pass its MOC and  
NSArrayController instance to each of the subviews as it creates  
them.  I still need to create an NSArrayController instance in each  
view's NIB file in IB to bind the objects in each of the views, but I  
can create an outlet in each view controller and set it to the  
NSArrayController instance passed in from the main view when the  
subview is instantiated.  But, this doesn't seem to work.  I can NSLog  
each array controller to see that each view has the same instance of  
the NSArrayController, but searching in the main view doesn't seem to  
filter any of the subviews properly.


I'm sure I haven't described the issues clearly but I'm hoping someone  
will understand this well enough to propose a solution.


Thanks in advance,

Brad
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: [NOOB] Finding Information (was: real noob question)

2009-01-19 Thread Michael Ash
On Mon, Jan 19, 2009 at 2:57 PM, Brian Slick  wrote:
> I'm not sure this is a documentation failure as much as a language failure,
> at least in this case.  Why isn't there an initWithInt: or initWithFloat:
> like in some other cases?  THAT would have resulted in the documentation
> page leading to the correct answer.  Mantissa?  Come on.

I really don't see the problem with this. While Apple generally does a
good job of insulating you from the details of how things work
underneath, you still have to know *something* about how things are
built. NSDecimalNumber is fundamentally built around mantissa and
exponent. Thinking the document is inadequate because it relies on
these concepts would be like thinking that the NSString documentation
is inadequate because it relies on the concept of "character".

There are basically only three ways to make a variable NSDecimalNumber
that are mentioned in the documentation. If faced with this problem,
it sure seems to me that it would be worth investigating all of them
before giving up.

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: Memory allocation issues with NSObject and NSString

2009-01-19 Thread Michael Ash
On Mon, Jan 19, 2009 at 6:14 PM, Ben Trumbull  wrote:
>> I sure hope not! The documentation for the method states:
>>
>> "The init method defined in the NSObject class does no initialization;
>> it simply returns self."
>>
>> Making it do anything else would be a serious breach of the API contract.
>
> That is a matter of perspective.  And why lawyers plague the world.  "no
> initialization" is not the same as "absolutely not a single CPU
> instruction".  For example, this tech writer might have meant "no
> initialization of this object", which would be obvious, not realizing that
> someone else would read that and wrongly infer that they could safely skip
> using it correctly as demonstrated in the code box right next to the words.

Perspective, nuts! Given the context, it's about as clear as you could
possibly get that this method does nothing but return self. The use of
the word "simply", the "no initialization" when describing an init
method, the utter pointlessness of the sentence if other work were
being done, it all leads to a single conclusion. Quite frankly, any
tech writer who wrote the above sentence with the intent of allowing
for other activities to take place would be so bad at his job that he
should be fired and replaced by someone competent.

The rest of the discussion is about how to deal with -init in the
general case, not NSObject's specific implementation thereof, so it
does not apply.

I maintain that NSObject -init is guaranteed to do nothing, and
changing this fact would seriously break the API contract.

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: Binding of invisible controls: is lazy data loading possible?

2009-01-19 Thread Quincey Morris

On Jan 19, 2009, at 17:33, mmalc Crawford wrote:


On Jan 19, 2009, at 5:25 PM, Quincey Morris wrote:

If anyone can find a place in any documentation or header files  
that *says* the indexed to-many accessors (such as  
insertObject:inAtIndex: and removeObjectFromAtIndex:) are  
KVO-compliant when used directly, you'd be doing a public service  
by posting a link.






In order to be considered KVO-compliant for a specific property, a  
class must ensure the following;


* The class must be key-value coding compliant for the property as  
specified in “Ensuring KVC Compliance”.


->




Well, yes, but that's not the answer to my question. It says:

If the to-many related objects are mutable, and the - method  
does not return an NSMutableArray, you must also implement - 
insertObject:inAtIndex: and -removeObjectFromAtIndex:.


This says what a class needs to do to *be* KVO-compliant, not whether  
calling these methods is the actual means of triggering the  
notification -- it doesn't say what you need to call to *change* the  
property KVO-compliantly.


I'm not just splitting hairs here, though I am parsing the terminology  
very finely. If you go to the place where these accessors are actually  
described:


	http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ 
/apple_ref/doc/uid/20002174-178830-BAJEDEFB


the only thing it says about how to get mutable access is:

The key-value coding methods mutableArrayValueForKey: and  
mutableArrayValueForKeyPath: provide mutable access to a to-many  
relationship, regardless of the class used to model the relationship.


In order to support these methods, your class must implement two  
additional methods for each of these keys: - 
insertObject:inAtIndex: and -removeObjectFromAtIndex:.  
[...] The example in Listing 6 shows the methods required to support  
mutableArrayValueForKey: for the to-many transactions property.


From this, you could get the idea that the class must *have* the  
accessors to "support" or "implement" KVO-compliance, but that you  
must *use* the mutableArrayValue proxy to make the change. It's not  
inconsistent with the documentation that the implementation of the  
mutableArrayValue proxy class might be in effect like this:


[object willChange...];
[object insertObject: ... inAtIndex:...];
[object didChange...];

There's plenty of documentation that says that the insert/remove  
methods are the implementation of the to-many access, but none that  
they are suitable for the class's public interface.


IAC, the original quote is weird in other ways:

If the to-many related objects are mutable, and the - method  
does not return an NSMutableArray, you must also implement - 
insertObject:inAtIndex: and -removeObjectFromAtIndex:.


The mutability of the related objects is irrelevant: it's the  
mutability of the relationship property itself that is at stake.


It also suggests that if the - method *does* return a  
NSMutableArray, you don't have to implement insert/remove methods but  
the property is still KVO-compliant for changes. (I believe I have  
code that actually relies on this, and that it does work, but I would  
have to go searching for it to be sure.) This is not said anywhere  
else (not in the mutableArrayValueForKey documentation, nor in  
NSKeyValueCoding.h), and actually contradicts part of what Ken  
Thomases said earlier in the thread. So that's yet another puzzle.



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: ObjC in time-critical parts of the code

2009-01-19 Thread Michael Ash
On Mon, Jan 19, 2009 at 2:49 AM, Ben Trumbull  wrote:
>> Well no, it doesn't. ObjC has functions, by virtue of being a superset
>> of C, but it does not have "member functions". You can write functions
>> that are logically associated with a class, but this is a human
>> construct, not one that the compiler knows about.
>
> Not sure what compiler you're using, but mine can tell the difference:
> #import 
> @interface Foo : NSObject {
> @private id a;
> }
> @end
> static id plainCFunction(Foo* f);
> static id memberCFunction(Foo* f);
> static id plainCFunction(Foo* f) {
> return f->a;
> }
> @implementation Foo
> static id memberCFunction(Foo* f) {
> return f->a;
> }
> @end
>
> /tmp/members/members.m: In function 'plainCFunction':
> /tmp/members/members.m:12: warning: instance variable 'a' is @private; this
> will be a hard error in the future

That's just a slight modification of access permissions due to the
placement of the function definition. It does not make it a "member",
which to me would mean some kind of namespacing, ownership, or at
least some kind of association with the class. Although the access
permissions are somewhat relaxed, the function is still not associated
with your class in any way.

A minor quibble, but I think it's important, as for example there's no
way to get any information about the function using the Objective-C
runtime, and there's no way to even find out whether the function is a
"member" or not besides diving into the .m file and seeing whether
it's inside or outside the @implementation block.

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: NsCollectionView Selection

2009-01-19 Thread Sandro Noel

Graham.

I did not mean Lazy in an offensive way :)
I meant it as I want to learn the real stuff and understand how it  
works.
The documentation is hefty and sometimes confusing, so I ask for  
advice :)


I do want a gradient semi-transparent look, it find it sleek.
besides once it's designed, I can reuse, so to me it's not a waste of  
time.


I'll give a closer look at the NSBox, see what I can pull out of it.
If I can subclass the NSBox and have it draw a gradient then that  
would be ok for me.


Thank you Graham.

Sandro Noel.

On 19-Jan-09, at 11:24 PM, Graham Cox wrote:



On 20 Jan 2009, at 3:10 pm, Sandro Noel wrote:


But I'm not looking for the lazy approach,
I really want the app to be good looking, I like Mac apps because  
they are fancy, I want my app to be fancy too :)


Besides I'm learning, so I might as well learn to do it the right  
way :)

that's why i ask :))

So i hear that if i want something to look good i have to subclass  
it ?



Can you be more specific about what doesn't look good with the NSBox  
approach? Most collection views I've seen (and those I've  
implemented myself) use this approach and they look fine. Apple  
appear to be adopting a round-cornered selection for standard UI  
(such as IKImageBrowserView) and a custom NSBox provides this  
functionality perfectly. (Note, depending on your needs you might  
find that IKImageBrowserVIew might do what you want - it's higher  
level than NSCollectionView and takes care of a lot of the ugly  
details for you.).


The only thing I can think of that you might be after is a selection  
that contained a gradient or background other than a flat colour  
(note NSBox can have a semi-transparent background also). In this  
case you'd probably need to subclass.


As for it being a lazy approach, I don't see that. If you want to  
spend all your time implementing a selection highlight go ahead, but  
most of us have better things to do! Lazy it may (arguably) be, but  
it's definitely not the wrong way.


--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: NsCollectionView Selection

2009-01-19 Thread Sandro Noel

Graham.

NSbox will not let me set the background color if the Box Type is not  
custom,

If I do that I lose the rounded borders. :(
and i can't set the border colors either if the box type is not custom.

do you have a suggestion?

Sandro Noel.

On 19-Jan-09, at 11:24 PM, Graham Cox wrote:



On 20 Jan 2009, at 3:10 pm, Sandro Noel wrote:


But I'm not looking for the lazy approach,
I really want the app to be good looking, I like Mac apps because  
they are fancy, I want my app to be fancy too :)


Besides I'm learning, so I might as well learn to do it the right  
way :)

that's why i ask :))

So i hear that if i want something to look good i have to subclass  
it ?



Can you be more specific about what doesn't look good with the NSBox  
approach? Most collection views I've seen (and those I've  
implemented myself) use this approach and they look fine. Apple  
appear to be adopting a round-cornered selection for standard UI  
(such as IKImageBrowserView) and a custom NSBox provides this  
functionality perfectly. (Note, depending on your needs you might  
find that IKImageBrowserVIew might do what you want - it's higher  
level than NSCollectionView and takes care of a lot of the ugly  
details for you.).


The only thing I can think of that you might be after is a selection  
that contained a gradient or background other than a flat colour  
(note NSBox can have a semi-transparent background also). In this  
case you'd probably need to subclass.


As for it being a lazy approach, I don't see that. If you want to  
spend all your time implementing a selection highlight go ahead, but  
most of us have better things to do! Lazy it may (arguably) be, but  
it's definitely not the wrong way.


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


draw two strokes(lines) simultaneousy on NSView

2009-01-19 Thread Gami Ravi
Hi All,
I want to create an application that will draws two strokes simultaneously on 
NSView. How can i draw two strokes simultaneously ?
Any help would be appreciated.


Thanks & Regards,
Ravi Gami.

--
_
Disclaimer: This e-mail message and all attachments transmitted with it
are intended solely for the use of the addressee and may contain legally
privileged and confidential information. If the reader of this message
is not the intended recipient, or an employee or agent responsible for
delivering this message to the intended recipient, you are hereby
notified that any dissemination, distribution, copying, or other use of
this message or its attachments is strictly prohibited. If you have
received this message in error, please notify the sender immediately by
replying to this message and please delete it from your computer. Any
views expressed in this message are those of the individual sender
unless otherwise stated.Company has taken enough precautions to prevent
the spread of viruses. However the company accepts no liability for any
damage caused by any virus transmitted by this email.
__

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: NsCollectionView Selection

2009-01-19 Thread Graham Cox


On 20 Jan 2009, at 4:59 pm, Sandro Noel wrote:

NSbox will not let me set the background color if the Box Type is  
not custom,

If I do that I lose the rounded borders. :(
and i can't set the border colors either if the box type is not  
custom.



That's not the case - you ONLY get rounded corners if the box type is  
custom.


You can set it all in IB - the border width, margins and corner radius  
are all set in the "size" section of the palette. The colours for the  
border and fill are set in the main section.


--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: draw two strokes(lines) simultaneousy on NSView

2009-01-19 Thread Graham Cox


On 20 Jan 2009, at 5:12 pm, Gami Ravi wrote:

I want to create an application that will draws two strokes  
simultaneously on NSView. How can i draw two strokes simultaneously ?

Any help would be appreciated.


You don't say what you want to stroke, but let's assume a NSBezierPath.

// ...set up stroke parameters for stroke 1 here ...

[path stroke];

// ...set up stroke parameters for stroke 2 here...

[path stroke];



In other words, you just draw one stroke then the other.

If you really want to stroke two lines or other paths  
"simultaneously" (not sure what you mean by that either - nothing is  
truly simultaneous), then you can combine paths into one bezier path  
object and stroke it all at once. However, you can't apply separate  
stroke parameters to different parts of the path this way.


--Graham


___

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

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

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

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


Re: Problem setting up custom toolbar item in IB

2009-01-19 Thread Joey Hagedorn

Graham,

	Hm, maybe this is an issue with the custom view in your nib. Perhaps  
try putting your text fields inside, say,  a borderless NSBox instead?


-Joey


On Jan 19, 2009, at 8:55 PM, Graham Cox wrote:

I'm having trouble setting up a custom toolbar item. It looks like  
it should work and appears in IB OK but doesn't come up correctly at  
runtime. I  must be doing something wrong:


The toolbar item consists of a pair of NSTextFields and some labels.  
They must be grouped together as a single toolbar item so I have  
created a custom view that holds the items. I can drag the custom  
view into the toolbar items panel in IB and they appear there OK. I  
can hook up the fields to my controller.


At runtime I only see the toolbar item label and not the text fields  
or other labels. I can drag the item to the toolbar but it still  
just shows the label.


When my controller tries to set one of the field's values I get  
either a EXC_BAD_ACCESS, or an exception that NSData doesn't  
implement -setFloatValue:, but at awakeFromNib time I can see the  
text field outlets are set and are indeed NSTextFields. By the time  
the method is called to update the fields (a notification callback),  
the outlets have the same addresses but they point to garbage.


The controller isn't referenced from any other object in the nib,  
but that should be OK, right? Not using garbage collection.


Any ideas?

--Graham

___

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

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

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

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


Re: Problem setting up custom toolbar item in IB

2009-01-19 Thread Graham Cox


On 20 Jan 2009, at 3:55 pm, Graham Cox wrote:

When my controller tries to set one of the field's values I get  
either a EXC_BAD_ACCESS, or an exception that NSData doesn't  
implement -setFloatValue:, but at awakeFromNib time I can see the  
text field outlets are set and are indeed NSTextFields. By the time  
the method is called to update the fields (a notification callback),  
the outlets have the same addresses but they point to garbage.



Seems I can't use a custom view here. If I change the view to NSBox,  
it works OK. I'm thinking this is because NSToolbar copies views using  
the archiving/dearchiving trick and a plain NSView doesn't implement  
NSCoding for its subviews (this actually surprises me however).


In this case I can use NSBox with a custom setting and it looks OK.

Next problem, my controller "loses" its connections to the fields in  
the toolbar item. Again, on reflection I should have expected this -  
the outlets are to the toolbar item's prototype view, not the copy  
that is placed into the toolbar. It looks as if I need to implement  
the toolbar delegate methods and fix up the connections manually,  
unless anyone has any better ideas?


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


  1   2   >