Re: Non-pageable app

2009-04-05 Thread Stephen J. Butler
On Mon, Apr 6, 2009 at 1:14 AM, Chris Suter  wrote:
> Right, but someone who has physical access to the machine can do
> whatever they like. They could open the box and probe the memory
> directly somehow or add a malicious bit of software to get the details
> later.

My favorite attack involves using a special firewire device to
initiate DMA transfers to read memory. Setting a firmware password
prevents this on OS X.
___

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

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

Help/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: NSButton not responding to click in worker thread

2009-04-05 Thread m
UI events are reported on the main thread. If your main thread is  
blocked, you will not receive any events.


_murat


On Apr 5, 2009, at 11:20 PM, Vijay Kanse wrote:


Hello All,
I have separated my task on thread when my main thread is blocked.
I am not able to find where my main thread is blocked. Separating my  
task on

worker thread  i am not able to get button click event.

I think this is because of main thread is blocked.

How can i find where my main thread is blocked ?
or is there any solution to get button click event in worker thread  
while

main thread is blocked ?
After execution of worker thread , i am getting my main thread  
working and i

am getting event of clicked button.



Thanks.
___

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

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

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

This email sent to mlist0...@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: NSButton not responding to click in worker thread

2009-04-05 Thread Kyle Sluder
On Mon, Apr 6, 2009 at 2:20 AM, Vijay Kanse  wrote:
> I have separated my task on thread when my main thread is blocked.
> I am not able to find where my main thread is blocked. Separating my task on
> worker thread  i am not able to get button click event.

UI events must be handled on the main thread.

--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: Question re: [NSWindow setFrame:display:]

2009-04-05 Thread Kyle Sluder
On Mon, Apr 6, 2009 at 2:07 AM,   wrote:
> In my NSDocument subclass, I am trying to set the main window's frame in the
> windowControllerDidLoadNib: method. For some reason, I can set the width and
> height of the window's frame, but not its origin. Any ideas? I am using the
> setFrame:NSMakeRect(x, y, w, h) display:YES

See -[NSWindowController shouldCascadeWindows].  If you don't override
-[NSDocument makeWindowControllers], NSDocument makes one for you
(using the return value of -windowNibName), and the default behavior
of NSWindowController is, as the documentation says, to automatically
cascade the window.

The solution is to override -makeWindowControllers and create your own
NSWindowController, calling -setShouldCascadeWindows: as appropriate.

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


NSButton not responding to click in worker thread

2009-04-05 Thread Vijay Kanse
Hello All,
I have separated my task on thread when my main thread is blocked.
I am not able to find where my main thread is blocked. Separating my task on
worker thread  i am not able to get button click event.

I think this is because of main thread is blocked.

How can i find where my main thread is blocked ?
or is there any solution to get button click event in worker thread while
main thread is blocked ?
After execution of worker thread , i am getting my main thread working and i
am getting event of clicked button.



Thanks.
___

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

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

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

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


Re: Non-pageable app

2009-04-05 Thread Chris Suter
Hi Kyle,

On Mon, Apr 6, 2009 at 4:03 PM, Kyle Sluder  wrote:
> On Sun, Apr 5, 2009 at 8:07 PM, Chris Suter  wrote:
>> What am I missing?
>
> If the attacker physically powers off the machine while the page is
> written out to disk, s/he can just read the page off the swap space on
> the HDD.  If this page contains, say, an initialization vector, then
> bang you're dead.

Right, but someone who has physical access to the machine can do
whatever they like. They could open the box and probe the memory
directly somehow or add a malicious bit of software to get the details
later.

As someone else pointed out to me, it would kind of make sense if you
were worried about the machine being stolen but even then, I suspect
it would be beyond your average thief to get the details; I mean you'd
expect them to have better sources of income than from stealing.

I guess you have to weigh up the risk with the effort involved; I
can't see that it's worth the effort.

Anyway, this is probably getting a little off-topic.

Regards,

Chris
___

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

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

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

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


Question re: [NSWindow setFrame:display:]

2009-04-05 Thread livinginlosangeles
In my NSDocument subclass, I am trying to set the main window's frame  
in the windowControllerDidLoadNib: method. For some reason, I can set  
the width and height of the window's frame, but not its origin. Any  
ideas? I am using the setFrame:NSMakeRect(x, y, w, h) display:YES


[[self windowForSheet] setFrame: NSMakeRect(0,0,100,100) 
display:YES];

LA
___

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

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

Help/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: Non-pageable app

2009-04-05 Thread Kyle Sluder
On Sun, Apr 5, 2009 at 8:07 PM, Chris Suter  wrote:
> What am I missing?

If the attacker physically powers off the machine while the page is
written out to disk, s/he can just read the page off the swap space on
the HDD.  If this page contains, say, an initialization vector, then
bang you're dead.

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


Inserting text in UITextView without scrolling animation (2)

2009-04-05 Thread Ignacio Enriquez
Hi...
Last week I wrote the same question and there was no answer... I hope
this time there is a answer.

I am trying to implement a customized Keyboard using UIView,
UIButtons, and UITextViewDelegate methods for getting the actual
location of the cursor inside of a UITextView object.

Everything goes great until the input text becomes so big that it has
to be scrolled.
The problem is that every time the hole text is actually replaced and
is scrolled (with animation) until the position it was before. And
when making several character inputs the text scrolls with such a
frecuency that is looks like it is trembling or is been shacked.
I think a solution would be to find a way to set the new text without
animation. or maybe not replacing he hole text, just inserting the new
character in the present text. Though I think the last one is
impossible since text property is "copy"

@property(nonatomic, copy) NSString *text


Is there any way I can achieve setting a new text without scrolling
animation? (just scroll would be great.)

Thanks in Advance.



-- 
_
Guillermo Ignacio Enriquez Gutierrez
_
___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Greg Guerin

Michael Ash wrote:


Good point. Although this has the disadvantage of temporarily using a
bunch of memory, roughly doubling your footprint for this data
structure, that's not likely to be a problem for the typical use cases
for this thing.


I don't see why it should take extra memory.

As you say, there will be a larger NSData footprint, roughly double,  
if a single NSMutableData is used to accumulate all the individual  
NSData's, and that NSMutableData is then hashed as the final step.   
However, I know of no requirement to do it that way.


A secure-hash algorithm can usually be called incrementally.  Each  
object to be hashed returns its NSData, and that chunk of bytes is  
then digested into the cumulative secure-hash value.  Any blocking  
needed by the hash is typically done internal to the hash algorithm  
itself.  Even if the series of objects represented by an NSArray or  
NSDictionary were evaluated using simple traversal, there's still  
only a need for one NSData from one primitive object at a time.  And  
you can put an autorelease pool at any level of the traversal, should  
it seem prudent.


For example, see the openssl functions SHA1_Init(), SHA1_Update(),  
and SHA1_Final(), as contrasted to the monolithic SHA1() function.   
This is not unique to SHA1, either; most digests work this way.


Or am I missing something?

  -- GG

___

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

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

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

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


"Word Wrap" and "Character Wrap" in NSTextField

2009-04-05 Thread Jerry Krinock
I have an NSTextField, instantiated in Interface Builder 3.  In  
Interface Builder's Inspector > Attributes I've set:


   Text Field > Layout (popup) > Wraps
   Control > Line Breaks (popup) > Word Wrap

The value binding is bound.  The font size in the text field is 11  
point, and its height is 45 points, enough to fit three lines.


I expect that when the string provided by the model is bigger than can  
fit on one line, it should wrap to the next line, but instead it is  
clipped at the right edge of the first line.  The second and third  
lines are never drawn.  Same thing happens if I type into the field  
(it's editable) -- text just fall off at the right edge.


I get the same result if I set the Line Breaks popup to Character  
Wrap.  There is none of my code touching this NSTextField; it's all  
xib and bindings.


In the list archives, I see several similar issues and confirmed bugs  
in past years, but nothing quite like this.  It looks like it "just  
doesn't work".


Is there something else I need to do?

Thanks

Jerry Krinock
___

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

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

Help/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: Suppressing variable hiding warning in Xcode

2009-04-05 Thread Graham Cox


On 06/04/2009, at 11:06 AM, Bill Bumgarner wrote:


2. How do you get Xcode to not produce this warning?


Don't.  You'll thank yourself for not doing so after spending a few  
hours wondering why an iVar didn't get updated only to find that a  
parameter hid the iVar.



Given that good advice however, Apple really should ensure that  
legitimate code doesn't gratuitously throw this warning.


For example:

var = MIN( MAX( x, y ), z );

will emit this warning for variable '_a' because both macros MIN and  
MAX use the same local var name internally.


--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: Need localization-proof method of transporting dates.

2009-04-05 Thread Michael Ash
On Sun, Apr 5, 2009 at 9:18 PM, Greg Guerin  wrote:
> As a design, it might be more flexible to define a -gc_canonicalData method
> that returns an NSData containing unhashed canonical bytes, rather than
> -gc_sha1hash that returns a hash.  This would make it easier to use
> different secure-hash algorithms, should that be desired.  SHA1 isn't
> exactly state-of-the-art.

Good point. Although this has the disadvantage of temporarily using a
bunch of memory, roughly doubling your footprint for this data
structure, that's not likely to be a problem for the typical use cases
for this thing.

> I'd also make the code that calculates the hash from a given NSDictionary or
> NSArray return an error (or throw an exception) if anything in the
> collection doesn't respond to -gc_canonicalData. Or it could silently skip
> those (not hash them), depending on the context.

Note that it will already throw an exception if something doesn't
respond to the method, simply because this is the default behavior in
NSObject if you send a message to an object that doesn't understand
it. More gentle or controlled failure modes may well be desirable, of
course.

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: Accessing internal lock for atomic properties

2009-04-05 Thread Eric Hermanson
Yes, I understood that, but I figured if all of the synthesized set  
methods are using the same lock, then I could probably take advantage  
of that same lock if it were available to me do to some stuff  
internally on that object.  Anyway, thanks for the confirmation.


- Eric


On Apr 5, 2009, at 11:53 PM, Bill Bumgarner wrote:


On Apr 5, 2009, at 8:50 PM, Eric Hermanson wrote:
I want to acquire the lock so that I can run some logic that  
requires changing a set of variables atomically.  I suppose I'm  
going to have to create a new lock for this.


Yes -- the synthesized locks are only designed to ensure that the  
value set/retrieved is integral regardless of # of threads pounding  
upon it.   Beyond that, it contributes nothing to thread safety.


Multi-property data dependencies must be expressed at a higher  
level, typically by isolating sub-graphs of the objects of the model  
layer to single threads (see Core Data).


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: Accessing internal lock for atomic properties

2009-04-05 Thread Bill Bumgarner

On Apr 5, 2009, at 8:50 PM, Eric Hermanson wrote:
I want to acquire the lock so that I can run some logic that  
requires changing a set of variables atomically.  I suppose I'm  
going to have to create a new lock for this.


Yes -- the synthesized locks are only designed to ensure that the  
value set/retrieved is integral regardless of # of threads pounding  
upon it.   Beyond that, it contributes nothing to thread safety.


Multi-property data dependencies must be expressed at a higher level,  
typically by isolating sub-graphs of the objects of the model layer to  
single threads (see Core Data).


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: Accessing internal lock for atomic properties

2009-04-05 Thread Eric Hermanson
I want to acquire the lock so that I can run some logic that requires  
changing a set of variables atomically.  I suppose I'm going to have  
to create a new lock for this.


- Eric


On Apr 5, 2009, at 11:48 PM, Bill Bumgarner wrote:


On Apr 5, 2009, at 8:43 PM, Eric Hermanson wrote:
Is there any way to access the internal lock used when atomic  
properties are synthesized (assuming a simple @synchronized(self)  
is not used in this case)?


Nope.

What are you trying to do?

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: Accessing internal lock for atomic properties

2009-04-05 Thread Bill Bumgarner

On Apr 5, 2009, at 8:43 PM, Eric Hermanson wrote:
Is there any way to access the internal lock used when atomic  
properties are synthesized (assuming a simple @synchronized(self) is  
not used in this case)?


Nope.

What are you trying to do?

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


Accessing internal lock for atomic properties

2009-04-05 Thread Eric Hermanson

Hello,

Is there any way to access the internal lock used when atomic  
properties are synthesized (assuming a simple @synchronized(self) is  
not used in this case)?


- Eric

___

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

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

Help/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: Beachball on Lengthy Task

2009-04-05 Thread Pierce Freeman
David:

Thanks for all your help, it's almost working...  Just one more question:

Question: I am attempting to "turn" the object returned into a NSDictionary,
but it doesn't seem like something that can be turned into a NSDictionary.
Am I doing something wrong here?  The file is a plist file.


Sincerely,

Pierce Freeman


On 4/5/09 6:36 PM, "Dave Keck"  wrote:

>> 1. Is there any concern of thread safety using this class?
>> 2. How can I pass NSFileHandle the file URL of my files?
>> 3. How could I create a method that will take the contents of the file and
>> do something with them?
> 
> 1. No. NSFIleHandle takes care of creating a separate thread for you,
> and notifies your main thread when it's finished reading the given
> file, with a NSFileHandleReadToEndOfFileCompletionNotification
> notification.
> 
> 2. If you have a NSURL and need to create a NSFileHandle with that,
> simply use NSURL's -path method to get the NSURL's filesystem path.
> Otherwise, just create your file handle with a NSString path using
> -fileHandleForReadingAtPath:.
> 
> 3. Register for the NSFileHandleReadToEndOfFileCompletionNotification
> notification. Once it's received, you can access its respective
> NSFileHandle using the notification's -object method.
> 
> All of this has happened before, and it will all happen again, as they
> say. The answers to 2 & 3 can be found with a little searching - I
> encourage you to do so.
> 
> David


___

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

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

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

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


Re: Suppressing variable hiding warning in Xcode

2009-04-05 Thread Bradley S. O'Hearne

All,

Thanks for the advice. I everyone on the "one extra line of defense"  
rationale. I've worked in languages other than Objective C for years  
where using variable hiding is common practice, not flagged by the  
compiler. But you are right, that is only safe for developers who  
NEVER make a programming error. It took me a relatively short amount  
of time to rule myself out of the never-had-a-bug club.


Brad

On Apr 5, 2009, at 5:21 PM, Chris Suter wrote:


Hi Brad,

On Mon, Apr 6, 2009 at 10:10 AM, Brad O'Hearne
 wrote:

I had a few questions about selectively suppressing a certain  
warning in
Xcode. I personally find the warning which pertains to local  
variables

hiding instance variables a real nuisance. For example, if you have a
message signature with a parameter name which matches an instance  
variable

name, and the compiler produces the following message:

"warning: local declaration of '' hides instance  
variable"


Two questions:

1. I get the gist of trying to prevent developers from accidentally  
hiding
variables -- but is this really a major problem? Other than this,  
is there a

compelling reason to keep this warning in tact, and change variable
parameter variable names to make the warning go away?

2. How do you get Xcode to not produce this warning?


I would urge you not to suppress the warning. It's easy enough to
change one of the names so that they don't clash and it's one more
potential bug (you type the name intending to get the value of the
instance variable but get the parameter instead) you don't have to
worry about.

A lot of people like to prefix their instance variables. Apple use an
underscore which I don't personally like to do because underscore
prefixes tend to be reserved. Other people use different prefixes but
I don't like doing that either because that can complicate things for
KVO and KVC (KVO and KVC know about underscore prefixes).

My personal preference is to prefix the parameter name with either
'a', 'an' or 'the' depending on the context.

If you insist on disabling the warning, "-Wno-shadow" will probably do
the trick. You'd have found that out by looking at the gcc man page.

Kind regards,

Chris


___

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

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

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

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


Re: Puzzling run loop/autorelease pool question

2009-04-05 Thread m
Having my own autorelease pool in my call-back is an approach that I  
tried, and it worked, but I was unsatisfied because from my  
understanding of run loops and autorelease pools, it didn't seem like  
it should be necessary.


Because my app is a Cocoa app, and everything is happening on the main  
thread, there will be an autorelease pool in place. And it seems that  
the run loop machinery would be designed so that the right stuff  
either happens automatically, or that a way would have been be  
provided to make the right stuff happen.


According to Michael's article (thanks Michael!), the former does not  
appear to be the case (the right stuff doesn't happen automatically).


Something that looks like the correct solution is calling  
CFRunLoopWakeUp() in the notification handler. But it doesn't fix the  
problem. Bug?


So in the end, it looks like I'll have to use techniques that, as a  
side effect, cause the right thing to happen.


_murat

On Apr 5, 2009, at 4:56 PM, Chris Suter wrote:


Hi Michael,

On Mon, Apr 6, 2009 at 9:50 AM, Michael Ash   
wrote:

On Sun, Apr 5, 2009 at 5:11 PM, m  wrote:



The workaround is easy. What you're doing is fine, or you can post a
fake NSEvent, or something similar. Pretty much up to you.


Whilst that approach will probably work for ever, I still think you're
better off wrapping your C callbacks with your own NSAutoreleasePool;
nothing really guarantees that an autorelease pool will exist when
you're in a C callback that you've added directly to the runloop via a
C interface.

Regards,

Chris


___

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

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

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

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


Re: Beachball on Lengthy Task

2009-04-05 Thread Dave Keck
> 1. Is there any concern of thread safety using this class?
> 2. How can I pass NSFileHandle the file URL of my files?
> 3. How could I create a method that will take the contents of the file and
> do something with them?

1. No. NSFIleHandle takes care of creating a separate thread for you,
and notifies your main thread when it's finished reading the given
file, with a NSFileHandleReadToEndOfFileCompletionNotification
notification.

2. If you have a NSURL and need to create a NSFileHandle with that,
simply use NSURL's -path method to get the NSURL's filesystem path.
Otherwise, just create your file handle with a NSString path using
-fileHandleForReadingAtPath:.

3. Register for the NSFileHandleReadToEndOfFileCompletionNotification
notification. Once it's received, you can access its respective
NSFileHandle using the notification's -object method.

All of this has happened before, and it will all happen again, as they
say. The answers to 2 & 3 can be found with a little searching - I
encourage you to do so.

David
___

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

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

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

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


Re: Cocoa user pane equivalent?

2009-04-05 Thread Jo Meder

Hi Graham,

On 6/04/2009, at 1:07 AM, Graham Cox wrote:


On 05/04/2009, at 12:20 PM, Jo Meder wrote:

The one thing I'm not really clear on is what the Cocoa equivalent  
of a Carbon user pane control would be. It seems that there isn't  
really a direct equivalent in Cocoa and that the best way to do  
things would be to have a custom view inheriting from NSControl.  
Would that be right?


Jo, do you mean a dialog 'user item'?


No, a user pane control i.e. created with CreateUserPaneControl() and  
of type kControlKindUserPane.


These items did nothing except define a rectangular region of the  
dialog that you could customise in some unspecified way. The cocoa  
equivalent would be NSView, though it gives you far more than just  
a frame and then leaves the rest to you.


You could certainly subclass NSControl if you wanted a custom  
control (NSControl subclasses NSView) but NSView is more flexible  
in many ways, as all more general objects tend to be.


Thanks for confirming that.

Regards,

Jo Meder
___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Greg Guerin

Michael Ash wrote:


@implementation NSDictionary (SHA1Hashing)
- (NSData *)gc_sha1hash {
NSMutableData *subhashes = [NSMutableData data];
for(id key in [[self allKeys]
sortedArrayUsingSelector:@selector(compare:)]) {
[subhashes appendData:[key gc_sha1hash]];
[subhashes appendData:[[self objectForKey:key] gc_sha1hash]];
}
return [subhashes gc_sha1hash];
}
@end

Then define -gc_sha1hash for all the other classes you expect to
encounter as well. (The prefix is just to ensure that you don't
overwrite a hypothetical Apple implementation of a -sha1hash method.)



As a design, it might be more flexible to define a -gc_canonicalData  
method that returns an NSData containing unhashed canonical bytes,  
rather than -gc_sha1hash that returns a hash.  This would make it  
easier to use different secure-hash algorithms, should that be  
desired.  SHA1 isn't exactly state-of-the-art.


I'd also make the code that calculates the hash from a given  
NSDictionary or NSArray return an error (or throw an exception) if  
anything in the collection doesn't respond to -gc_canonicalData. Or  
it could silently skip those (not hash them), depending on the context.


  -- GG

___

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

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

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

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


Re: Cocoa user pane equivalent?

2009-04-05 Thread Jo Meder

Hi guys,


Can you explain what a user pane is (not all of us are that familiar
with Carbon) and what exactly you're trying to do?


A user pane was a precursor to HIView, that is a view (control is the
proper term for the user pane) that could handle user input events,
drawing and adding sub-views for grouping purposes.


Yes, that describes it pretty well.


NSView is the equivalent of HIView so NSView is what you want I think.


Thanks. Well, I still might inherit from NSControl if I decide it has  
stuff I need, but that info is a help.


Regards,

Jo Meder
___

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

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

Help/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: Suppressing variable hiding warning in Xcode

2009-04-05 Thread Bill Bumgarner

On Apr 5, 2009, at 5:10 PM, Brad O'Hearne wrote:
1. I get the gist of trying to prevent developers from accidentally  
hiding variables -- but is this really a major problem? Other than  
this, is there a compelling reason to keep this warning in tact, and  
change variable parameter variable names to make the warning go away?


Yes. Most -- not all, but most -- Objective-C programmers tend to shy  
away from various prefix/suffix solutions for marking instance  
variables, preferring to go with more english like names.  Apple uses  
_ to indicate "internal, don't touch", but not with 100% consistency.


Argument names are typically somewhat descriptive of their purpose --  
newOrigin, notificationName, userInfo -- or totally generic, while  
remaining descriptive -- aSize, anError, etc...




2. How do you get Xcode to not produce this warning?


Don't.  You'll thank yourself for not doing so after spending a few  
hours wondering why an iVar didn't get updated only to find that a  
parameter hid the iVar.


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: Suppressing variable hiding warning in Xcode

2009-04-05 Thread Chris Suter
Hi Brad,

On Mon, Apr 6, 2009 at 10:10 AM, Brad O'Hearne
 wrote:

> I had a few questions about selectively suppressing a certain warning in
> Xcode. I personally find the warning which pertains to local variables
> hiding instance variables a real nuisance. For example, if you have a
> message signature with a parameter name which matches an instance variable
> name, and the compiler produces the following message:
>
> "warning: local declaration of '' hides instance variable"
>
> Two questions:
>
> 1. I get the gist of trying to prevent developers from accidentally hiding
> variables -- but is this really a major problem? Other than this, is there a
> compelling reason to keep this warning in tact, and change variable
> parameter variable names to make the warning go away?
>
> 2. How do you get Xcode to not produce this warning?

I would urge you not to suppress the warning. It's easy enough to
change one of the names so that they don't clash and it's one more
potential bug (you type the name intending to get the value of the
instance variable but get the parameter instead) you don't have to
worry about.

A lot of people like to prefix their instance variables. Apple use an
underscore which I don't personally like to do because underscore
prefixes tend to be reserved. Other people use different prefixes but
I don't like doing that either because that can complicate things for
KVO and KVC (KVO and KVC know about underscore prefixes).

My personal preference is to prefix the parameter name with either
'a', 'an' or 'the' depending on the context.

If you insist on disabling the warning, "-Wno-shadow" will probably do
the trick. You'd have found that out by looking at the gcc man page.

Kind regards,

Chris
___

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

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

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

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


RE: Suppressing variable hiding warning in Xcode

2009-04-05 Thread Jeff Laing
> variables hiding instance variables a real nuisance. For example, if  
> you have a message signature with a parameter name which matches an  
> instance variable name, and the compiler produces the following
message:
>
> "warning: local declaration of '' hides instance
variable"

What really annoyed me was that I had trivial variables called 'mxd' and
'myd' which corresponded to 'movement-x-delta' and 'movement-y-delta'.

It took forever to work out that 'myd' clashed with an enum value
defined somewhere for Date Ordering - MonthYearDay.

(It took so long because Xcode does such a crap job at displaying
multi-line error messages, and thus the 'original definition is here'
line was nowhere near the 'local names clash' line)

In this case, it wasn't instance variables, just locals vs an enum in an
enclosing scope.

Apple might think about using better (ie, prefixed) names for all their
enums if they are going to clash like this, otherwise the set of
available variable names is going to evaporate over time...

Jeff Laing 

--
A complex system designed from scratch never works and cannot be patched
up to
make it work.  You have to start over, beginning with a working simple
system.
 -- J Gall. "Systemantics: How systems work and how they
fail"

___

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

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

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

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


Suppressing variable hiding warning in Xcode

2009-04-05 Thread Brad O'Hearne

Hey there,

I had a few questions about selectively suppressing a certain warning  
in Xcode. I personally find the warning which pertains to local  
variables hiding instance variables a real nuisance. For example, if  
you have a message signature with a parameter name which matches an  
instance variable name, and the compiler produces the following message:


"warning: local declaration of '' hides instance  
variable"


Two questions:

1. I get the gist of trying to prevent developers from accidentally  
hiding variables -- but is this really a major problem? Other than  
this, is there a compelling reason to keep this warning in tact, and  
change variable parameter variable names to make the warning go away?


2. How do you get Xcode to not produce this warning?

Thanks,

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: Non-pageable app

2009-04-05 Thread Chris Suter
Hi Finlay,

On Sun, Apr 5, 2009 at 6:47 AM, Finlay Dobbie  wrote:

> --
> Indeed, many types of data, such as hashes, unencrypted versions of
> sensitive data, and authentication tokens, should generally not be
> written to disk due to the potential for abuse. This raises an
> interesting problem. There is no good way to deal with this in user
> space (unless a program is running as root).
> --

I'm not sure I understand why there's a need to stop these details
from going to disk. Surely the only way a malicious program could read
any of this data is if it had root access and if it has root access,
there are loads of different ways it could get access to the data (for
example: reading it directly from memory).

What am I missing?

Regards,

Chris
___

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

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

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

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


Re: Puzzling run loop/autorelease pool question

2009-04-05 Thread Chris Suter
Hi Michael,

On Mon, Apr 6, 2009 at 9:50 AM, Michael Ash  wrote:
> On Sun, Apr 5, 2009 at 5:11 PM, m  wrote:

> The workaround is easy. What you're doing is fine, or you can post a
> fake NSEvent, or something similar. Pretty much up to you.

Whilst that approach will probably work for ever, I still think you're
better off wrapping your C callbacks with your own NSAutoreleasePool;
nothing really guarantees that an autorelease pool will exist when
you're in a C callback that you've added directly to the runloop via a
C interface.

Regards,

Chris
___

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

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

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

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


Re: IB 3.1 Panel Has Maximum Size funky - workaround?

2009-04-05 Thread Jonathan Hess

Hey Steve -

Is this IB 3.1? Or is it possibly 3.1.1 or 3.1.2? You may want to try  
this with the 3.1.2 tools.


Jon Hess

On Apr 5, 2009, at 3:11 PM, Steve Cronin wrote:


Folks;

I have a panel which I want to allow the user to extend vertically  
up to 100 pixels.


IB 3.1 (xib)
Resize flag - ON
Has Minimum Size - ON  (use Current to establish the base size)
Has Maximum Size - ON (use Current then add 100 to Height)
Now the project won't compile:
error: This window's maximum size is smaller than its content  
rectangle's size, a situation which may result in unexpected runtime  
behavior.


I set Has Maximum - OFF it will compile.
I've tried fiddling around trying to convince IB that I want a  
maximum size but something is amiss somewhere.


Is there a work around for this?

Thanks,
Steve
___

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

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

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

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


___

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

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

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

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


Re: Puzzling run loop/autorelease pool question

2009-04-05 Thread Chris Suter
Hi m,

On Mon, Apr 6, 2009 at 8:21 AM, m  wrote:
> I've uploaded a project that demonstrates the problem to
>
> 

The problem is that you set-up your callback and your actual callback
is all via C; it's not an Objective-C interface so it makes no
guarantee that an autorelease pool will even exist, let alone whether
it will drain it. Bear in mind, that when your events are triggered no
other Objective-C code runs except for yours; it's all done in
CoreFoundation's runloop code.

Anyway, to solve it, all your callbacks should create their own
autorelease pool and release them before returning. Likewise, if you
care about exceptions, you should catch them in your callback
functions, although if all you're going to do is terminate anyway,
letting your program crash is as good a way as any.

Kind regards,

Chris
___

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

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

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

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


Re: Puzzling run loop/autorelease pool question

2009-04-05 Thread Michael Ash
On Sun, Apr 5, 2009 at 5:11 PM, m  wrote:
> I'm having trouble with autoreleased objects not being released when I
> expect them to be released.
>
> I'm writing an app that observes ui elements of another app using the
> Accessibility API. I get a root ui element from the observed application and
> register for the kAXMainWindowChangedNotification.
>
> CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop],
> AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode);
>
>
> The idea is that when the observed application's main window changes, my
> observing app takes special action in response.
>
> So far so good. Here's the weird part: any autoreleased objects I allocate
> in my notification handler aren't in fact released until my observer app
> gets "tickled" by some event. So if my observer app is just sitting there in
> the background logging notifications to the console, any autoreleased
> objects created just pile up in the autorelease pool. Clicking in the
> observing app's window, or even just activating it then triggers a massive
> release festival.
>
> I suppose one explanation is that my run loop is stalled because it thinks
> there is nothing to process, but I can't find a straightforward way to
> programmatically tell the run loop to iterate. In any case, my understanding
> was that this was a detail I needn't worry about,
>
> A hack-around that seems to work: in my notification handler, I schedule a
> method for the next run loop iteration (using -[NSObject
> performSelector:withObject:afterDelay:]) in which I do all the real work,
> but I am puzzled as to why this works.
>
> It seems like there are lots of cases where one might write a background
> only app that doesn't receive events but whose autorelease pools are
> nevertheless drained at the end of a run loop iteration, which suggests that
> run loops really ought to keep iterating when necessary without any special
> action on the coder's part.
>
> Perhaps there is a subtlety of run loops that I'm missing. Can someone
> clarify this?

All you're missing is that runloops don't cycle the autorelease pool
for every single action. They do for most, but there are some they
miss. C-like callbacks such as this one tend to be in the "miss"
category. The pool still *exists*, so you don't really leak, but it
doesn't get drained until something happens that actually triggers the
pool, as you saw.

The workaround is easy. What you're doing is fine, or you can post a
fake NSEvent, or something similar. Pretty much up to you.

If you're interested, more details here:

http://www.mikeash.com/?page=pyblog/more-fun-with-autorelease.html

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: Need localization-proof method of transporting dates.

2009-04-05 Thread Michael Ash
On Sun, Apr 5, 2009 at 7:23 PM, Graham Cox  wrote:
> This leaves me with a problem - how to generate a SHA-1 hash of an arbitrary
> dictionary that is likely to remain stable under different architectures, OS
> versions, and so on.

Of an *arbitrary* dictionary? Can't be done. Class Foo might not have
a stable hash, even in theory (like if it wraps a file handle), and if
one is in your dictionary then you're hosed.

But you probably are just dealing with property list types, or perhaps
a few others. You know ahead of time what types you'll have, so you
can just implement the hash recursively, like so:

@implementation NSDictionary (SHA1Hashing)
- (NSData *)gc_sha1hash {
NSMutableData *subhashes = [NSMutableData data];
for(id key in [[self allKeys]
sortedArrayUsingSelector:@selector(compare:)]) {
[subhashes appendData:[key gc_sha1hash]];
[subhashes appendData:[[self objectForKey:key] gc_sha1hash]];
}
return [subhashes gc_sha1hash];
}
@end

Then define -gc_sha1hash for all the other classes you expect to
encounter as well. (The prefix is just to ensure that you don't
overwrite a hypothetical Apple implementation of a -sha1hash method.)

Implementing it for NSData is easy, you've done that. For classes like
NSString or NSDate, figure out a canonical way to convert them to an
NSData. For NSString, you can use one of the "WithCanonicalMapping"
methods, then convert to UTF-8. For NSDate, that whole class is
basically just a wrapper around a single value, the return value of
-timeIntervalSinceReferenceDate, so you could just print that into a
string and then hash the string. For NSArray, follow an approach
similar to NSDictionary. The key is to reduce everything down to an
NSData or something else you've already defined a hash for, like an
NSString, and do perform that reduction in a way which you control and
which is reproducible. (That last part is why I sort the keys in the
code above, since NSDictionary can give them in an arbitrary order
which won't be consistent across runs.)

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: Need localization-proof method of transporting dates.

2009-04-05 Thread Graham Cox


On 06/04/2009, at 1:15 AM, Michael Ash wrote:


Note that, as far as I know, there is no guarantee that -hash will
return the same value for the same object across runs of your program.
Apple is free to change their algorithm in an OS update, and could
conceivably (although I don't see why) switch between different
algorithms at process start time. You'll want to use your own hashing
algorithm for this.



Yes, I realise you're right. I've been assuming that -hash is derived  
in a simple way that is stable over time, OS version, etc.


The previous hashing approach used an object's -description method  
which was taken from Aquatic Prime's code for hashing a dictionary,  
but that was failing on dates with locale changes. There's no  
guarantee that -description will never change either.


This leaves me with a problem - how to generate a SHA-1 hash of an  
arbitrary dictionary that is likely to remain stable under different  
architectures, OS versions, and so on. Note that I currently also use  
the dictionary keys as part of the hashing function, so that part is  
probably safe. But the hash definitely has to be sensitive to the  
values for each key also.


Here's the current code:

@implementation NSData (SHA1Hash)

- (NSData*) sha1Hash
{
// calculates the 160 bit SHA-1 digest of the given data

unsigned char* digest = (unsigned char*) malloc(20);
SHA1([self bytes], [self length], digest);

return [[self class] dataWithBytesNoCopy:digest length:20];
}


+ (NSData*) sha1HashWithDictionary:(NSDictionary*) dict
{
	// hashes the contents of the dictionary and returns the SHA-1 digest  
resulting. This takes account of the keys and values in the dictionary
	// to provide a reliable signature for the dictionary. The dictionary  
passed must not already contain the digest we are trying to compute!


	// WARNING: using -description here (as AQP) makes the hash sensitive  
to system settings such as date format if the dictionary contains  
dates, etc. Thus
	// we must not use this is a way to verify the dictionary content.  
Instead we use the -hash value returned by the object.


NSMutableArray* keys = [[dict allKeys] mutableCopy];
[keys sortUsingSelector:@selector(caseInsensitiveCompare:)];

NSEnumerator*   iter = [keys objectEnumerator];
NSString*   key;
NSMutableData*  dictData = [NSMutableData data];

while(( key = [iter nextObject]))
{
id currentValue = [dict objectForKey:key];

		//NSLog(@"key = %@, obj = %@, hash = %d", key, currentValue,  
[currentValue hash]);


unsigned hash = [currentValue hash];
[dictData appendBytes:&hash length:sizeof(unsigned)];

char* description = (char*)[key UTF8String];
[dictData appendBytes:description length:strlen(description)];
}

[keys release];

return [dictData sha1Hash];
}


@end



So if anyone has any bright ideas about how I could successfully  
implement this, I'm all ears!


cheers, 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: Puzzling run loop/autorelease pool question

2009-04-05 Thread m

I've uploaded a project that demonstrates the problem to



_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



IB 3.1 Panel Has Maximum Size funky - workaround?

2009-04-05 Thread Steve Cronin

Folks;

I have a panel which I want to allow the user to extend vertically up  
to 100 pixels.


IB 3.1 (xib)
Resize flag - ON
Has Minimum Size - ON  (use Current to establish the base size)
Has Maximum Size - ON (use Current then add 100 to Height)
Now the project won't compile:
error: This window's maximum size is smaller than its content  
rectangle's size, a situation which may result in unexpected runtime  
behavior.


I set Has Maximum - OFF it will compile.
I've tried fiddling around trying to convince IB that I want a maximum  
size but something is amiss somewhere.


Is there a work around for this?

Thanks,
Steve
___

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

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

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

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


Re: crash reading archive

2009-04-05 Thread Sean McBride
James Maxwell (jbmaxw...@rubato-music.com) on 2009-04-05 4:24 PM said:

>I'm assuming it's trying to release a released object, but I can't
>see it...

Any you tried any of the follewing: NSZombie? GuardMalloc? leaks
checking with Instruments?  MallocDebug?

Also:



>NSString *filePath;
>filePath = NSHomeDirectory()
>   stringByAppendingPathComponent:@"Library"]
>   stringByAppendingPathComponent:@"Application Support"]

Note: google "NSApplicationSupportDirectory" for a better way...

Sean


___

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

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

Help/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: NSString and decoding HTML Entities

2009-04-05 Thread I. Savant

On Apr 5, 2009, at 5:52 PM, Stuart Malin wrote:

Thanks, but I understand the difference perfectly, but it's  
irrelevant.


Sorry, I.S., I didn't mean to imply that you didn't understand the  
difference -- just wanted to be clear for others following this  
thread as the distinction between percent escaping and entity  
decoding is often confused.


  No apology necessary - I should have included a ":-)", since it was  
meant to be tongue-in-cheek.



Your point that HTML entities are HTML is sensible, and more  
important, valid. Thank you for taking the time to build a test case.


The approach you have taken certainly offers much greater  
functionality, so I appreciate your posting this -- I may end up  
using it as well.


  I had done this once before, years ago, for a quick little utility  
I no longer have handy. Most important, which you noticed, is the  
flexibility this approach offers (which might be worth the overhead,  
especially if it's not repeated hundreds of times a second, etc.).


--
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: Beachball on Lengthy Task

2009-04-05 Thread Andrew Farmer

On 05 Apr 09, at 08:17, Michael Ash wrote:

On Sun, Apr 5, 2009 at 9:33 AM, Kirk Kerekes  wrote:
Along with threads and various asynchronous techniques already  
mentioned,
you should also consider creating a separate UI-less "foundation  
tool" to
perform your lengthy task, controlled with NSTask in your main app.  
This
yields all of the benefits of a thread, with none of the threading  
pitfalls.
Getting real-time feedback (for a progress indicator, for example)  
from the
task is more complex than with a thread, and getting result data  
back is
slightly more involved, but the absolute freedom from threading  
issues is

often worth it.

Several of Apple's utility apps are constructed as a UI shell that  
invokes

one or more tools.


I recommend avoiding this if possible. Processes are a somewhat scarce
resource on OS X (only 266 per user by default, looks like) and you
don't want to be using up more than you have to. It's unfortunate
because it can make things easier as you say.


It's also not particularly effective if your lengthy task involves any  
significant processing of data that's been created within your  
application. Most of Apple's utility apps that use helper tools (Disk  
Utility, Network Utility, et al) don't need to pass anything beyond a  
few parameters to their helper tools; if your application does,  
though, trying to split out functionality to a separate executable may  
make things worse rather than better.

___

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

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

Help/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: NSString and decoding HTML Entities

2009-04-05 Thread Stuart Malin


On Apr 5, 2009, at 11:32 AM, I. Savant wrote:


On Apr 5, 2009, at 4:35 PM, Stuart Malin wrote:


The source is not HTML tagged, but contains HTML entities.

see:
http://www.w3schools.com/tags/ref_entities.asp
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references


So, for instance, I want to convert "-->"  to "-->"

No need for an attributed string.


 Thanks, but I understand the difference perfectly, but it's  
irrelevant. HTML entities are HTML too, so this worked fine:


	NSMutableAttributedString * aStr = [[NSMutableAttributedString  
alloc] initWithHTML:[NSData dataWithContentsOfURL:[NSURL  
URLWithString:@"file:///Users/me/test.html"]] documentAttributes:nil];
	[textView replaceCharactersInRange:NSMakeRange(0, [[textView  
string] length]) withString:[aStr string]];


 ... with an HTML file containing the entity > (NSData from local  
file for convenient illustrative purposes) but your method is  
probably more direct / efficient. I referenced the above because you  
said, "I can't seem to find an NSString method to do so (not that I  
sometimes don't easily miss the obvious)."


 It's not strictly NSString, but might have worked fine for you.


Sorry, I.S., I didn't mean to imply that you didn't understand the  
difference -- just wanted to be clear for others following this thread  
as the distinction between percent escaping and entity decoding is  
often confused.


Your point that HTML entities are HTML is sensible, and more  
important, valid. Thank you for taking the time to build a test case.


The approach you have taken certainly offers much greater  
functionality, so I appreciate your posting this -- I may end up using  
it as well.



___

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

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

Help/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: creating related objects

2009-04-05 Thread David Scheidt


On Apr 4, 2009, at 2:26 AM, Quincey Morris wrote:


On Apr 3, 2009, at 09:49, David Scheidt wrote:

I have an NSPersistantDocument application.  In one one of my  
sheets to create an object, I need to have a checkbox that, if  
checked, will bring up the creation sheet for a related object.  I  
can't figure out how to do this.  I rather expect that I'm missing  
something simple, but I don't know what.


Is this what you're looking for?

	http://developer.apple.com/documentation/Cocoa/Conceptual/Sheets/Tasks/UsingCascadingSheets.html#/ 
/apple_ref/doc/uid/20001046


It's talking about alerts, but the technique applies to any sequence  
of sheets.


That's not quite it, but it was enough of a poke to get me to figure  
out the problem.


Thanks!
___

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

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

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

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


Re: NSXMLParser memory consumption

2009-04-05 Thread Marcel Weiher


On Apr 5, 2009, at 9:35 , George King wrote:
Yes, probably.  Have you tried initializing it with a memory-mapped  
NSData instead of an NSURL?


Thank you for the suggestion; I was unaware of  
initWithContentsOfMappedFile:. This worked to a certain extent, in  
that it kept memory consumption to within the bounds of available  
physical memory, but it still consumed all the memory available.  
This caused a good deal of thrashing when I tried running the test  
and working at the same time.


This may be one of a number of things.  You might want to check wether  
an madvise() call on the mapped memory range with the  
"MADV_SEQUENTIAL" flag helps.  This tells the system that it can do a  
"free-behind" of memory you've touched.




Thanks for the link - I will investigate. Yesterday I got into  
libxml2, and the xmlReader API provides functionality equivalent to  
NSXMLParser without the memory consumption.


If you're seeing a difference with libxml2, then Objective-XML should  
also help, to a similar or somewhat better extent.


Cheers,

Marcel




___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Marcel Weiher


On Apr 5, 2009, at 8:15 , Michael Ash wrote:



Note that, as far as I know, there is no guarantee that -hash will
return the same value for the same object across runs of your program.


And in fact this has changed in the past.

Marcel

___

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

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

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

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


Unable to save file in Document-Based Application

2009-04-05 Thread cocoa learner
Hi All,
I am new to cocoa and GUI programming.
I wrote a Document-Based Application. Whose code snippet as follows to write
data into a file (this code is taken from
Aaron.Hillegass-Cocoa.Programming.for.Mac.OS.X
book's Chapter 10 ) -

 - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError

{

NSLog(@"dataOfType : Called");

NSData *data = [NSKeyedArchiver archivedDataWithRootObject: employees];

if (data == nil)

{

NSLog(@"dataOfType : Failed to write into file");

}

else

{

NSLog(@"dataOfType : Data is written into file");

}

 NSLog(@"dataOfType : Finished");

 return data;

}

But this code piece is not saving the data into file. Does any one have any
clue why it's not able to create file?

Regards
Cocoa.learner
___

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

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

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

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


Newbie question: Cocoa threads within RubyCocoa

2009-04-05 Thread Arcadio Rubio García

Hi all,

I'm trying to build a simple Cocoa GUI that acts as an observer to my  
Ruby text application and reports progress in a window (with a  
progress bar, etc).


I'm using RubyCocoa for creating the GUI, but I guess anyone who does  
not know Ruby or RubyCocoa might be still able to answer my question.


My problem is that I need to run the following GUI in a separate  
thread and be able to send messages to it from my main app.


Can anyone point how to do this? I've tried wrapping the app  
instantiation in a NSObject and doing  
NSThread.detachNewThreadSelector_toTarget_withObject(:run, runner,  
nil) to it, but the window does not appear.


Thanks.



require 'osx/cocoa'
include OSX


class AppDelegate < NSObject
  def init
frame = [200.0, 300.0, 250.0, 100.0]
@win =  
NSWindow.alloc.initWithContentRect_styleMask_backing_defer(frame,
   
15, 2, 0)

@win.setTitle 'Test'
@win.setLevel 0
@bar = NSProgressIndicator.alloc.initWithFrame [10.0, 10.0, 80.0,  
80.0]

@win.contentView.addSubview(@bar)
@bar.setIndeterminate(false)
@win.display
@win.orderFrontRegardless
  end

  def step
@bar.incrementBy(20)
  end
end


app = NSApplication.sharedApplication
app.setDelegate(AppDelegate.alloc.init)
app.run
___

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

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

Help/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: NSString and decoding HTML Entities

2009-04-05 Thread I. Savant

On Apr 5, 2009, at 4:35 PM, Stuart Malin wrote:


The source is not HTML tagged, but contains HTML entities.

see:
http://www.w3schools.com/tags/ref_entities.asp
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references


So, for instance, I want to convert "-->"  to "-->"

No need for an attributed string.


  Thanks, but I understand the difference perfectly, but it's  
irrelevant. HTML entities are HTML too, so this worked fine:


	NSMutableAttributedString * aStr = [[NSMutableAttributedString alloc]  
initWithHTML:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"file:///Users/me/test.html 
"]] documentAttributes:nil];
	[textView replaceCharactersInRange:NSMakeRange(0, [[textView string]  
length]) withString:[aStr string]];


  ... with an HTML file containing the entity > (NSData from local  
file for convenient illustrative purposes) but your method is probably  
more direct / efficient. I referenced the above because you said, "I  
can't seem to find an NSString method to do so (not that I sometimes  
don't easily miss the obvious)."


  It's not strictly NSString, but might have worked fine for you.

--
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: IB Plugin help

2009-04-05 Thread Kevin Cathey

Hi Jon,

Here are my responses to your responses to my responses :):

[1] INSTALLING THE PLUGIN

There are obviously two modes for using an IB Plugin: developing it,  
and then actually using it as if it was just another plugin on the  
system. In the case you are developing the plugin, the best way to do  
this comes by default when you created the IB plugin project: just hit  
Build and Go and Xcode will pass along information to IB to load the  
development version of your plugin. Again, this works out of the box.


But as you asked, how do we get a plugin from development into  
"installation" mode where I don't have to be debugging my plugin from  
Xcode to use it? There are a few ways of doing this of course. One way  
which I use to develop plugins is to build what is called a  
distribution root. A root is a built version of your project that,  
when the build is finished, is put in a folder (the "Installation  
Build Products Location", or "DSTROOT" which is by default "/tmp/ 
PROJECT_NAME.dst") that has a hierarchy of subfolders that mimics the  
layout on disk. The layout is determined by each Xcode target's  
"Installation Directory" (INSTALL_PATH). For example, let's say I have  
a MyPluginProject Xcode project that has the two standard IB plugin  
targets, MyPlugin for the plugin, and MyFramework for the framework.  
For the framework target, I set the Installation Directory to "/ 
Library/Frameworks" (set by default). And for the plugin target, I set  
the Installation Directory to "/Library/Frameworks/ 
MyFramework.framework/Resources" (also set by default).


Now, from the command line, I use the CLI to Xcode called xcodebuild.  
If I run the "install" command, then Xcode will build my project,  
create the folder specified by my DSTROOT, and then install each of  
the built targets into the appropriate subfolders based upon their  
Installation Directory. The "install" command might look like this:



cd MYPROJECTDIRECTORY
sudo xcodebuild install -configuration Release -target All


This invokes xcodebuild to build the "All" target (added by default in  
IB plugin projects) of the project in the CWD using the Release  
configuration. If I then look in /tmp, I will see the following  
folder: "MyPluginProject.dst". And inside of that folder, I get the  
following layout of folders:


/tmp
/MyPluginProject.dst
/Library
/Frameworks
/MyFramework.framework
... other framework stuff
/Resources
/MyPlugin.ibplugin
... and it's  
contents


Then, to "install" the distribution root on my system, all I need to  
do is the following command:



sudo ditto /tmp/MyPluginProject.dst /


And this will copy the contents of the distribution root folder in  
"/", effectively placing each item exactly where it needs to go. At  
this point, the framework and plugin are installed, and if I open up  
IB, go to the Preferences, and add the plugin from /Library/ 
Frameworks, then I'm done.


So, to review. To install a plugin, assuming I started with standard  
IB plugin template, I do the following:


(1) Set the Installation Directory for the plugin and framework to  
where it should be installed. The framework, by default, will be "/ 
Library/Frameworks", which is good. The plugin, by default, will be "/ 
Library/Frameworks/MYFRAMEWORK.framework/Resources". That also is  
fine. If you change the name of your framework, however, be sure to  
reset the installation directory.


(2) From the directory from plugin Xcode project lives in, build a  
distribution root by running the following: "sudo xcodebuild install - 
configuration Release -target All"


(3) To install the built root, run: "sudo ditto /tmp/ 
MYPROJECTNAME.dst /"


(4) In IB, under the Preferences, add your plugin by finding the  
framework in /Library/Frameworks.


(5) Enjoy!



But what if I want to change some things about your plugin later on?  
Do you have to build a root and install each time you want to check a  
change your are working on? No! If you change your plugin and want to  
test it quickly, you just hit "Build and Go" like you did when you  
first developed the plugin. Xcode will pass this information to IB,  
and IB will use your development version, NOT your installed version.  
How does it know the difference? When you run from Xcode, Xcode sets  
up the current working directory and then passes a flag that IB uses  
to open your plugin. Since the CWD is set to your build products  
folder, it uses the the plugin from there instead.


This way, you can work on your plugin for awhile, making changes and  
testing in IB. Then, when you are satisfied, you can build a root,  
install it, and then go along your

Re: NSString and decoding HTML Entities

2009-04-05 Thread Stephen J. Butler
On Sun, Apr 5, 2009 at 2:56 PM, Stuart Malin  wrote:
> I need to convert strings that contain HTML entities (e.g., ’  or
> &#gt;).  I can't seem to find an NSString method to do so (not that I
> sometimes don't easily miss the obvious).  So, I created a category on
> NSString and made two trivial methods that take advantage of toll-free
> bridging between NSString and CFStringRef by using
> CFXMLCreateStringByEscapingEntities and
> CFXMLCreateStringByUnescapingEntities.  Is there a better way?

Sounds good. Are you using garbage collection? You should read this if
you haven't already. It explains how CF(Retain|Release) work under GC
and when to use CFMakeCollectable:


___

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

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

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

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


Puzzling run loop/autorelease pool question

2009-04-05 Thread m
I'm having trouble with autoreleased objects not being released when I  
expect them to be released.


I'm writing an app that observes ui elements of another app using the  
Accessibility API. I get a root ui element from the observed  
application and register for the kAXMainWindowChangedNotification.


CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop],  
AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode);



The idea is that when the observed application's main window changes,  
my observing app takes special action in response.


So far so good. Here's the weird part: any autoreleased objects I  
allocate in my notification handler aren't in fact released until my  
observer app gets "tickled" by some event. So if my observer app is  
just sitting there in the background logging notifications to the  
console, any autoreleased objects created just pile up in the  
autorelease pool. Clicking in the observing app's window, or even just  
activating it then triggers a massive release festival.


I suppose one explanation is that my run loop is stalled because it  
thinks there is nothing to process, but I can't find a straightforward  
way to programmatically tell the run loop to iterate. In any case, my  
understanding was that this was a detail I needn't worry about,


A hack-around that seems to work: in my notification handler, I  
schedule a method for the next run loop iteration (using -[NSObject  
performSelector:withObject:afterDelay:]) in which I do all the real  
work, but I am puzzled as to why this works.


It seems like there are lots of cases where one might write a  
background only app that doesn't receive events but whose autorelease  
pools are nevertheless drained at the end of a run loop iteration,  
which suggests that run loops really ought to keep iterating when  
necessary without any special action on the coder's part.


Perhaps there is a subtlety of run loops that I'm missing. Can someone  
clarify this?


_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: NSString and decoding HTML Entities

2009-04-05 Thread Stuart Malin


On Apr 5, 2009, at 10:19 AM, I. Savant wrote:


On Apr 5, 2009, at 3:56 PM, Stuart Malin wrote:

I need to convert strings that contain HTML entities (e.g.,  
’  or &#gt;).


 To what?

 If you want it to be an attributed string, there's always the - 
[NSAttributedString initWithHTML:...] methods (in the  
NSAttributedString AppKit additions). If you just want to strip the  
HTML, you can then ask the attributed string for its -string ...


The source is not HTML tagged, but contains HTML entities.

see:
http://www.w3schools.com/tags/ref_entities.asp
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references


So, for instance, I want to convert "-->"  to "-->"

No need for an attributed string.



___

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

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

Help/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: NSString and decoding

2009-04-05 Thread Stuart Malin


On Apr 5, 2009, at 10:22 AM, Jack Carbaugh wrote:

it would have helped if I read & digested the WHOLE message. my  
apologies ! what i referenced and what he wanted were two different  
things.


my apologies,

jack


no worries.

this notion of escaping HTML entities seems often confused with URL  
encoding.


___

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

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

Help/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: NSString and decoding HTML Entities

2009-04-05 Thread Bryan Henry
The HTML entities that Stuart is talking about aren't "percent  
escapes", and aren't replaced by - 
stringByReplacingPercentEscapesUsingEncoding:.


- Bryan

On Apr 5, 2009, at 4:19 PM, Jack Carbaugh wrote:


Why don't you just use the features of NSString ?

stringByReplacingPercentEscapesUsingEncoding:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#/ 
/apple_ref/doc/uid/2154-BCIECHFE


On Apr 5, 2009, at 3:56 PM, Stuart Malin wrote:

I need to convert strings that contain HTML entities (e.g.,  
’  or &#gt;).  I can't seem to find an NSString method to do  
so (not that I sometimes don't easily miss the obvious).  So, I  
created a category on NSString and made two trivial methods that  
take advantage of toll-free bridging between NSString and  
CFStringRef by using CFXMLCreateStringByEscapingEntities and  
CFXMLCreateStringByUnescapingEntities.  Is there a better way?

___

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

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

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

This email sent to intrn...@aol.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/bryanhenry%40mac.com

This email sent to bryanhe...@mac.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


crash reading archive

2009-04-05 Thread James Maxwell
I'm trying to read a "default" configuration-type file when my app  
loads. It's worked, on and off, for the last couple of days, but it's  
just started complaining again. This is the code I'm using to load the  
object. It seems pretty straightforward, so I can't figure out what's  
up. I'm assuming it's trying to release a released object, but I can't  
see it... Is there anything in the error log (bottom) that says  
anything unusual? The following code is in my WindowControllerDidLoad:



NSString *filePath;
filePath = NSHomeDirectory()
stringByAppendingPathComponent:@"Library"]
stringByAppendingPathComponent:@"Application Support"]
stringByAppendingPathComponent:@"ManuScore"]

stringByAppendingPathComponent:@"DefaultHTMNetwork.MHTMData"];

NSFileManager *fileManager = [NSFileManager defaultManager];
if([fileManager fileExistsAtPath:filePath])
	[self setLiveHTMNetwork:[NSKeyedUnarchiver  
unarchiveObjectWithFile:filePath]];

else
{
[self setLiveHTMNetwork:[[HTMNetwork alloc] init]];
[[self liveHTMNetwork] configureSimpleTestNetwork];
}

// ... etc...   

And it's saved automatically, at runtime, with the following:

- (void)saveNetworkState
{   
NSString *filePath;
filePath = NSHomeDirectory()
stringByAppendingPathComponent:@"Library"]
stringByAppendingPathComponent:@"Application Support"]
stringByAppendingPathComponent:@"ManuScore"]

stringByAppendingPathComponent:@"DefaultHTMNetwork.MHTMData"];

[NSKeyedArchiver archiveRootObject:self toFile:filePath];
}

And the error:


Program received signal:  “EXC_BAD_ACCESS”.
kill
quit

#0  0x9695a688 in objc_msgSend
#1  0x90efae4f in NSPopAutoreleasePool
#2  0x90f09e53 in _decodeObject
#3  0x90f4fa6b in +[NSKeyedUnarchiver unarchiveObjectWithFile:]
#4	0x4496 in -[MyDocument windowControllerDidLoadNib:] at  
MyDocument.m:285

#5  0x96d24d2b in -[NSWindowController _windowDidLoad]
#6  0x96cc2d0a in -[NSWindowController window]
#7  0x96cc2c0a in -[NSWindowController showWindow:]
#8  0x96cc2b4d in -[NSDocument showWindows]
#9	0x96cc0e14 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:]

#10 0x96cc095f in -[NSDocumentController(NSInternal) _openUntitled]
#11 0x96cc07b1 in -[NSApplication _doOpenUntitled]
#12 0x96cbfe95 in -[NSApplication(NSAppleEventHandling) _handleAEOpen:]
#13	0x96cbf6bc in -[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:]
#14	0x90f2443f in -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:]

#15 0x90f2414f in _NSAppleEventManagerGenericHandler
#16 0x94648648 in aeDispatchAppleEvent
#17 0x9464857e in dispatchEventAndSendReply
#18 0x94648425 in aeProcessAppleEvent
#19 0x954049a5 in AEProcessAppleEvent
#20 0x96cbcf91 in _DPSNextEvent
#21	0x96cbc630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:]

#22 0x96cb566b in -[NSApplication run]
#23 0x96c828a4 in NSApplicationMain
#24 0x4718 in main at main.m:14

___

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

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

Help/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: NSString and decoding

2009-04-05 Thread Jack Carbaugh
it would have helped if I read & digested the WHOLE message. my  
apologies ! what i referenced and what he wanted were two different  
things.


my apologies,

jack
___

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

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

Help/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: NSString and decoding HTML Entities

2009-04-05 Thread Jack Carbaugh

Why don't you just use the features of NSString ?

stringByReplacingPercentEscapesUsingEncoding:

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#/ 
/apple_ref/doc/uid/2154-BCIECHFE


On Apr 5, 2009, at 3:56 PM, Stuart Malin wrote:

I need to convert strings that contain HTML entities (e.g., ’   
or &#gt;).  I can't seem to find an NSString method to do so (not  
that I sometimes don't easily miss the obvious).  So, I created a  
category on NSString and made two trivial methods that take  
advantage of toll-free bridging between NSString and CFStringRef by  
using CFXMLCreateStringByEscapingEntities and  
CFXMLCreateStringByUnescapingEntities.  Is there a better way?

___

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

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

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

This email sent to intrn...@aol.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: NSString and decoding HTML Entities

2009-04-05 Thread I. Savant

On Apr 5, 2009, at 3:56 PM, Stuart Malin wrote:

I need to convert strings that contain HTML entities (e.g., ’   
or &#gt;).


  To what?

  If you want it to be an attributed string, there's always the - 
[NSAttributedString initWithHTML:...] methods (in the  
NSAttributedString AppKit additions). If you just want to strip the  
HTML, you can then ask the attributed string for its -string ...


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


NSString and decoding HTML Entities

2009-04-05 Thread Stuart Malin
I need to convert strings that contain HTML entities (e.g., ’   
or &#gt;).  I can't seem to find an NSString method to do so (not that  
I sometimes don't easily miss the obvious).  So, I created a category  
on NSString and made two trivial methods that take advantage of toll- 
free bridging between NSString and CFStringRef by using  
CFXMLCreateStringByEscapingEntities and  
CFXMLCreateStringByUnescapingEntities.  Is there a better way?

___

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

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

Help/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: IB Plugin help

2009-04-05 Thread jmunson

Namaste!

Is this the proper way to do that:

- (NSImage *)ibDefaultImage
{
	NSBundle *myBundle = [NSBundle  
bundleWithIdentifier:@"com.MyCompany.MyPluginName"];

NSString *someString = [myBundle pathForResource:@"SomePic" 
ofType:@"png"];
	NSImage *someImage = [[[NSImage alloc]  
initWithContentsOfFile:someString] autorelease];

return someImage;
}

When I ran it, I got the nifty little icon rep of plug-in.

Many Thanks!!!

Peace, Love, and Light,

/s/ Jon C. Munson II


Quoting Brandon Walkin :


I haven't yet made an IB plugin with a custom formatter, but I'd assume
you change that image the same way you change the image that appears in
the document window. Return your own image in the -ibDefaultImage
method in your integration category.

On 5-Apr-09, at 9:31 AM, jmun...@his.com wrote:

1.  How do I change that blue cube (which displays when the   
textfield is selected) to my graphic (like NSNumberFormatter and   
NSDateFormatter)?




___

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

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

Help/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: Automating reading classes with InterfaceBuilder

2009-04-05 Thread Joey Hagedorn

Josef,
	While there is not an API for communicating to Interface Builder  
directly, Interface Builder syncs with header files in the Xcode  
project associated with a xib or nib file. I presume you're still  
using Xcode to manage and build the project. If you include the  
converted Objective-C headers in the Xcode project, Interface Builder  
should automatically pick up the changes.


-Joey


On Apr 4, 2009, at 6:04 PM, Ryan Joseph wrote:

I'm working on a Pascal bridge to Cocoa and as part of the system I  
have a PHP script which converts files to Objective-C headers, which  
InterfaceBuilder can use. However first I must manually "Read class  
files" and Reload in InterfaceBuilder. Xcode does this so there must  
be a way, but can I use AppleEvents to tell InterfaceBuilder to do  
this automatically? A UNIX solution that I could call from PHP or a  
shell script would be even better. Thank you.


Regards,
Josef


___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Michael Ash
On Sun, Apr 5, 2009 at 11:58 AM, Uli Kusterer
 wrote:
> On 05.04.2009, at 17:15, Michael Ash wrote:
>>
>> Note that, as far as I know, there is no guarantee that -hash will
>> return the same value for the same object across runs of your program.
>
>  Good point. It's not too likely that a hash would be different between
> launches (after all, a hash is of the value, there's no sense in including
> the pointer, because pointer comparisons are already fast and don't need a
> hash), but it's surely possible that the algorithm could change betwen OS
> releases or include some element unique to a particular machine to take
> advantage of hardware features or the like.

You can't include the pointer in the hash at all unless your only test
for equality is object identity. But the algorithm could change across
launches for other reasons. Maybe they dump in a random value just to
keep things interesting, after all.

As for changing across OSes, this definitely actually happens. For
example, NSAttributedString hashing changed on Tiger to hash more
attribute values. I also recall that NSString's hash method was
changed at one point, but I can't find any discussion of this.

>  Also, it's very likely the hash isn't the same between the 64-bit and
> 32-bit runtimes. After all, it's an NSUInteger, which is an unsigned long
> long on 64 bit, but an unsigned long on 32 bit. If you have twice as many
> bits available for storing your hash, the runtime is likely generating more
> widely distributed hashes to take advantage of that.
>
>  In fact, that sounds like a much more likely source of the bug than an
> issue with serializing NSDate. Is your app compiled for 64 bit? Is one of
> the Mac CPUs in question 32-bit and the other 64-bit?

It's also quite likely to be different between PPC and x86
architectures, since there's no need for the hash value to remain
constant between them, and plenty of opportunity for it to change.

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: Beachball on Lengthy Task

2009-04-05 Thread Pierce Freeman
Dear Kirk:

While I probably won't be using that in my current project, it sounds like a
good idea and I will probably look into it if I ever have a need...


On 4/5/09 6:33 AM, "Kirk Kerekes"  wrote:

> Along with threads and various asynchronous techniques already
> mentioned, you should also consider creating a separate UI-less
> "foundation tool" to perform your lengthy task, controlled with NSTask
> in your main app. This yields all of the benefits of a thread, with
> none of the threading pitfalls. Getting real-time feedback (for a
> progress indicator, for example) from the task is more complex than
> with a thread, and getting result data back is slightly more involved,
> but the absolute freedom from threading issues is often worth it.
> 
> Several of Apple's utility apps are constructed as a UI shell that
> invokes one or more tools.
> 
> 
> 


___

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

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

Help/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: Beachball on Lengthy Task

2009-04-05 Thread Pierce Freeman
David:

Thanks for your help, this seems like a class that will be perfect for what
I am doing!  Just a few questions:

1. Is there any concern of thread safety using this class?
2. How can I pass NSFileHandle the file URL of my files?
3. How could I create a method that will take the contents of the file and
do something with them?

Sorry about the big questions. ;)


Sincerely,

Pierce Freeman


On 4/4/09 9:10 PM, "Dave Keck"  wrote:

>> Yeah, it really helped!  I am trying to get the contents of the files in a
>> certain directory, so I think that I could probably get away with using a
>> timer.
> 
> In this case, the reason your task is taking several seconds to
> complete is most likely attributed to the sheer time it takes the read
> the contents of the files; that is, most of the time that it takes for
> the lengthy-task to complete isn't due to lots of
> computation-intensive stuff going on, but rather the age-old slow disk
> read. On the list of the 3 best times to use threads, reading large
> files from disk would perhaps be one of them...
> 
> I probably should have asked for more information before forming my
> last post - for this case in particular, I would use NSFileHandle's
> asynchronous file reading mechanisms (which create separate threads
> for you, so you don't have to worry about it). Read about NSFileHandle
> in the docs, specifically, check out
> -readToEndOfFileInBackgroundAndNotify.
> 
> At any rate, to get the contents of every file in a directory, I would
> iterate over the files in the directory, creating an NSFileHandle for
> each one, and call -readToEndOfFileInBackgroundAndNotify for each.
> Depending on how many files you're expecting, you may need to call
> -readToEndOfFileInBackgroundAndNotify on a small number of
> NSFileHandles, wait until those have finished reading, call it on the
> next group of NSFileHandles, etc.
> 
> Note that while you may have escaped from using threads this time
> (directly, at least) that's not always going to be the case :).
> Threads are indispensable and with the number of cores chips are
> sporting these days, will only become more so...
> 
> Good luck!
> 
> David


___

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

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

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

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


Re: Beachball on Lengthy Task

2009-04-05 Thread Pierce Freeman
Stuart:

That sounds like it could work, however, pointed out by someone else - I
think NSFileHandle's readToEndOfFileInBackgroundAndNotify could work better
as I am dealing with reading files.


On 4/4/09 8:45 PM, "Stuart Malin"  wrote:

> 
> On Apr 4, 2009, at 5:36 PM, Pierce Freeman wrote:
> 
>>> And, if you are 10.5 only, there's also NSObject's
>>> performSelectorInBackground:withObject:
>> 
>> Is this a timer or a thread creator?  I don't believe it has inputs
>> for the
>> time, or could it just do it automatically?  Also, is there some way
>> I can
>> make this work with a function already created?
> 
> That is a thread creator. It will initiate the specified selector of
> the receiver (the invoked object). You can pass a single object to it;
> that object can, of course, contain references to other objects.
> 
> Please be careful to distinguish "method" from "function."  If you
> meant an Objective-C method, yes, it will work with that. If you meant
> a C function, then no, it will not work, at least not directly, but in
> such case it would be easy to create a method that called the function.
> 
> Note: as has already been pointed out, you must be very careful
> regarding thread safety. A background thread task must carefully
> constrain which objects it instantiates and methods used to those that
> are thread safe. Certainly no U/I.
> 
> Read the cited references, and additional material germane to these.
> 
> btw: by any stretch of the imagination, I'm not an expert with threads.
> 


___

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

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

Help/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: IB Plugin help

2009-04-05 Thread Brandon Walkin
I haven't yet made an IB plugin with a custom formatter, but I'd  
assume you change that image the same way you change the image that  
appears in the document window. Return your own image in the - 
ibDefaultImage method in your integration category.


On 5-Apr-09, at 9:31 AM, jmun...@his.com wrote:

1.  How do I change that blue cube (which displays when the  
textfield is selected) to my graphic (like NSNumberFormatter and  
NSDateFormatter)?


___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Greg Guerin

Graham Cox wrote:


My app encodes expiry dates for demo versions, etc.



If you posted the URL where one could obtain the demo version of your  
app, I think several people on the list would be able to try it under  
different languages and locales, as well as different bitness and CPU  
flavors.  The language of the list is English, but that need not be  
the primary language of a subscriber.  And you can reasonably expect  
a modicum of technical ability, so this could give you more data  
points relatively easily.


In short, please post (the URL of) your code.

  -- GG

___

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

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

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

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


Re: PackageMaker Script

2009-04-05 Thread Jean-Daniel Dupas

Is it related in anyway to Cocoa ?

You should try installer-dev instead of cocoa-dev.

http://lists.apple.com/mailman/listinfo/installer-dev


Le 5 avr. 09 à 18:35, John Nairn a écrit :


I cannot get my app installation to run a postflight script.

1. The script runs fine in terminal app and exits with 0
2. It put in the my install package (at path Scripts/postflight) and  
choose that file in the Scripts panel in the postflight field

3. The script is in the built package (when I show its contents)
4. The install proceeds without warning or error (and even a brief  
message says running installer script)
5. The script does not run (as judged by its function is not done  
and none of the "echo" lines appear in console or installer.log)

6. I am using PackageMaker 3.0.3


John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

___

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

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

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

This email sent to devli...@shadowlab.org



___

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

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

Help/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: Beachball on Lengthy Task

2009-04-05 Thread Greg Guerin

Michael Ash wrote:


Processes are a somewhat scarce
resource on OS X (only 266 per user by default, looks like)


That's a raisable (soft) limit.  The hard limit is higher.  See man  
setrlimit.


In bash, the command 'ulimit -Sa' lists the soft limits, and 'ulimit - 
Ha' lists the hard ones.


  -- GG

___

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

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

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

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


Re: Need localization-proof method of transporting dates.

2009-04-05 Thread Greg Guerin

Graham Cox wrote:

Sure, I understand that. Actually the SHA-1 hash is derived from  
the - hash of several objects, not just the date. My take is that  
the combination of the several objects (typically about 8 different  
pieces of information) is sufficiently unique to be unspoofable in  
practice. And in fact the SHA-1 is only used as a signature anyway,  
not as a unique value in its own right - the existence of identical  
SHA-1 hashes for different info sets wouldn't matter.


Do you present a hash failure to the user in the same way as  
expiration of the date? Maybe one of the other hashes is changing,  
and it isn't necessarily the date.



Nice thought, but not the case. The expiry is firing several months  
too early, not just a few hours.



It might be worthwhile to temporarily change the primary language on  
your machine, long enough to cause your app to trigger the problem,  
so you can see it happen.  I don't know Korean or Arabic, but I can  
switch the language and puzzle it out well enough with menu positions  
and menu lengths and the like to figure things out.


You might also try changing the date on your machine, then create a  
series of future expiries with sequential months, different days, and  
different years, so you can try them all under the foreign language  
that's known to fail.  The idea is to get enough predictable data  
points so you can observe more than occasional failures.  Then a  
pattern might emerge.


  -- GG
___

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

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

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

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


PackageMaker Script

2009-04-05 Thread John Nairn

I cannot get my app installation to run a postflight script.

1. The script runs fine in terminal app and exits with 0
2. It put in the my install package (at path Scripts/postflight) and  
choose that file in the Scripts panel in the postflight field

3. The script is in the built package (when I show its contents)
4. The install proceeds without warning or error (and even a brief  
message says running installer script)
5. The script does not run (as judged by its function is not done and  
none of the "echo" lines appear in console or installer.log)

6. I am using PackageMaker 3.0.3


John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

___

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

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

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

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


Re: NSXMLParser memory consumption

2009-04-05 Thread George King
I hit a stumbling block when passing large files (multi-GB) to  
NSXMLParser.


Are you doing this in 64 bit?


Yes, I switched to building x86_64 because NSXMLParser was refusing  
files over 4GB.


It appears that NSXMLParser's initWithContentsOfURL: method loads  
the contents of the entire file into memory, which is causing  
virtual memory thrashing for at file sizes approaching my physical  
RAM (2 GB in this case, so I start seeing performance issues at  
around 1.3 GB). After reading the CFXMLParser documentation, I  
suspect that core foundation does the same thing.


Yes, probably.  Have you tried initializing it with a memory-mapped  
NSData instead of an NSURL?


Thank you for the suggestion; I was unaware of  
initWithContentsOfMappedFile:. This worked to a certain extent, in  
that it kept memory consumption to within the bounds of available  
physical memory, but it still consumed all the memory available. This  
caused a good deal of thrashing when I tried running the test and  
working at the same time.


Can somebody suggest an alternative API for parsing xml that does  
not have memory requirements linear with file size for the  
initialization? Given the event-driven design I originally imagined  
that the parser would read through a file incrementally, without  
loading it all into memory.


My Objective-XML might help, though I haven't tried it for files  
quite that large yet.  The largest I tried was a couple of hundred  
MB, which worked fine.   For one, it uses significantly less memory  
than NSXMLParser (and is faster),  trying very hard to touch as  
little memory as possible and keep as little of it around as  
possible.  It also actually does incremental loading of URLs, though  
it will detect file-URLs and then load them directly (and use  
dataWithContentsOfURL:, which will likely also do a read() instead  
of an mmap() ).


It has an NSXMLParser-compatible SAX API as well as a more  
convenient MAX API.


Current download is at:

http://www.metaobject.com/downloads/Objective-C/Objective-XML-5.1.tgz

I just tried it with a 190 MB XML file, which took around 7s to  
parse on my MacBook Pro.  RPRVT stayed at 600KB the whole time,  
RSHRD was also not affected.   RSIZE did go to 191MB, reflecting the  
fact that more and more of the mapped file's memory gets mapped into  
the process in question.



Thanks for the link - I will investigate. Yesterday I got into  
libxml2, and the xmlReader API provides functionality equivalent to  
NSXMLParser without the memory consumption.


___

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

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

Help/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: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-05 Thread Uli Kusterer

On 04.04.2009, at 02:30, Eric Hermanson wrote:

Now, one would expect that the array would contain:

element 1: MyCounterInstance.oid=1
element 2: MyCounterInstance.oid=2

However, this is NOT the case.  Either the compiler or the runtime  
executes the SECOND call to [MyCounterClass newObject] FIRST, so the  
array actually contains:


element 1: MyCounterInstance.oid=2
element 2: MyCounterInstance.oid=1



Nothing to do with ObjC or NSArray. That's a part of the C standard  
left open to allow platform-specific optimizations. I've blogged about  
it in a simpler context here:


http://zathras.de/blog-c-parameter-evaluation-order.htm

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Uli Kusterer

On 05.04.2009, at 17:15, Michael Ash wrote:

Note that, as far as I know, there is no guarantee that -hash will
return the same value for the same object across runs of your program.



 Good point. It's not too likely that a hash would be different  
between launches (after all, a hash is of the value, there's no sense  
in including the pointer, because pointer comparisons are already fast  
and don't need a hash), but it's surely possible that the algorithm  
could change betwen OS releases or include some element unique to a  
particular machine to take advantage of hardware features or the like.


 Also, it's very likely the hash isn't the same between the 64-bit  
and 32-bit runtimes. After all, it's an NSUInteger, which is an  
unsigned long long on 64 bit, but an unsigned long on 32 bit. If you  
have twice as many bits available for storing your hash, the runtime  
is likely generating more widely distributed hashes to take advantage  
of that.


 In fact, that sounds like a much more likely source of the bug than  
an issue with serializing NSDate. Is your app compiled for 64 bit? Is  
one of the Mac CPUs in question 32-bit and the other 64-bit?


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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

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

Help/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: Beachball on Lengthy Task

2009-04-05 Thread Michael Ash
On Sun, Apr 5, 2009 at 9:33 AM, Kirk Kerekes  wrote:
> Along with threads and various asynchronous techniques already mentioned,
> you should also consider creating a separate UI-less "foundation tool" to
> perform your lengthy task, controlled with NSTask in your main app. This
> yields all of the benefits of a thread, with none of the threading pitfalls.
> Getting real-time feedback (for a progress indicator, for example) from the
> task is more complex than with a thread, and getting result data back is
> slightly more involved, but the absolute freedom from threading issues is
> often worth it.
>
> Several of Apple's utility apps are constructed as a UI shell that invokes
> one or more tools.

I recommend avoiding this if possible. Processes are a somewhat scarce
resource on OS X (only 266 per user by default, looks like) and you
don't want to be using up more than you have to. It's unfortunate
because it can make things easier as you say.

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: Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-05 Thread Jean-Daniel Dupas

This is not the var arg, it append with all functions (on Intel Mac).
Evaluation order in argument passing is undefined.
 Someone in this thread (Mike IIRC) quoted the sentence in the C  
standard that states this.




Le 4 avr. 09 à 08:14, Eric Hermanson a écrit :

A comma is a sequence yet the order in arrayWithObjects is  
indeterminate.  It must be the var arg causing the ordering mix.


Sent from my iPhone

On Apr 4, 2009, at 12:29 AM, Michael Ash   
wrote:


On Fri, Apr 3, 2009 at 8:30 PM, Eric Hermanson   
wrote:
Some (or most) people might be aware of this caveat, but I was  
not, so I'll

share it.

Consider this code:

  NSArray *array = [NSArray arrayWithObjects:[MyCounterClass  
newObject],

[MyCounterClass newObject], nil];

where [MyCounterClass newObject] is a static method that returns a  
new
autoreleased instance that simply stores an incrementing int32  
counter in

its instance variable, e.g.

  self.oid = SomeStaticCounter++;   // (or ideally,
OSAtomicIncrement32Barrier(&SomeStaticCounter);

Now, one would expect that the array would contain:

  element 1: MyCounterInstance.oid=1
  element 2: MyCounterInstance.oid=2

However, this is NOT the case.  Either the compiler or the runtime  
executes
the SECOND call to [MyCounterClass newObject] FIRST, so the array  
actually

contains:

  element 1: MyCounterInstance.oid=2
  element 2: MyCounterInstance.oid=1

NSArray arrayWithObjects: is of course correctly putting the  
objects into
the array in the correct natural ordering, but the objects are  
CREATED on
the stack in the oppose order.  Maybe most people knew that, I did  
not.  So

the (or a) workaround is:

  MyCounterClass *object1 = [MyCounterClass newObject];
  MyCounterClass *object2 = [MyCounterClass newObject];
  NSArray *array = [NSArray arrayWithObjects: object1, object2,  
nil];


This is actually a "feature" of C, which ObjC inherits. C does not
define an order of operations except across "sequence points", which
are basically semicolons, although C defines some others too.
Different parts of a statement are executed in an arbitrary order.
Basically, the compiler can decide which order suits it best. As  
such,

conforming C (and thus ObjC) code must never rely on the order of
execution of function arguments, arithmetic subexpressions, or
anything else of that nature. In any given statement, there should
never be two parts of the statement that have interdependent side
effects.

Wikipedia has a decent discussion of this concept along with some
illuminating examples:

http://en.wikipedia.org/wiki/Sequence_point

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/zmonster%40mac.com

This email sent to zmons...@mac.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/devlists%40shadowlab.org

This email sent to devli...@shadowlab.org



___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Michael Ash
On Sun, Apr 5, 2009 at 5:24 AM, Graham Cox  wrote:
>
> On 05/04/2009, at 5:02 AM, Greg Guerin wrote:
>
>> An object's -hash method is not guaranteed to return a unique value.
>>  Different objects can have the same hash as other objects of the same type,
>> or of different types.  Therefore, if you are calculating a SHA-1 hash of
>> the -hash value returned from the NSDate, your authentication can be spoofed
>> by an unknown number of other NSDate objects that return the same value from
>> -hash.
>
>
> Sure, I understand that. Actually the SHA-1 hash is derived from the -hash
> of several objects, not just the date. My take is that the combination of
> the several objects (typically about 8 different pieces of information) is
> sufficiently unique to be unspoofable in practice. And in fact the SHA-1 is
> only used as a signature anyway, not as a unique value in its own right -
> the existence of identical SHA-1 hashes for different info sets wouldn't
> matter.

Note that, as far as I know, there is no guarantee that -hash will
return the same value for the same object across runs of your program.
Apple is free to change their algorithm in an OS update, and could
conceivably (although I don't see why) switch between different
algorithms at process start time. You'll want to use your own hashing
algorithm for this.

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:Beachball on Lengthy Task

2009-04-05 Thread Kirk Kerekes
Along with threads and various asynchronous techniques already  
mentioned, you should also consider creating a separate UI-less  
"foundation tool" to perform your lengthy task, controlled with NSTask  
in your main app. This yields all of the benefits of a thread, with  
none of the threading pitfalls. Getting real-time feedback (for a  
progress indicator, for example) from the task is more complex than  
with a thread, and getting result data back is slightly more involved,  
but the absolute freedom from threading issues is often worth it.


Several of Apple's utility apps are constructed as a UI shell that  
invokes one or more tools.




___

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

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

Help/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: IB Plugin help

2009-04-05 Thread jmunson

Namaste!

Thank you Kevin and Josh!

Josh:

To clear up the assertion error, "Clean All Targets."  There was some  
junk not getting dumped out of the project on successive builds.


Also, you nailed it with the "TextLength" key. Doh!  I  
took Apple's file comment of "MyFirstKey" literally.  While not  
terribly new with KVC, this is my first plugin and I thought Apple may  
be doing something different.  So, I took the comment at face value.


After changing TextLength to textLength, the plugin operates as expected.

Kevin:

[A]
1.  Yes.

2.  com.JTAENTERPRISESLLC.JTAENTLLCTextLengthLimiter,  
com.JTAENTERPRISESLLC.JTAENTLLCTextLengthLimiter


Here's the output of the two terminal commands:

1st command (known):

"com.JTAENTERPRISESLLC.JTAENTLLCTextLengthLimiter" =  
"/Users/jcmii/JTAENTLLCTextLengthLimiter/JTAENTLLCTextLengthLimiter/build/Debug/JTAENTLLCTextLengthLimiter.ibplugin";
"com.JTAENTERPRISESLLC.JTAENTLLCTextLengthLimiterFormatter" =  
"/Users/jcmii/StashWizG/StashWizG/JTAENTLLCTextLengthLimiter.framework/Resources/JTAENTLLCTextLengthLimiter.ibplugin";



2nd command (loaded):

"com.JTAENTERPRISESLLC.JTAENTLLCTextLengthLimiter"

I do have two remaining questions:

1.  How do I change that blue cube (which displays when the textfield  
is selected) to my graphic (like NSNumberFormatter and NSDateFormatter)?


2.  When I deploy my application do I need to deploy my plugin to the  
Library/Frameworks directory on the client machine, or is it enough to  
bundle it with my application?


Many Thanks!!!

Peace, Love, and Light,

/s/ Jon C. Munson II

Quoting josh hughes :


Hi Jon,

I tried compiling the project you attached but I was still getting
Assertion Failures so I built the project from scratch again and it
loads into IB without Assertion Failures (I think there is definitely
something not setup right in the project you attached!).

O.k First off, just to check; you are adding the framework to your
live app, i.e...
in Groupes & Files (in your live app!):

Browse to Frameworks and select Other Frameworks.
Right click (ctl click) and navigate to Add->Existing Frameworks.
In the open panel, browse to and select /Library/
NameOfYourFramework.framework.
Click Add.

Other Frameworks should now look something like this:

Other Frameworks/
NameOfYourFramework.framework
AppKit.framework
CoreData.framework
Foundation.framework

It Is important your live app has the framework added to it as your
plugin is dependent  on it and will crash if it's not there!

Sorry if you are already doing this, I thought It's better to make
sure as this is quite important!

Secondly, I think the reason IB keeps opening the new document window
when you try and reopen the .xib is because the encoder is failing to
encode the @"TextLength"  property as it is not KVC-Compliant, so the
component crashes when you try to save the xib, hence it also crashes
when you try to decode/open the doc.

I noticed that the component's console was spewing out errors when I
tried to save or reopen an .xib the the component in it (in a live app):

009-04-05 12:32:51.436 Interface Builder[26488:10b] An exception was
thrown during execution of an NSScriptCommand...
2009-04-05 12:32:51.438 Interface Builder[26488:10b]
[ valueForUndefinedKey:]: this
class is not key value coding-compliant for the key TextLength.

I changed:
[[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:
[NSArray arrayWithObjects:@"TextLength", nil]];

to:
[[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray:
[NSArray arrayWithObjects:@"textLength", nil]];

and this seems to have stopped the crashing when reopening the .xib.

I have the project working here and can send you a .zip if you like?

Hope this helps.

All the best,
Josh

On 5 Apr 2009, at 01:10, jmun...@his.com wrote:




Sorry for going quiet like that! I got distracted!



No problem! :)


I think that the fact IB is asking you to create a new document is a
good thing!


Actually, not in this case.  The plugin seems to work fine within
its project, so I decided to try and "install" it so I could use it  
  in my other (live) project.  I created a new window xib
(imaginatively called "test"), put a textfield on it and saved it.   
  Then, I added the formatter to the textfield, gave it a value of  
5   and saved that.  On re-open, IB then asked me what sort of   
resource  to create - test was corrupted I suppose.



I believe that when the project builds, the compiler automatically
launches the target/s (in this case an IB Plugin Component/bundle)
which in turn loads the plugin into IB and asks for you to create a
new document (to test it out)!?

So I think so far things are looking good!



In the case of the plug-in only, yes, it seems viable.  However,
"live" is not the case.



However, when I compiled the project, the component crashed IB,
warning about an Assertion Failure:

Assertion Message: Two plug-ins
(com.JTAENTE

Re: Linking the "document edited" flag to the Undo menu item state

2009-04-05 Thread Graham Cox


On 04/04/2009, at 3:22 AM, Ashley Clark wrote:

As far as I know returning the undo manager via your window  
delegate's windowWillReturnUndoManager: only keeps the window from  
creating its' own undo manager, it does not set up the mechanisms to  
update the window's dirty state.



Yes, I stand corrected. I was sure this was all you needed to do, but  
I just tried it and sure enough, it's not working.


--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: Cocoa user pane equivalent?

2009-04-05 Thread Graham Cox


On 05/04/2009, at 12:20 PM, Jo Meder wrote:

The one thing I'm not really clear on is what the Cocoa equivalent  
of a Carbon user pane control would be. It seems that there isn't  
really a direct equivalent in Cocoa and that the best way to do  
things would be to have a custom view inheriting from NSControl.  
Would that be right?



Jo, do you mean a dialog 'user item'?

These items did nothing except define a rectangular region of the  
dialog that you could customise in some unspecified way. The cocoa  
equivalent would be NSView, though it gives you far more than just a  
frame and then leaves the rest to you.


You could certainly subclass NSControl if you wanted a custom control  
(NSControl subclasses NSView) but NSView is more flexible in many  
ways, as all more general objects tend to be.


--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: IB Plugin help

2009-04-05 Thread josh hughes

Hi Jon,

I tried compiling the project you attached but I was still getting  
Assertion Failures so I built the project from scratch again and it  
loads into IB without Assertion Failures (I think there is definitely  
something not setup right in the project you attached!).


O.k First off, just to check; you are adding the framework to your  
live app, i.e...

in Groupes & Files (in your live app!):

Browse to Frameworks and select Other Frameworks.
Right click (ctl click) and navigate to Add->Existing Frameworks.
In the open panel, browse to and select /Library/ 
NameOfYourFramework.framework.

Click Add.

Other Frameworks should now look something like this:

Other Frameworks/
NameOfYourFramework.framework
AppKit.framework
CoreData.framework
Foundation.framework

It Is important your live app has the framework added to it as your  
plugin is dependent  on it and will crash if it's not there!


Sorry if you are already doing this, I thought It's better to make  
sure as this is quite important!


Secondly, I think the reason IB keeps opening the new document window  
when you try and reopen the .xib is because the encoder is failing to  
encode the @"TextLength"  property as it is not KVC-Compliant, so the  
component crashes when you try to save the xib, hence it also crashes  
when you try to decode/open the doc.


I noticed that the component's console was spewing out errors when I  
tried to save or reopen an .xib the the component in it (in a live app):


009-04-05 12:32:51.436 Interface Builder[26488:10b] An exception was  
thrown during execution of an NSScriptCommand...
2009-04-05 12:32:51.438 Interface Builder[26488:10b]  
[ valueForUndefinedKey:]: this  
class is not key value coding-compliant for the key TextLength.


I changed:
	[[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray: 
[NSArray arrayWithObjects:@"TextLength", nil]];


to:
	[[keyPaths objectForKey:IBAttributeKeyPaths] addObjectsFromArray: 
[NSArray arrayWithObjects:@"textLength", nil]];


and this seems to have stopped the crashing when reopening the .xib.

I have the project working here and can send you a .zip if you like?

Hope this helps.

All the best,
Josh

On 5 Apr 2009, at 01:10, jmun...@his.com wrote:




Sorry for going quiet like that! I got distracted!



No problem! :)


I think that the fact IB is asking you to create a new document is a
good thing!


Actually, not in this case.  The plugin seems to work fine within  
its project, so I decided to try and "install" it so I could use it  
in my other (live) project.  I created a new window xib  
(imaginatively called "test"), put a textfield on it and saved it.   
Then, I added the formatter to the textfield, gave it a value of 5  
and saved that.  On re-open, IB then asked me what sort of resource  
to create - test was corrupted I suppose.



I believe that when the project builds, the compiler automatically
launches the target/s (in this case an IB Plugin Component/bundle)
which in turn loads the plugin into IB and asks for you to create a
new document (to test it out)!?

So I think so far things are looking good!



In the case of the plug-in only, yes, it seems viable.  However,  
"live" is not the case.



However, when I compiled the project, the component crashed IB,
warning about an Assertion Failure:

Assertion Message: Two plug-ins
(com.JTAENTERPRISESLLC.JTAENTLLCTextLengthLimiter and
com.JTAENTERPRISESLLC.JTAENTLLCTextLengthLimiter) both integrate a
class description for the class JTAENTLLCTextLengthLimiterFormatter.
The primary definition for the class should only come from one plug-
in; the other plug-in should be declaring a category. Declaring a
category is accomplished by omitting the super class from
classdescription file.

I have no idea where any of this is coming from or how to fix it!



I think I fixed that in the attached zip.  Not sure what I did,  
other than to make sure all my "names" matched up in the appropriate  
places (I think the error was in the Limiter.m file).


I did try replicating (more or less) the project from scratch and  
this

seemed to get rid of the Assertion Failure and the plugin seemed to
load o.k.

Check out the attachment!



I also tested your plugin re-deux in my "live" environment and got  
the same result.  An xib wherein the plug-in is employed seems to  
get corrupted and IB then asks for a new resource to create.


Give that a shot.  Put your plug-in (or mine) in some frameworks  
directory, add it to IBs prefs->plug-ins, and add it to a project.   
Create a new window.xib, add a textfield, then use the formatter.   
Save and close the xib.  Upon re-load it should crash (IB won't  
crash though - just the xib is corrupted).


One thing I did notice about my plug-in is that the required  
framework seems to want the ibplugin file.  I don't know how to  
revert that to the .framework file.  Although, in yours, it is  
pointing to the .framework file and it still cra

Re: Toll-free bridge type at runtime

2009-04-05 Thread Ryan Joseph
I think you misunderstand, this check can't be made at compile time.  
Also the moderator said:


this thread has passed it's usefulness. It certainly isn't appropriate  
for cocoa-dev anyways.


so I think that means it has been banned. ;) What you said sparks some  
ideas anyway that I will keep in mind. Thanks.


On Apr 5, 2009, at 4:22 PM, Uli Kusterer wrote:


On 03.04.2009, at 09:22, Ryan Joseph wrote:
The Pascal compiler I'm using would need some extra runtime support  
(like telling me if a pointer is an object) to accomplish what you  
are talking about, but yes that is the way it should work. I think  
the Ruby and Python bridges made changes to the actual compiler  
also that I'm not able to do so I need to look into other more  
creative solutions.



Maybe I'm misunderstanding you, but can't you instead just do a  
compile-time switch on the pointer's type? If someone declares an  
ObjC pointer type (or CF pointer type) as a parameter type, you can  
tell *at compile time* that passing a regular array will need to be  
converted to that type. So you insert the conversion code. That is  
where you should IMHO be trying to solve that problem.


Alternatively, I'm not too familiar with the Object Pascal runtime,  
but aren't there classes used for the built-in types that you could  
possibly redefine? Either just make them thin wrappers around  
CFArrays etc., or create several subclasses (a class cluster if you  
wish) that are regular Pascal arrays and CFArrays, and have  
functions to convert from one to the other.


Then you could generate a stub library using the BridgeSupport files  
that automatically wraps CFTypes in appropriate Pascal objects. Of  
course, that still wouldn't solve the issues of directly  
manipulating structs that contain CFTypes, but I presume those would  
need to be handled specially anyway.


But finally, keep in mind that even Objective C makes no effort to  
bridge the plain C types to CFTypes. So I think it would be  
perfectly OK to just not do that wrapping, but rather provide  
conversion functions for those cases where you need it, and let  
people deal directly with the CFTypes (Maybe aided by simple helper  
classes they can add to their projects).


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de







Regards,
Josef

___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Uli Kusterer

On 05.04.2009, at 11:24, Graham Cox wrote:
However it does seem as if writing out the date as seconds since  
1970 (or a string, as Tommy suggested) might be safer and cut out  
any potential gotchas that I haven't realised existed.



 Keep us posted whether that fixes it.

 Have you got a copy of the user's Preferences file? There might be  
some clue in there, e.g. use of different date separators or so. My  
guess would be that an invalid date will probably end up as [NSDate  
distantPast], or NIL and thus return NO if it's the first item in your  
test, or throw if it's the second.


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Uli Kusterer

On 04.04.2009, at 19:50, Greg Guerin wrote:

timeIntervalSince1970



-timeIntervalSinceReferenceDate sounds like a longer-lasting, more  
modern alternative :-)


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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

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

Help/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: Need localization-proof method of transporting dates.

2009-04-05 Thread Graham Cox


On 05/04/2009, at 5:02 AM, Greg Guerin wrote:

An object's -hash method is not guaranteed to return a unique  
value.  Different objects can have the same hash as other objects of  
the same type, or of different types.  Therefore, if you are  
calculating a SHA-1 hash of the -hash value returned from the  
NSDate, your authentication can be spoofed by an unknown number of  
other NSDate objects that return the same value from -hash.



Sure, I understand that. Actually the SHA-1 hash is derived from the - 
hash of several objects, not just the date. My take is that the  
combination of the several objects (typically about 8 different pieces  
of information) is sufficiently unique to be unspoofable in practice.  
And in fact the SHA-1 is only used as a signature anyway, not as a  
unique value in its own right - the existence of identical SHA-1  
hashes for different info sets wouldn't matter.


I suspect that when you write an expiry NSDate to a plist file, it  
represents your local date and time.  This expiry is then expiring  
at your local time, not the recipient's local time.  However, since  
it's later in your location than almost anywhere else in the world,  
the recipient perceives the expiration as premature.


The problem is not in the localization of NSDate.  The problem is in  
not accounting for time-zone differences between your location and  
the user's location.



Nice thought, but not the case. The expiry is firing several months  
too early, not just a few hours. While the date written does represent  
my local time, the exact expiry would only be affected by a few hours.  
I pretty much don't care about that - I don't tell the user to the  
second when it will expire anyway, only which day.


However it does seem as if writing out the date as seconds since 1970  
(or a string, as Tommy suggested) might be safer and cut out any  
potential gotchas that I haven't realised existed.


--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: Error: mutating method sent to immutable object

2009-04-05 Thread Graham Cox


On 05/04/2009, at 4:50 AM, Priscila J.V. wrote:


Can you please suggest me something to fix it?



Why not try randomly changing the code without thinking about the  
problem until it stops throwing errors?


Yes you're right, that would be stupid. So why are you doing it?

You need to develop the ability to read your code and mentally  
understand what is actually happening. I pointed out the problem in my  
very first reply to you, yet you haven't acted on it, and instead are  
just expecting someone else to fix up the mess. We could, but you  
won't have learned a thing. A problem you fix yourself is worth ten  
fixed by somebody else.


So try a bit harder... and take heed of my note about carelessness.

--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: Toll-free bridge type at runtime

2009-04-05 Thread Uli Kusterer

On 03.04.2009, at 09:22, Ryan Joseph wrote:
The Pascal compiler I'm using would need some extra runtime support  
(like telling me if a pointer is an object) to accomplish what you  
are talking about, but yes that is the way it should work. I think  
the Ruby and Python bridges made changes to the actual compiler also  
that I'm not able to do so I need to look into other more creative  
solutions.



 Maybe I'm misunderstanding you, but can't you instead just do a  
compile-time switch on the pointer's type? If someone declares an ObjC  
pointer type (or CF pointer type) as a parameter type, you can tell  
*at compile time* that passing a regular array will need to be  
converted to that type. So you insert the conversion code. That is  
where you should IMHO be trying to solve that problem.


 Alternatively, I'm not too familiar with the Object Pascal runtime,  
but aren't there classes used for the built-in types that you could  
possibly redefine? Either just make them thin wrappers around CFArrays  
etc., or create several subclasses (a class cluster if you wish) that  
are regular Pascal arrays and CFArrays, and have functions to convert  
from one to the other.


 Then you could generate a stub library using the BridgeSupport files  
that automatically wraps CFTypes in appropriate Pascal objects. Of  
course, that still wouldn't solve the issues of directly manipulating  
structs that contain CFTypes, but I presume those would need to be  
handled specially anyway.


 But finally, keep in mind that even Objective C makes no effort to  
bridge the plain C types to CFTypes. So I think it would be perfectly  
OK to just not do that wrapping, but rather provide conversion  
functions for those cases where you need it, and let people deal  
directly with the CFTypes (Maybe aided by simple helper classes they  
can add to their projects).


Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





___

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

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

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

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


Re: NSXMLParser memory consumption

2009-04-05 Thread Marcel Weiher


On Apr 4, 2009, at 9:02 , George King wrote:

I hit a stumbling block when passing large files (multi-GB) to  
NSXMLParser.


Are you doing this in 64 bit?

It appears that NSXMLParser's initWithContentsOfURL: method loads  
the contents of the entire file into memory, which is causing  
virtual memory thrashing for at file sizes approaching my physical  
RAM (2 GB in this case, so I start seeing performance issues at  
around 1.3 GB). After reading the CFXMLParser documentation, I  
suspect that core foundation does the same thing.


Yes, probably.  Have you tried initializing it with a memory-mapped  
NSData instead of an NSURL?


Can somebody suggest an alternative API for parsing xml that does  
not have memory requirements linear with file size for the  
initialization? Given the event-driven design I originally imagined  
that the parser would read through a file incrementally, without  
loading it all into memory.


My Objective-XML might help, though I haven't tried it for files quite  
that large yet.  The largest I tried was a couple of hundred MB, which  
worked fine.   For one, it uses significantly less memory than  
NSXMLParser (and is faster),  trying very hard to touch as little  
memory as possible and keep as little of it around as possible.  It  
also actually does incremental loading of URLs, though it will detect  
file-URLs and then load them directly (and use dataWithContentsOfURL:,  
which will likely also do a read() instead of an mmap() ).


It has an NSXMLParser-compatible SAX API as well as a more convenient  
MAX API.


Current download is at:

http://www.metaobject.com/downloads/Objective-C/Objective-XML-5.1.tgz

I just tried it with a 190 MB XML file, which took around 7s to parse  
on my MacBook Pro.  RPRVT stayed at 600KB the whole time, RSHRD was  
also not affected.   RSIZE did go to 191MB, reflecting the fact that  
more and more of the mapped file's memory gets mapped into the process  
in question.



Note that once the NSXMLParser delegate starts receiving messages, I  
am able to keep memory usage under control by giving the delegate  
its own autorelease pool and draining/replacing it once every x  
calls to parser:didStartElement





Marcel

___

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

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

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

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