Re: Toll-free bridge type at runtime

2009-04-03 Thread Marcel Weiher


On Apr 2, 2009, at 18:44 , Michael Ash wrote:

On Thu, Apr 2, 2009 at 7:37 PM, Marcel Weiher  
marcel.wei...@gmail.com wrote:

It can be
distinguished from an array created using CFArrayCreate, just as it
can be distinguished from an array created using [NSArray array],


Glad that you agree that the test can be performed, which is  
different from

what you said before:
On Apr 1, 2009, at 21:44 , Michael Ash wrote:

The test cannot be performed, because the question does not make  
any sense.


I am not agreeing that the test can be performed. The test is to
distinguish between a CFArray and an NSArray.


Which is still fairly trivial except for the one special (but common/ 
important) case where they are the same, which is if the NSArray in  
question is an NSCFArray.



What I am saying above
is that it is possible to distinguish between a custom NSArray
subclass and a subclass provided by the system. These are not the same
thing.


How are they not the same thing?  If you say NSArray, what do you  
mean?  Do you mean the NSArray class itself?  In that case, this is  
all pointless, because you are hardly going to get actual NSArray  
instances, it being an abstract superclass and all.  If by NSArray  
something that is an NSArray (so NSArray and its subclasses), then  
that is exactly the same thing, because CFArray is a system-provided  
subclass of NSArray.


Or do you mean NSCFArray when you say NSArray?  That would be pretty  
tautologically pointless and also wrong, because NSArray and NSCFArray  
are simply not the same thing, the fact that you get NSCFArrays when  
you ask NSArray for instances notwithstanding.




On another note, I find your habit of quoting what I say and then
stating so you really mean X to be extremely irritating. I don't
mind if you disagree with me, but please do so explicitly, rather than
taking my own words and then twisting them to suit you.


Sorry you feel irritation, but I am not twisting your words, I am  
just quoting you.  The inconsistencies in what you claim are in your  
words, not in my quoting of them.


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

2009-04-03 Thread Chris Suter
Hi Marcel,

[snip]
 However, that does not mean that they are the same.

They are the effectively the same and I couldn't see anything in your
e-mail that proves otherwise.

You appear to have proven that a subclass of NSArray doesn't happen to
be a descendent NSCFArray (nobody asked that though) and you've proven
that you can tell the difference between a subclass and a regular
NSArray (but nobody asked about that either).

There's one other point that I should make: there's nothing stopping
you from using CFArray… functions on your NSArray subclass.

So, I'm still confused, as I was before, not about the issue, but
exactly what it is you're trying to say and how it's helpful with
respect to the original problem.

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

2009-04-03 Thread Marcel Weiher


On Apr 2, 2009, at 23:22 , Chris Suter wrote:


Hi Marcel,

[snip]

However, that does not mean that they are the same.


They are the effectively the same and I couldn't see anything in your
e-mail that proves otherwise.


I have said from the very beginning while the anser is mostly true  
for what the original poster is trying to accomplish, it is actually  
not true.


Reading helps.

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

2009-04-03 Thread Ryan Joseph


On Apr 3, 2009, at 12:47 PM, Bill Bumgarner wrote:


On Apr 2, 2009, at 8:40 PM, Ryan Joseph wrote:
// We must use the Handle which is the Objective-C object because  
dragTypes is a NSArray wrapper and passing a Pascal object to  
Objective-C runtime WILL cause errors


dragTypes := NSArray.array_;
view.registerForDraggedTypes(dragTypes.Handle);

I just didn't want users to type .Handle and let that choice be  
made a runtime behind the scenes. Was that worth everyones time? ;)


If it is what was required to lead to this point, then ... yes... it  
was an unfortunate use of time but ultimately led to this rather  
important detail that probably should have been posted in the first  
place. ;)
In retrospect for sure. ;) At first I thought it would just be an  
extra detail to confuse people.





So -- you aren't actually building a transparent bridge.  You are  
effectively building a solution that proxies objects between one  
side and the other and, on the Pascal side (at the least), the users  
of your proxying bridge have to take an extra step to gain access to  
the underlying object.


It is certainly a valid way to build a bridge between the  
languages.  But is the extra level of indirection really necessary?
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.


Thanks for your ideas.




RubyCocoa, PyObjC, and a number of other bridges are all proofs that  
-- for said languages -- having indirect proxies in the targeted  
language is not necessary.   For PyObjC and RubyCocoa (now MacRuby),  
the array classes are rendered in a compatible fashion between the  
languages.
I bet those languages do something similar to what I am, that is make  
a native Ruby class and within one of it's instance variables store  
the Objective-C object, which is dereferences when passing the Ruby  
object to Cocoa methods. The difference is I'm sure they added runtime  
support to know if a generic pointer is a Ruby class or otherwise so  
they can make safe choices at runtime.



That is, if via PyObjC, you pass a Python array to an Objective-C  
method as a parameter, it is received as a subclass of NSArray that  
just works.  Similarly, any random NSArray instance passed from  
Objective-C into Python shows up as a python array object.


Now, maybe there is some particular design point of the Pascal  
variant that you are targeting that prevents this.
Simply, if I attempt to dereference a pointer that is in fact a  
CoreFoundation type it will crash. I need to know if it's a CFType,  
and if not dereferencing is safe. Knowing if it was a Pascal object  
would be just as good, but I don't have that option.





Regardless, there is a tremendous body of work available that  
successfully demonstrates bridging between Objective-C and other  
languages.  Much of it is under extremely liberal license -- PyObjC  
is MIT Licensed, feel free to copy/paste at will -- and it would  
likely be a boon to you to explore such implementations deeply?


b.bum



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


Stop the form from refresh again

2009-04-03 Thread developers mac
Hi there,

 I am developing an application for iphone. I am moving from a.xib to
b.xib  fetching a value  return back to a.xib. By the mean time all values
entered in the textfields of the a.xib files getting cleared (I am building
the whole page on the viewdidload method). I want stop this. Is there any
suggestion on that?
___

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

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

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

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


Re: Stop the form from refresh again

2009-04-03 Thread Alexander Spohr


Am 03.04.2009 um 10:22 schrieb developers mac:


(I am building the whole page on the viewdidload method).


If you build the page fill in the values...

And please people, stop posting anonymously! Give your mail accounts a  
name or at least sign your messages. I don’t like to answer people  
whose name is „developers mac“ or „Developer“.


atze

___

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

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

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

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


Dragging around an NSImageView

2009-04-03 Thread Aaron Scott

Hi,

I'm trying to figure out how to be able to drag an NSImageView around.  
The NSImageView has been added as a subview to another NSImageView.


Basically, I'm trying to drag a grey box around over the top of a  
picture. I can programmatically move it around but I can't seem to  
find the right code to allow me to drag it around.


Cheers,
Aaron


--

A Handicapped parking sign does not signify that this spot is for  
handicapped people. It is actually in fact a warning, that the spot  
belongs to Chuck Norris and that you will be handicapped if you park  
there.


___

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

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

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

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


Re: Bindings and MenuItems

2009-04-03 Thread Alexander Spohr


Am 03.04.2009 um 06:49 schrieb Ben Lachman:

No.  That was what my original message outlined.  Say you have a  
table view selected and hit cmd-p.  NSView has a default  
implementation of print: so it will print the table view.  In my  
case and in many others what you really want to print is the detail  
view or some representation of it that actually shows the currently  
data of the selected object(s).  So no that's not really what the  
first responder is for.


Why not subclassing that table view and overriding print:?

atze

___

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

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

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

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


Create a folder as a package/bundle ...

2009-04-03 Thread Mic Pringle
Hi,

How would one go about creating a folder that would appear to the
finder as a bundle/package ?

In the app I'm working on, I need to implement this as the save
function generates more than one file, and is sort of a 'project' so
could have associated resources etc but I would like to use a custom
file extension and have it all look like a single file instead of
several.

Any help would be greatly appreciated.

Thanks,

-Mic
___

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

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

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

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


Re: Stop the form from refresh again

2009-04-03 Thread I. Savant

On Apr 3, 2009, at 6:12 AM, Alexander Spohr wrote:

I don’t like to answer people whose name is „developers mac“ or  
„Developer“.


  Then don't.

  It's everybody's right to post under whatever name they wish just  
as it's your right not to answer.


--
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: Create a folder as a package/bundle ...

2009-04-03 Thread I. Savant

On Apr 3, 2009, at 6:25 AM, Mic Pringle wrote:


How would one go about creating a folder that would appear to the
finder as a bundle/package ?


  Have you searched the archives? The documentation? Google, perhaps?  
While no longer a *frequently* asked question, it's been asked  
countless times and there're even some examples on cocoadev.com and  
other places. Please search before posting.


  Getting the appearance is as easy as flipping a switch when you  
declare your document types. Managing reading/writing the package is a  
bit more involved, but cocoadev's example works well. The format has  
to be just so in order for Finder to realize it's a package.


http://www.cocoadev.com/index.pl?SavingFilePackageWithManySmallIndependentFiles

--
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: Create a folder as a package/bundle ...

2009-04-03 Thread Mic Pringle
Hi,

I did do some searching but it came up with nothing relevant. Perhaps
I was searching in the wrong place ?

Thanks for pointing out the example on Cocoa dev. However, it does not
show what I need. You see, in the code that gets the file attributes
to set on the folder, it uses this call ..

NSDictionary *attributes=[self fileAttributesToWriteToFile:newPath
 ofType:docType
 saveOperation:saveType];

However, these is no code listing for fileAttributesToWriteToFile on
the page, and therefore I cannot see which attributes are getting set
?

Thanks

-Mic

2009/4/3 I. Savant idiotsavant2...@gmail.com:
 On Apr 3, 2009, at 6:25 AM, Mic Pringle wrote:

 How would one go about creating a folder that would appear to the
 finder as a bundle/package ?

  Have you searched the archives? The documentation? Google, perhaps? While
 no longer a *frequently* asked question, it's been asked countless times and
 there're even some examples on cocoadev.com and other places. Please search
 before posting.

  Getting the appearance is as easy as flipping a switch when you declare
 your document types. Managing reading/writing the package is a bit more
 involved, but cocoadev's example works well. The format has to be just so in
 order for Finder to realize it's a package.

 http://www.cocoadev.com/index.pl?SavingFilePackageWithManySmallIndependentFiles

 --
 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: Create a folder as a package/bundle ...

2009-04-03 Thread I. Savant

On Apr 3, 2009, at 7:06 AM, Mic Pringle wrote:


I did do some searching but it came up with nothing relevant. Perhaps
I was searching in the wrong place ?


  Google finds everything you need with the terms you provided (when  
including the word Cocoa to narrow the scope), if you take the time  
to look through the results. That's how I found them.




Thanks for pointing out the example on Cocoa dev. However, it does not
show what I need.


  Yes it does. You just have to take the time to research thoroughly  
so that you understand it. You can't just give up when the first  
results you find aren't a complete, drop-in solution. Don't understand  
a method? Then search for it. It's probably documented somewhere.




You see, in the code that gets the file attributes
to set on the folder, it uses this call ..

NSDictionary *attributes=[self fileAttributesToWriteToFile:newPath
ofType:docType
saveOperation:saveType];

However, these is no code listing for fileAttributesToWriteToFile on
the page, and therefore I cannot see which attributes are getting set
?



  Like this right here.

  The method you asked about is EASILY found by searching the  
documentation. You'll learn that it's an NSDocument method which was  
deprecated in 10.4, and that - 
fileAttributesToWriteToURL:ofType:forSaveOperation:originalContentsURL:error 
: is its replacement.


  Following the handy link takes you straight to a nice method  
definition, complete with Discussion section that directly answers  
your question in the first several paragraphs, with references to more  
options.


  Another term you should search for is cross-referencing. Applying  
it will help you immensely in software development.


--
I.S.



On Apr 3, 2009, at 7:06 AM, Mic Pringle wrote:


Hi,

I did do some searching but it came up with nothing relevant. Perhaps
I was searching in the wrong place ?

Thanks for pointing out the example on Cocoa dev. However, it does not
show what I need. You see, in the code that gets the file attributes
to set on the folder, it uses this call ..

NSDictionary *attributes=[self fileAttributesToWriteToFile:newPath
ofType:docType
saveOperation:saveType];

However, these is no code listing for fileAttributesToWriteToFile on
the page, and therefore I cannot see which attributes are getting set
?

Thanks

-Mic

2009/4/3 I. Savant idiotsavant2...@gmail.com:

On Apr 3, 2009, at 6:25 AM, Mic Pringle wrote:


How would one go about creating a folder that would appear to the
finder as a bundle/package ?


 Have you searched the archives? The documentation? Google,  
perhaps? While
no longer a *frequently* asked question, it's been asked countless  
times and
there're even some examples on cocoadev.com and other places.  
Please search

before posting.

 Getting the appearance is as easy as flipping a switch when you  
declare
your document types. Managing reading/writing the package is a bit  
more
involved, but cocoadev's example works well. The format has to be  
just so in

order for Finder to realize it's a package.

http://www.cocoadev.com/index.pl?SavingFilePackageWithManySmallIndependentFiles

--
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: Best Strategy to Control iTunes

2009-04-03 Thread has


On Apr 1, 2009, at 8:15 PM, Ammar Ibrahim wrote:

I'm afraid I'm new and don't quite understand, do you recommend I  
use appscript?


I'm biased, of course, but yeah, it's probably the best choice. It's  
more powerful and reliable than Scripting Bridge, can be used in  
background threads so won't block your GUI on lengthy operations, and  
avoids the extra complexity of using a sub-process if you need to pass  
non-trivial data.




If so, what's the difference between the following methods:

1- NSAppleScript


Runs AppleScript code within your process.

Pros:

- Nothing speaks Apple events better than AppleScript.

Cons:

- It can only be used on your main thread, so will block your GUI on  
lengthy operations.


- While AppleScript itself is very fast at sending events, if you have  
to invoke it repeatedly then you will pay a performance penalty due to  
the overheads of calling into it.


- If you have to pass complex data between ObjC and AppleScript,  
you'll probably spend as much time packing and unpacking that than if  
you just called AESendMessage directly with it, unless you use  
something like appscript's AEMCodecs class to do that for you.


Notes:

- Generally recommended only for situations where you need to run user- 
supplied scripts.




2- Cocoa Scripting Bridge


Sends Apple events directly from Objective-C.

Pros:

- Included in Mac OS X 10.5 and later, which is convenient.

Cons:

- Less capable than AppleScript due to the way its API is designed.

- More prone to application compatibility problems for the same reason.

- Obfuscated API doesn't follow good Cocoa design practices (e.g.  
SBElementArray claims to be descended from NSArray, but does not  
behave as one).


Notes:

- SB tries to disguise Apple events - which are basically RPC plus  
first-class queries - to make them look like object-oriented Cocoa.  
This makes it look more familiar - and therefore more attractive - to  
existing ObjC/Cocoa developers.


However, there is significant impedance mismatch between the two  
systems, so this resemblance is only skin-deep. While SB tries to hide  
these differences from the user beneath a thick abstraction layer,  
they tend to leak out whenever a target application does not behave  
exactly according to SB's in-built assumptions.


Thus commands that work perfectly in AppleScript may fail when  
translated to SB, and as SB's internal magic is not publicly  
documented, it is considerably harder to troubleshoot the problem and  
develop workarounds.




3- AppScript


Sends Apple events directly from Objective-C. (Python and Ruby  
versions are also available, and a MacRuby version is under  
development.)


Pros:

- Mature design has been heavily field-tested and refined over the  
last five years, so application compatibility is very nearly on par  
with AppleScript and functionality is equal or better (e.g. thread  
support).


- Open-source MIT licensed.

Cons:

- Third-party solution, so you will have to build and include it in  
your application bundle yourself.


- Does not hand-hold you or try to make Apple event IPC appear any  
less difficult or confusing than it actually is. (Whether this is  
really a con, or just refreshing honestly, is a decision left to the  
user.)


- Not quite as polished as the Python and Ruby versions, so you may  
encounter the odd implementation bug, e.g. I've had a report of  
problems in 64-bit processes.


- Single developer - that'd be me - currently up to the neck in work,  
so development and support of unpaid projects such as appscript isn't  
as active as I'd like (although I wouldn't say it was any worse than  
SB support).


Notes:

- Deliberately mimics AppleScript's own behaviours as much as possible  
in order to avoid application compatibility problems (i.e. quirk-for- 
quirk compatibility), so feels quite unlike normal Cocoa APIs. Still  
occasionally runs into compatibility problems, but the design is  
sufficiently open and flexible that workarounds are usually  
straightforward.


- Some knowledge of AppleScript is recommended. (Actually, I would  
strongly recommend some knowledge of AppleScript regardless of what  
platform you use - you will need it in order to understand existing  
example scripts, get help from applescript-users, etc.)


- Make sure you get the ASDictionary and ASTranslate dev tools too.



4- Command line invocation of osascript



Runs AppleScript code within a subprocess.

Pros:

- This avoids the threading problems of calling AppleScript in-process.

Cons:

- It's a traditional command line tool, so you are very limited in  
what you can pass in and out - i.e. UTF8-encoded data.


...

Other options to be aware of:

- OSAKit -- more capable, though undocumented, alternative to  
NSAppleScript


- Carbon OSA -- more capable than OSAKit, but gnarly Classic-style C  
APIs


- AEBuild* functions -- lower level API that constructs Apple events  
via printf-style format strings


- Carbon 

Dismissing the iPhone keyboard

2009-04-03 Thread Development
How do I dismiss the keyboard from a UITextView when the cursor is  
moved out?

___

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

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

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

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


Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread James Montgomerie


On 2 Apr 2009, at 22:33, WT wrote:

25 was just a test. The actual app has 2 interlocking 7x7 grids, so  
the number of image views is actually 98. I should explain that this  
animated laying out of image views happens only once and, from that  
point on, the image views all remain in the same place, though each  
image itself is animated. Here's a screen shot to clarify things:


grid.png


Presuming that this is full-size, It is uncommon to have views that  
are so small (the balls must be, what, 4X4 pixels or something?), I'd  
say.  Intuitively, it 'looks' to me like the 'normal' architecture for  
something like this would be to have one custom view for the entire  
grid (of course, there are always exceptions, and I don't know the  
full background of your app).


The balls pulsate, growing and shrinking in size, an effect that I  
accomplish using UIImageView's -startAnimating, but the animation I  
was referring to in my previous posts has to do with adding each  
image view to its proper place.


My question boils down to this: if I am going to use -startAnimating  
for the pulsation, then each ball *has* to be an instance of  
UIImageView, which requires me to add 98 subviews to the superview  
and the laying out animation is as I described in the 25-image  
example. On the other hand, I could forgo using 98 subviews and do  
everything (one-time animated layout *and* animated pulsation)  
inside the superview's -drawRect. This second option is where I'm  
unsure how to proceed.


The solution I have now (98 subviews) works and is convenient but is  
taxing the device, so I'm looking for a better alternative,  
performance-wise.


If it's taxing the device, then I would recommend creating your own  
view, and compositing the images yourself in drawRect:, as you suggest.


To get your animation, just set a timer at your frame rate and call  
setNeedsDisplay on the view in its callback.  Inside drawRect, you  
could either work out what to display based on the time, or you could  
set some flags in your timer routine setting 'state' for drawrect to  
use before you make the setNeedsDisplay call.


Look at the UIImage's drawInRect and/or drawAtPoint: methods for how  
to draw the images.  There are methods that let you specify alpha and  
blend mode, and the drawInRect method will scale the image to fit the  
rect you specify.


Note that you won't need an UIImage instance for every 'ball' - ones  
that are the same looking can just be drawn by reusing the same  
UIImage instance and drawing it multiple times.


If this is still taxing, you might want to look into using a custom  
OpenGL view to do your rendering (although you might want to run  
through a few OpenGL tutorials first if you've never used OpenGL  
before, I'd say it's quite a different style of API in many ways).


Jamie.

___

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

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

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

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


Re: Dismissing the iPhone keyboard

2009-04-03 Thread Dave DeLong
Have the UITextfield resignFirstResponder.  The keyboard goes away  
when an editable element loses first responder status.


Dave

On Apr 3, 2009, at 6:49 AM, Development wrote:

How do I dismiss the keyboard from a UITextView when the cursor is  
moved out?

___

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

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

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

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


Re: Automatic code generation for C++/Objective C bridge

2009-04-03 Thread Scott Ribe
I don't see the point. I work extensively with Objective-C++ and I don't
think I've ever seen a single situation where wrapping C++ objects in
Objective-C wrappers would have been a good approach.

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


___

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

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

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

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


Re: Dismissing the iPhone keyboard

2009-04-03 Thread Development

I'm using

- (void)textFieldDidEndEditing:(UITextField *)textField
{

[textField resignFirstResponder];
}

and the matching method for the textview

I have set the delegate in IB and yet the note is never sent.

I can't figure out what I'm doing wrong.


On Apr 3, 2009, at 6:24 AM, Dave DeLong wrote:

Have the UITextfield resignFirstResponder.  The keyboard goes away  
when an editable element loses first responder status.


Dave

On Apr 3, 2009, at 6:49 AM, Development wrote:

How do I dismiss the keyboard from a UITextView when the cursor is  
moved out?

___

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

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

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

This email sent to developm...@fornextsoft.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


hung in read$UNIX2003

2009-04-03 Thread Michael Domino

Hi all,

I have a task prepared and launched with the code below, and when it  
returns (in this situation that status code returned from  
terminationStatus is 0), it hangs in availableData, never to return.  
The stack at this point is very deep because of a recursive function  
(see the stack trace below), which might be a factor in this hanging  
problem. Could this be a problem with the stack depth? This code  
functions perfectly most of the time.


messagePipeError = [NSPipe pipe];
messagePipeOutput = [NSPipe pipe];
[task setLaunchPath:@/usr/bin/hdiutil];
[task setArguments:[NSArray 
arrayWithObjects:@info, nil]];
[task setStandardError:messagePipeError];   

[task setStandardOutput:messagePipeOutput]; 

[task launch];
[task waitUntilExit];
status = [task terminationStatus];

			NSData *messageDataError = [[messagePipeError fileHandleForReading]  
availableData];
			messageError = [[[NSString alloc] initWithData:messageDataError  
encoding:NSUTF8StringEncoding] autorelease];


This is the stack:

0 read$UNIX2003
1 NSReadFromFileDescriptor
2 -[NSConcreteFileHandle availableData]
3 MyFunction
.
.
.
221 PThread::run
222 PThread::threadFunction
223 _pthread_body

The code the debugger shows in read$UNIX2003:

+ mov $0xc0003,%eax
+0005 call   0x93d38a14 sysenter_trap
+0010 jae   0x93d5beea read$UNIX2003+26 hung here
+0012 call   0x93d5bee1 read$UNIX2003+17
+0017 pop  %edx
+0018 mov  0xcce61df(%edx),%edx
+0024 jmp  *%edx
+0026 ret

Michael Domino
michael.dom...@identityfinder.com





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Inserting text in UITextView without scrolling animation

2009-04-03 Thread Ignacio Enriquez
Hi
I hope this is the right place for this question.
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.
___

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

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

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

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


Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread WT
Presuming that this is full-size, It is uncommon to have views that  
are so small (the balls must be, what, 4X4 pixels or something?),  
I'd say.


No, no, the smallest ball is 13x13 pixels and the whole picture is  
nearly 320 pixels on each side. I had to shrink the picture to such a  
small size because of the cocoa-dev limitations on the size of  
attachments (25 kb max).


Intuitively, it 'looks' to me like the 'normal' architecture for  
something like this would be to have one custom view for the entire  
grid (of course, there are always exceptions, and I don't know the  
full background of your app).


I do have a custom UIView for the grid, but it doesn't do much for  
now, since I'm currently using the UIImageView instances to do the  
heavy lifting.


If it's taxing the device, then I would recommend creating your own  
view, and compositing the images yourself in drawRect:, as you  
suggest.


That's what I was inclined to do from the start, but I found it easier  
to code the UIImageView solution first, to see how it works out.


To get your animation, just set a timer at your frame rate and call  
setNeedsDisplay on the view in its callback.  Inside drawRect, you  
could either work out what to display based on the time, or you  
could set some flags in your timer routine setting 'state' for  
drawrect to use before you make the setNeedsDisplay call.


Ah, ok. This is the guidance I needed. Thanks!

Look at the UIImage's drawInRect and/or drawAtPoint: methods for how  
to draw the images.  There are methods that let you specify alpha  
and blend mode, and the drawInRect method will scale the image to  
fit the rect you specify.


Yes, I'm familiar with them.

Note that you won't need an UIImage instance for every 'ball' - ones  
that are the same looking can just be drawn by reusing the same  
UIImage instance and drawing it multiple times.


Indeed. In fact, I have a custom class working as a singleton image  
server that hands out cached versions of the necessary images.


If this is still taxing, you might want to look into using a custom  
OpenGL view to do your rendering (although you might want to run  
through a few OpenGL tutorials first if you've never used OpenGL  
before, I'd say it's quite a different style of API in many ways).


I considered openGL as well, but I have no practical experience with  
it and this is not the best time for me to learn it, while I'm trying  
to finish this application.


Thank you for your help.
Wagner
___

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

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

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

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


Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread glenn andreas


I do have a custom UIView for the grid, but it doesn't do much for  
now, since I'm currently using the UIImageView instances to do the  
heavy lifting.




You are aware that you can pass an array of UIImages to a UIView and  
it will animate them at whatever speed you tell it, right?  It's not  
perfect (it's hard to sync between multiple views unless you set them  
all at once), but handles simple things fine.  I've made an animated  
GIF viewer widget using this and it works quite well...



Glenn Andreas  gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
quadrium | flame : flame fractals  strange attractors : build,  
mutate, evolve, animate




___

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

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

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

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


Re: Dismissing the iPhone keyboard

2009-04-03 Thread Eric E. Dolecki
You have that method hooked to the UITextField's DidEndOnExit?
E.

On Fri, Apr 3, 2009 at 9:30 AM, Development developm...@fornextsoft.comwrote:

 I'm using

 - (void)textFieldDidEndEditing:(UITextField *)textField
 {

[textField resignFirstResponder];
 }

 and the matching method for the textview

 I have set the delegate in IB and yet the note is never sent.

 I can't figure out what I'm doing wrong.



 On Apr 3, 2009, at 6:24 AM, Dave DeLong wrote:

  Have the UITextfield resignFirstResponder.  The keyboard goes away when an
 editable element loses first responder status.

 Dave

 On Apr 3, 2009, at 6:49 AM, Development wrote:

  How do I dismiss the keyboard from a UITextView when the cursor is moved
 out?

 ___

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

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

 Help/Unsubscribe/Update your Subscription:

 http://lists.apple.com/mailman/options/cocoa-dev/development%40fornextsoft.com

 This email sent to developm...@fornextsoft.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/edolecki%40gmail.com

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




-- 
http://ericd.net
Interactive design and development
___

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

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

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

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


Re: Dismissing the iPhone keyboard

2009-04-03 Thread Brian Slick

Do you have:
@interface YourViewController : UIViewController UITextFieldDelegate
 ^
...in your header file?

Oh, just glanced at my own code, and I'm using this when the text  
field gets created:

[textField addTarget:self
action:@selector(textFieldDone:)
forControlEvents:UIControlEventEditingDidEndOnExit];

And this is the method:

- (void)textFieldDone:(id)sender
{
[sender resignFirstResponder];
}

Try that.

Brian

On Apr 3, 2009, at 9:30 AM, Development wrote:


I'm using

- (void)textFieldDidEndEditing:(UITextField *)textField
{

[textField resignFirstResponder];
}

and the matching method for the textview

I have set the delegate in IB and yet the note is never sent.

I can't figure out what I'm doing wrong.


On Apr 3, 2009, at 6:24 AM, Dave DeLong wrote:

Have the UITextfield resignFirstResponder.  The keyboard goes away  
when an editable element loses first responder status.


Dave

On Apr 3, 2009, at 6:49 AM, Development wrote:

How do I dismiss the keyboard from a UITextView when the cursor is  
moved out?

___

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

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

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

This email sent to developm...@fornextsoft.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/brianslick%40mac.com

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


[Q] using a custom formatter via IB

2009-04-03 Thread Jon C. Munson II
Namaste!

I've got a custom formatter for limiting text input to a certain-length
string.  I did this because the default delayed message of attribute is
too long isn't exactly a good way to keep our users from shooting
themselves in the foot (though I AM glad it is there).  Also, writing
validation methods for each and every attribute that could have a length
issue seems ridiculous too.

I'd like to instantiate this formatter in IB and connect it via rubber
bands to the formatter outlet for each affected text field.  This to avoid
lots of coding otherwise.

However, each affected text field may have a different allowable length.

So, to facilitate that (and not create a formatter for each desired length),
the formatter has a settable property to determine the correct length.
Right now, this is all done through code (IBOutlets to each field,
setFormatter, etc.).

My original thought was to hopefully instantiate the formatter via an IB
Object (the blue cube).  However, the property isn't exposed (I suspected it
wouldn't be).

My overall question is:  How do I expose that property in IB? 

To create this formatter for use in IB, should I go the route of a plug-in?
I do have several apps in which this could be useful, and the answer to the
other two questions are no as well.  I started looking into that.

-OR-

Is it possible to simply instantiate the object with a settable property?
And where may I find documentation that describes the particular process of
exposing the property so IB can see it (if other than creating a plug-in)
and thus allowing setting?

As a side note, has anyone requested of Apple that some sort of min or
maxLength properties be made available?  That would be a really good default
property to have on any sort of text field!

Thanks in advance!

Peace, Love, and Light,

/s/ Jon C. Munson II



___

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

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

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

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


Re: [Q] using a custom formatter via IB

2009-04-03 Thread I. Savant
On Fri, Apr 3, 2009 at 10:43 AM, Jon C. Munson II jmun...@his.com wrote:
 To create this formatter for use in IB, should I go the route of a plug-in?

  Yes. If you want to be able to set this at design time, you should
create an IB plugin containing this formatter.


 Is it possible to simply instantiate the object with a settable property?

  No. IB has to know what UI to display to allow you to manipulate the
instantiated object. Thus, a plugin is required.


 And where may I find documentation that describes the particular process of
 exposing the property so IB can see it (if other than creating a plug-in)
 and thus allowing setting?

http://developer.apple.com/documentation/developertools/Conceptual/IBPlugInGuide/Introduction/Introduction.html


 As a side note, has anyone requested of Apple that some sort of min or
 maxLength properties be made available?  That would be a really good default
 property to have on any sort of text field!

  If they did, they've done so via http://bugreporter.apple.com ...
which is what you should do as well.

--
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: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread WT
I do have a custom UIView for the grid, but it doesn't do much for  
now, since I'm currently using the UIImageView instances to do the  
heavy lifting.




You are aware that you can pass an array of UIImages to a UIView and  
it will animate them at whatever speed you tell it, right?  It's not  
perfect (it's hard to sync between multiple views unless you set  
them all at once), but handles simple things fine.  I've made an  
animated GIF viewer widget using this and it works quite well...


Yes, I am aware of that. That's how I am doing things right now. I  
have 98 UIImageView instances, each associated with an array of up to  
9 UIImage objects. I think it's *very* convenient. I set the pulsating  
animation on each UIImageView and I don't have to worry about it. My  
original question is one of efficiency, given how many UIImageViews I  
have as active subviews at any one time.


___

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

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

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

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


RE: [Q] using a custom formatter via IB

2009-04-03 Thread Jon C. Munson II
 
 On Fri, Apr 3, 2009 at 10:43 AM, Jon C. Munson II jmun...@his.com wrote:
  To create this formatter for use in IB, should I go the route of a plug-
 in?
 
   Yes. If you want to be able to set this at design time, you should
 create an IB plugin containing this formatter.


[Jon C. Munson II] OK, that's what I figured.  I'm looking into that now.
 
 
  Is it possible to simply instantiate the object with a settable
 property?
 
   No. IB has to know what UI to display to allow you to manipulate the
 instantiated object. Thus, a plugin is required.
 


[Jon C. Munson II] Also figured that too, so thank you for the confirmation.
 
  And where may I find documentation that describes the particular process
 of
  exposing the property so IB can see it (if other than creating a plug-
 in)
  and thus allowing setting?
 
 http://developer.apple.com/documentation/developertools/Conceptual/IBPlugI
 nGuide/Introduction/Introduction.html
 
 
[Jon C. Munson II] Already reading that one. :)

  As a side note, has anyone requested of Apple that some sort of min or
  maxLength properties be made available?  That would be a really good
 default
  property to have on any sort of text field!
 
   If they did, they've done so via http://bugreporter.apple.com ...
 which is what you should do as well.
 

[Jon C. Munson II] Done.  The number is:  6754683

 --
 I.S.
[Jon C. Munson II] 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: Dragging around an NSImageView

2009-04-03 Thread Randall Meadows

On Apr 3, 2009, at 4:14 AM, Aaron Scott wrote:

I'm trying to figure out how to be able to drag an NSImageView  
around. The NSImageView has been added as a subview to another  
NSImageView.


Basically, I'm trying to drag a grey box around over the top of a  
picture. I can programmatically move it around but I can't seem to  
find the right code to allow me to drag it around.


You don't actually drag a *view*, you drag an image.  Pedantic,  
perhaps, but important.


When you start a drag, you specify the image that will be dragged.   
See NSView's -dragImage:at:offset:event:pasteboard:source:slideBack:,  
as well as Dragging Sources in the Drag and Drop Programming Topics  
for Cocoa reference.

___

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

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

Help/Unsubscribe/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-03 Thread Michael Ash
On Fri, Apr 3, 2009 at 2:08 AM, Marcel Weiher marcel.wei...@gmail.com wrote:
 What I am saying above
 is that it is possible to distinguish between a custom NSArray
 subclass and a subclass provided by the system. These are not the same
 thing.

 How are they not the same thing?  If you say NSArray, what do you mean?
  Do you mean the NSArray class itself?  In that case, this is all pointless,
 because you are hardly going to get actual NSArray instances, it being an
 abstract superclass and all.

Of *course* I mean NSArray itself. What did you *think* I meant?
Whenever I say NSArray I mean, hello, NSArray.

And it is *not* pointless. Every instance of a subclass of NSArray is
also an instance of NSArray. This is *basic* object-oriented
programming concepts here.

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: Create a folder as a package/bundle ...

2009-04-03 Thread I. Savant
On Fri, Apr 3, 2009 at 12:00 PM, Sean McBride s...@rogue-research.com wrote:

 One thing you should do is set the bundle bit of your folder.  You can
 use the MoreFilesX sample code, and call:

  FSChangeFinderFlags (theFsRef, true, kHasBundle);

  I don't think this will work on its own, but I could be wrong. Can
you verify this?

--
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: hung in read$UNIX2003

2009-04-03 Thread Michael Ash
On Fri, Apr 3, 2009 at 9:36 AM, Michael Domino
michael.dom...@identityfinder.com wrote:
 Hi all,

 I have a task prepared and launched with the code below, and when it returns
 (in this situation that status code returned from terminationStatus is 0),
 it hangs in availableData, never to return. The stack at this point is very
 deep because of a recursive function (see the stack trace below), which
 might be a factor in this hanging problem. Could this be a problem with the
 stack depth? This code functions perfectly most of the time.

                                messagePipeError = [NSPipe pipe];
                                messagePipeOutput = [NSPipe pipe];
                                [task setLaunchPath:@/usr/bin/hdiutil];
                                [task setArguments:[NSArray
 arrayWithObjects:@info, nil]];
                                [task setStandardError:messagePipeError];

                                [task setStandardOutput:messagePipeOutput];

                                [task launch];
                                [task waitUntilExit];
                                status = [task terminationStatus];

                        NSData *messageDataError = [[messagePipeError
 fileHandleForReading] availableData];
                        messageError = [[[NSString alloc]
 initWithData:messageDataError encoding:NSUTF8StringEncoding] autorelease];

I don't know if this is the cause of your problem or not, but never,
ever do this. Don't call waitUntilExit before you read. Pipes have a
small buffer (4kB?) and if it fills up then further writes will block.
This means that if you do a waitUntilExit while the subprocess is
writing more data than the pipe can buffer, you'll deadlock. The
subprocess will be waiting for you to read data before it can
continue, and you will be waiting for it to exit before you read data.
Read all data (using readDataToEndOfFile or equivalent) *before* you
do waitUntilExit.

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: Create a folder as a package/bundle ...

2009-04-03 Thread Sean McBride
On 4/3/09 12:07 PM, I. Savant said:

 One thing you should do is set the bundle bit of your folder.  You can
 use the MoreFilesX sample code, and call:

  FSChangeFinderFlags (theFsRef, true, kHasBundle);

  I don't think this will work on its own, but I could be wrong. Can
you verify this?

It works.  Every app that creates packages should set the bundle bit on
all packages, always.  Few do.  If you don't set the bundle bit and the
application is not on any of your disks, the Finder will show a folder.

Ever install a fresh system (with no Xcode) and navigate to a folder
with an .xcodeproj?  It will appear as a folder because Xcode doesn't
set the bundle bit.

--

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


___

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

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

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

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


Re: Create a folder as a package/bundle ...

2009-04-03 Thread I. Savant
On Fri, Apr 3, 2009 at 12:11 PM, Sean McBride s...@rogue-research.com wrote:
 On 4/3/09 12:07 PM, I. Savant said:

 One thing you should do is set the bundle bit of your folder.  You can
 use the MoreFilesX sample code, and call:

  FSChangeFinderFlags (theFsRef, true, kHasBundle);

  I don't think this will work on its own, but I could be wrong. Can
you verify this?

 It works.  Every app that creates packages should set the bundle bit on
 all packages, always.  Few do.  If you don't set the bundle bit and the
 application is not on any of your disks, the Finder will show a folder.

 Ever install a fresh system (with no Xcode) and navigate to a folder
 with an .xcodeproj?  It will appear as a folder because Xcode doesn't
 set the bundle bit.

  Yes, I agree this helps keep the file looking correct when
LaunchServices can't find the matching application (since the
application itself declares the type and declares it as being a
bundle/package), but my point is that I don't believe this on its own
is sufficient, is it? As I understand it, you have to provide the
appropriate bundle structure (Info.plist with a Contents folder, etc.)
so Finder recognizes it and knows what to do.

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


IB Plugin help

2009-04-03 Thread Jon C. Munson II
Namaste!

OK, I've read through the IB plug-in programming guide.  That document
essentially, as an example, discusses a highly simplistic NSButton
derivative that doesn't have any code behind it.

So, I'm a bit stuck.

The object I'd like to make a plug-in of is an NSFormatter subclass.

Is there an example of how to make a plug-in of this type?  Is it possible
to examine either NSDateFormatter or NSNumberFormatter to see how that was
done?  If so, where may I find them?

Thanks! 

Peace, Love, and Light,

/s/ Jon C. Munson II



___

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

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

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

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


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

2009-04-03 Thread Ashley Clark

On Apr 2, 2009, at 10:57 PM, Huibert Aalbers wrote:


Hi everyone,

I am writing an application that offers support for Undo/Redo.  
Everything works fine, except for a small detail that bothers me.


Since I set the document edited flag manually, using the [theWindow  
setDocumentEdited:YES] instruction each time the document is  
modified, I have no way to remove the flag when a user undoes all  
the changes.


The solution would be to set the document edited flag based on the  
status of the Undo menu item state. Is there a simple way to do this?


Register an observer on your undo manager's  
NSUndoManagerDidUndoChangeNotification and  
NSUndoManagerDidRedoChangeNotification and set your dirty flag there.


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.



Ashley
___

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

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

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

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


Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread glenn andreas


On Apr 3, 2009, at 10:15 AM, WT wrote:

I do have a custom UIView for the grid, but it doesn't do much for  
now, since I'm currently using the UIImageView instances to do the  
heavy lifting.




You are aware that you can pass an array of UIImages to a UIView  
and it will animate them at whatever speed you tell it, right?   
It's not perfect (it's hard to sync between multiple views unless  
you set them all at once), but handles simple things fine.  I've  
made an animated GIF viewer widget using this and it works quite  
well...


Yes, I am aware of that. That's how I am doing things right now. I  
have 98 UIImageView instances, each associated with an array of up  
to 9 UIImage objects. I think it's *very* convenient. I set the  
pulsating animation on each UIImageView and I don't have to worry  
about it. My original question is one of efficiency, given how many  
UIImageViews I have as active subviews at any one time.





You are going to, in general, be hard pressed to get more efficient  
than UIImageView.  If there were a faster way to draw a UIImage on the  
screen, UIImageView would use it (and probably does - it has access to  
internal private API caching/drawing details that you don't).   
Remember  that the built  in view classes are designed to be as  
efficient as practical (for example, the docs say that it is more  
efficient to embed a UILabel subview than to use the built in string  
drawing routines)


So it comes down to can you draw a grid of images faster than a grid  
of UIImageViews.  Obviously the move the bits around drawing part  
isn't going to be faster, so is the question becomes one of the  
overhead of having a boatload of views drawing vs your single view  
drawing.  It seems like the answer should be probably, but you're  
going to have to use the performance tools to make sure - it may turn  
out that what you gain in by having the single view is lost by loosing  
the knows private APIs speed.


(There may be other constraints, such as the synchronization of the  
animation,  that may preclude using the grid of UIImageViews)


There are, however, two techniques that can be taken.  The first (and  
easiest) is to switch to using CALayers directly (UIViews are built  
on top of CALayers).  Make your view a grid of CALayers (which each  
CALayer has an individual image).  This obviously involves going a bit  
deeper than just using UIImageViews, but  it's not too bad.  If you  
want to get more efficiency without major changes (at the cost of  
loosing some of the capabilities that come with having separate views,  
such as more complicated hit testing, having to do your own animation,  
etc...), this is probably your best bet.


The other (and this will give you the most efficiency) is to switch  
over to OpenGL, but obviously this is hard retrofit into an existing  
app (not to mention requires being up to speed with OpenGL).


And no matter what, run Shark to see where any performance bottlenecks  
actually are! (They may be in code you have no control over)


Glenn Andreas  gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
quadrium | prime : build, mutate, evolve, animate : the next  
generation of fractal art




___

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

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

Help/Unsubscribe/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-03 Thread Bill Bumgarner

On Apr 3, 2009, at 12:22 AM, 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.


Ruby/Python did not change the language compilers;   they both work  
entirely via the public APIs of both the interpreted language's  
runtime and the Objective-C runtime's API.


Hence the motivation for my question;   it is possible to do, but it  
sounds like there may be a limitation in the Pascal compiler you are  
using.



Thanks for your ideas.


Sure -- it is an interesting idea and I'm all for more languages being  
bridged to Objective-C as long as the bridge authors promise to file  
bugs along the way. ;)


RubyCocoa, PyObjC, and a number of other bridges are all proofs  
that -- for said languages -- having indirect proxies in the  
targeted language is not necessary.   For PyObjC and RubyCocoa (now  
MacRuby), the array classes are rendered in a compatible fashion  
between the languages.
I bet those languages do something similar to what I am, that is  
make a native Ruby class and within one of it's instance variables  
store the Objective-C object, which is dereferences when passing the  
Ruby object to Cocoa methods. The difference is I'm sure they added  
runtime support to know if a generic pointer is a Ruby class or  
otherwise so they can make safe choices at runtime.


They do that for the various classes that are, more or less, primitive  
types within the runtime environment.  Specifically, NSString,  
NSArray, NSDictionary and NSSet (amongst others) are subclasses with  
Ruby/Python native versions that can, because of class cluster  
behavior, transparently pass across the bridge in either direction.


In this case, it very much is proxying.  However, there is no notion  
of needing to grab the handle to the foreign instance when passing the  
object back across the bridge.


Instead, the bridge itself takes care of grabbing the native type out  
of the object.


A similar mechanism is used for subclassing.   However, the subclasses  
truly are subclasses from their Objective-C parent classes and, thus,  
the subclasses are perfectly viable on the Objective-C side of the  
bridge, too.



That is, if via PyObjC, you pass a Python array to an Objective-C  
method as a parameter, it is received as a subclass of NSArray that  
just works.  Similarly, any random NSArray instance passed from  
Objective-C into Python shows up as a python array object.


Now, maybe there is some particular design point of the Pascal  
variant that you are targeting that prevents this.
Simply, if I attempt to dereference a pointer that is in fact a  
CoreFoundation type it will crash. I need to know if it's a CFType,  
and if not dereferencing is safe. Knowing if it was a Pascal object  
would be just as good, but I don't have that option.


Alternatively, can you simply pass the Pascal object into whatever  
mechanism takes care of the dispatch between Pascal and Objective-C,  
have that mechanism detect that it received a Pascal object, and  
dereference before passing along?   This is, more or less, what the  
Python/Ruby bridges do, with an additional bit of goop to ensure that  
object identity is preserved -- that if A is passed from Python to  
Objective-C and, later, Objective-C calls back into Python with A, it  
is the same A as before (important for Strings and the like).


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: Dismissing the iPhone keyboard

2009-04-03 Thread Development
Thanks for the responses I see now that i had not hooked the end on  
exit method.



On Apr 3, 2009, at 5:49 AM, Development wrote:

How do I dismiss the keyboard from a UITextView when the cursor is  
moved out?

___

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

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

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

This email sent to developm...@fornextsoft.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: Create a folder as a package/bundle ...

2009-04-03 Thread Sean McBride
On 4/3/09 12:15 PM, I. Savant said:

  Yes, I agree this helps keep the file looking correct when
LaunchServices can't find the matching application (since the
application itself declares the type and declares it as being a
bundle/package), but my point is that I don't believe this on its own
is sufficient, is it? As I understand it, you have to provide the
appropriate bundle structure (Info.plist with a Contents folder, etc.)
so Finder recognizes it and knows what to do.

It's sufficient.  Try this:

$ cd ~
$ mkdir package
$ SetFile -a B package

--

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


___

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

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

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

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


Re: Create a folder as a package/bundle ...

2009-04-03 Thread I. Savant
On Fri, Apr 3, 2009 at 2:13 PM, Sean McBride s...@rogue-research.com wrote:

 It's sufficient.  Try this:

 $ cd ~
 $ mkdir package
 $ SetFile -a B package

  Well I'll be damned. :-)

  This would've been *really* handy to know a few years ago when I
built an application using a package-based documents. So it appears
there's no need to use the file wrapper methods after all and the
standard NSDocument file opening methods will handle this just fine,
or am I mistaken?

--
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: Dismissing the iPhone keyboard

2009-04-03 Thread Bertil Holmberg
I think you are using this in the wrong order; This method  
[textFieldDidEndEditing:] is called after the text field resigns its  
first responder status.


How do you move the cursor outside the text field?

Dave Mark handles this in his excellent book by using an invisible  
background view that accepts touches and sends the resignFirstResponder.


You may also want to implement the [optional] textFieldShouldReturn:  
to handle touches in the Done button. Like this:


// Asked when the delegate should process the Return/Done button
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == self.titleField) {
// Remove the keyboard and save the new/modified text
[self.titleField resignFirstResponder];
[self saveAction:self];
}
return YES;
}


- (void)textFieldDidEndEditing:(UITextField *)textField
{

[textField resignFirstResponder];
}

and the matching method for the textview

I have set the delegate in IB and yet the note is never sent.

I can't figure out what I'm doing wrong.


___

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

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

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

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


Re: hung in read$UNIX2003

2009-04-03 Thread Ken Thomases

On Apr 3, 2009, at 11:10 AM, Michael Ash wrote:


On Fri, Apr 3, 2009 at 9:36 AM, Michael Domino
michael.dom...@identityfinder.com wrote:

I have a task prepared and launched with the code below, and when  
it returns
(in this situation that status code returned from terminationStatus  
is 0),

it hangs in availableData, never to return. [...]

   messagePipeError = [NSPipe pipe];
   messagePipeOutput = [NSPipe pipe];
   [task setLaunchPath:@/usr/bin/ 
hdiutil];

   [task setArguments:[NSArray
arrayWithObjects:@info, nil]];
   [task  
setStandardError:messagePipeError];


   [task  
setStandardOutput:messagePipeOutput];


   [task launch];
   [task waitUntilExit];
   status = [task terminationStatus];

   NSData *messageDataError = [[messagePipeError
fileHandleForReading] availableData];
   messageError = [[[NSString alloc]
initWithData:messageDataError encoding:NSUTF8StringEncoding]  
autorelease];


I don't know if this is the cause of your problem or not, but never,
ever do this. Don't call waitUntilExit before you read. Pipes have a
small buffer (4kB?) and if it fills up then further writes will block.
This means that if you do a waitUntilExit while the subprocess is
writing more data than the pipe can buffer, you'll deadlock. The
subprocess will be waiting for you to read data before it can
continue, and you will be waiting for it to exit before you read data.
Read all data (using readDataToEndOfFile or equivalent) *before* you
do waitUntilExit.


And, since you have two pipes, you're going to have to read from both  
simultaneously.  Otherwise, you still have a chance for deadlock, if  
you're blocking reading on one handle while the subprocess is blocking  
waiting for the other pipe to be drained.


This is best done using the asynchronous methods of NSFileHandle.

Cheers,
Ken

___

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

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

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

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


RE: IB Plugin help

2009-04-03 Thread Jon C. Munson II
Namaste!

I've muddled along as far as I can go and I need further assistance.

Here's what I've done so far:

1.  Created a plug-in project.
2.  Edited the class description file to contain two entries, my plug-in
class and the superclass of NSFormatter (I was able to find and looked at
the same file for both NSDateFormatter and NSNumberFormatter).
3.  changed the ...View default .h and .m files to ...Formatter .h and .m,
and updated any other files pointing at same.  Also set the base class to
NSFormatter from NSView (which was the default template value).
4.  Edited the library nib - removed the Example button, button view, label
 line for such, leaving the template view stuff up top.  Dropped an
ImageWell on the template view and pointed that to a custom icon.  Added an
object and set that to my ...Formatter class.  Bound the representedObject
of the view (containing the ImageWell) to that object.
5.  Edited the inspector nib - removed everything but the first label and
text field, changing the label to read Length.  Set the Value binding of
the text field to inspectedObjectsController.selection.length.
6.  Edited the ...Integration file, replacing the comments with my length (
@Length ) property.

Compiled and ran the plug-in.

IB pops up and the library displays an entry for my plug-in.  However, I get
a disclosure triangle (no objects show below), that leads to My Company (a
book), and then to Objects (another book).

What am I missing???

Thanks!

Peace, Love, and Light,

/s/ Jon C. Munson II



___

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

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

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

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


Best Practice for reading a string with NSScanner

2009-04-03 Thread Gustavo Pizano
Hello, this is another post form a previous one that I was able to  
solve, but this one has to be more with a efficient method to achieve  
the following goal.


I have a text file, which contains bunch  of lines like this ones :  
(sorry about the identation)
apphelp.dll5.1.2600.5512
Application Compatibility Client Library
appmgmts.dll   5.1.2600.5512   Software  
installation Service
appmgr.dll 5.1.2600.5512   Software  
Installation Snapin Extenstion
asferror.dll   11.0.5721.5145  Definice  
chyb ASF

asycfilt.dll   5.1.2600.5512
ati2cqag.dll   6.14.10.233 Central  
Memory Manager / Queue Server Module
ati2dvaa.dll   6.13.10.5019ATI RAGE  
128 WindowsNT Display Driver

   divxwmpexttype.dll   


So I was doing scanning  the string (which came from the file) reading  
the library name and saving the result into productName, then the  
version and then the description,  then Im reading an empty string to   
put the scanner on the next line,


[theScanner scanUpToString:@intoString:productName];
[theScanner scanString:@ intoString:NULL];
[theScanner scanUpToString:@   intoString:version];
[theScanner scanString:@ intoString:NULL];
[theScanner scanUpToString:@   intoString:des];
[theScanner scanString:@ intoString:NULL];

All the above in a while loop.
BUT!, here is where it got weird for me. the file is not consistent on  
each road, as you can see the line that contains the asycfilt.dll  has  
a version, but has no  description, so when running the loop, after it  
successfully scan the previous road,  start scanning this particular  
line, gets the library name, then the version, and in the status will  
get the next library name, which its wrong, also it will happen  
something similar  with the last library name, which contains no  
version and no description, in this case in version will put the next  
library name(which is in the next line, I didn't put it), and the  
description will be the version of the last library name.


I have tried many things, but no success, I have getting the  
NScharacterset for a line break, and try to read until there, but its  
always doing the same thing, i guess im not using it properly. , I  
have tried putting some conditionals to see what I have just scanned,  
but as you can see all data its different from each other.


The last hope I have is to compare the next scanned value to see if  
the string I have just scanned has a suffix of .dll in that case I  
know Im in the next line, but im sure there should be some workaround  
different than this one.



Any help I will really appreciate it.

Thanks a lot

Gustavo






___

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

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

Help/Unsubscribe/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-03 Thread Michael Ash
On Fri, Apr 3, 2009 at 12:15 PM, Marcel Weiher marcel.wei...@gmail.com wrote:

 On Apr 3, 2009, at 9:06 , Michael Ash wrote:

 Of *course* I mean NSArray itself. What did you *think* I meant?
 Whenever I say NSArray I mean, hello, NSArray.

 That's what I thought, thanks for clarifying!  I was getting worried there
 for a bit...

 And it is *not* pointless. Every instance of a subclass of NSArray is
 also an instance of NSArray. This is *basic* object-oriented
 programming concepts here.

 Yes, that was exactly what I was saying:
 If you by NSArray you mean every instance of a subclass of NSArray, then
 NSArray = CFArray is simply false, and it is trivial to distinguish NSArrays
 from CFArrays in the general case both at compile time and at runtime, as
 the code I posted here shows conclusively.

What I'm saying is that NSArray == CFArray, based on behavior. Thus it
is impossible to distinguish them, and nonsensical to want to.

As far as I can tell, what you're saying is that NSCFArray == CFArray.
In which case it is *still* impossible to distinguish an NSArray from
a CFArray, and still nonsensical to want to.

But clearly that is not correct, since you keep saying that it is
trivial to distinguish them. So, please fill out the following
function:

NSString *IsNSOrCFArray(id foo) // returns @NSArray or @CFArray
{

}

And also please indicate what this function should return for
IsNSOrCFArray([NSArray array]).

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: Linking the document edited flag to the Undo menu item state

2009-04-03 Thread Huibert Aalbers

Ashley,

Thanks for your advice. I think you are right, I have implemented  
Graham's recommendation but even though undo/redo works fine, as you  
mention, there seems to be no effect on the window's dirty state.


Regards,

Huibert


On 03/04/2009, at 10:22 a.m., Ashley Clark wrote:


On Apr 2, 2009, at 10:57 PM, Huibert Aalbers wrote:


Hi everyone,

I am writing an application that offers support for Undo/Redo.  
Everything works fine, except for a small detail that bothers me.


Since I set the document edited flag manually, using the [theWindow  
setDocumentEdited:YES] instruction each time the document is  
modified, I have no way to remove the flag when a user undoes all  
the changes.


The solution would be to set the document edited flag based on the  
status of the Undo menu item state. Is there a simple way to do this?


Register an observer on your undo manager's  
NSUndoManagerDidUndoChangeNotification and  
NSUndoManagerDidRedoChangeNotification and set your dirty flag there.


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.



Ashley


___

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

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

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

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


best practice for dealing with saving/loading preferences.

2009-04-03 Thread Memo Akten
I have an iphone app that runs at 60fps. I have all of my settings  
(about 10-15) stored in an NSMutableDictionary. When changes are made  
from the UI, the relevant NSNumber in the dictionary is updated. My  
update loop (which runs at 60fps) reads the settings directly from the  
dictionary (once per frame).


I now want to save/load these settings as well. I know how to use  
NSUserDefaults so my question isn't a syntax question but more which  
is the preferred mefthod. I see a number of options:


- dont even use NSUserDefaults  but just save the NSMutableDictionary  
directly with writeToFile:atomically:  when the application exits (And  
read at startup)


- write the dictionary to NSUserDefaults as a single entity  
[[NSUserDefaults standardUserDefaults] setObject:settingsDict  
forKey:@MySettings] when application exits (and create mutable copy  
at startup)


- scrap my dictionary, and just use NSUserDefaults. When a setting is  
changed in the UI, immediately [[NSUserDefaults standardUserDefaults]  
setFloat:forKey:], and in the update loop read settings  
[[NSUserDefaults standardUserDefaults] floatForKey:@setting1];



Is there any one of these that is particularly recommended or advised  
against?


Cheers,

Memo.
___

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

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

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

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


Re: user access privileges to plist in /library/preferences

2009-04-03 Thread Memo Akten


On 1 Apr 2009, at 21:55, Greg Guerin wrote:
Do you understand the Posix permissions and ownership concepts, as  
applied to files and dirs?  If not, you need to learn those.


Do you understand the Posix 'umask' concept and its default value?   
Again, you should learn that.


Finally, you will need to provide non-nil attributes to  
createDirectoryAtPath: that specifies all-read, all-write, and all- 
search permissions on the created dir.  If you don't, then the  
directory will not be writable to anyone except its owner (the user  
account that creates it), due to how the default umask value affects  
the created dirs initial permissions.

Thanks, I'll look into it.


Whenever you write the log-file, you may also need to specify all- 
write permissions.  It may depend on how you write the file.
I'm using -[NSDictionary writeToFile:atomically:] so I guess this  
isn't an option. But seeing as this file will not exist unless it was  
created by my app, and neither will the containing folder which I will  
create with full permissions, any file created in this folder will  
inherit the parents permissions?


Cheers,


Memo.
___

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

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

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

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


Reading cab into object

2009-04-03 Thread Mark Bateman

Hi
I have a csv file I want to use as a source for a searchable list

The csv has 16 fields. I have managed to read the csv line by line  
into an array


I'm having difficulty figuring out how to load an instance of an  
object with the single line of the array and initialising each of the  
objects properties with the fields seperated by commas


What am I missing.  Should I load an intermediate array using  
ComponentsSeparatedByString method. Even so how do I then initialize  
the custom object fields


Mark
___

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

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

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

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


Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread David Duncan

On Apr 2, 2009, at 8:11 PM, WT wrote:

25 was just a test. The actual app has 2 interlocking 7x7 grids, so  
the number of image views is actually 98. I should explain that this  
animated laying out of image views happens only once and, from that  
point on, the image views all remain in the same place, though each  
image itself is animated. Here's a screen shot to clarify things:


The balls pulsate, growing and shrinking in size, an effect that I  
accomplish using UIImageView's -startAnimating, but the animation I  
was referring to in my previous posts has to do with adding each  
image view to its proper place.


My question boils down to this: if I am going to use -startAnimating  
for the pulsation, then each ball *has* to be an instance of  
UIImageView, which requires me to add 98 subviews to the superview  
and the laying out animation is as I described in the 25-image  
example. On the other hand, I could forgo using 98 subviews and do  
everything (one-time animated layout *and* animated pulsation)  
inside the superview's -drawRect. This second option is where I'm  
unsure how to proceed.


The solution I have now (98 subviews) works and is convenient but is  
taxing the device, so I'm looking for a better alternative,  
performance-wise.



You may see better performance by borrowing a technique from OpenGL -  
namely by creating a texture atlas. In Core Animation parlance, you do  
this by using a common image for the layer contents and using the  
contentsRect property to select a portion of the image. If the balls  
in your scene always animate at a particular rate and with particular  
parameters, then you can set this up once and forget about it for the  
rest of the scene and Core Animation will update the image for you at  
an appropriate rate.


The first step is to create a texture atlas and note the normalized  
coordinates of each frame (so if you had an image that represented 16  
frames, the first one might be at 0.0, 0.0, the second at 0.25, 0.0,  
etc each with a 0.25x0.25 size). Setup all your layers (or  
UIImageViews if you like) with the same image, and then add a keyframe  
animation to the layer that animates the contentsRect to scrub across  
the frames like this:


CAKeyframeAnimation *animation = [CAKeyframeAnimation  
animationWithKeyPath:@contentsRect];

// Media Timing Parameters
animation.duration = kTimeConst * frameCount; // how long to animate  
each frame for by number of frames

animation.repeatCount = 1e9; // repeat forever
// Keyframe Parameters
animation.values = [NSArray arrayWithObjects:
	[NSValue valueWithCGRect:CGRectMake(0.00, 0.00, 0.25, 0.25)], //  
frame 1
	[NSValue valueWithCGRect:CGRectMake(0.25, 0.00, 0.25, 0.25)], //  
frame 2
	[NSValue valueWithCGRect:CGRectMake(0.50, 0.00, 0.25, 0.25)], //  
frame 3

... // etc
nil];
animation.calculationMode = kCAAnimationDiscrete; // don't interpolate  
values


Then you just add this animation to the layer and your content will  
animate its way through the atlas without you needing to do a thing.

--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


NSString* kMyKey = @aKey vs #define MYKEY @aKey

2009-04-03 Thread Memo Akten

I was wondering if there is much difference between:

NSString* kMyKey = @aKey;

// and then throughout the application:
[myDictionary setObject:xxx forKey:kMyKey];
[myDictionary objectForKey: kMyKey];



vs

#define MYKEY @aKey

// and then throughout the application:
[myDictionary setObject:xxx forKey: MYKEY];
[myDictionary objectForKey: MYKEY];


The docs say the strings created with the @ construct are created at  
compile time. Does that mean potentially if we use the define 50  
times, there are 50 NSStrings with identical content created at  
compile time? Or does the compiler optimize that 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: Best Practice for reading a string with NSScanner

2009-04-03 Thread Quincey Morris

On Apr 3, 2009, at 12:08, Gustavo Pizano wrote:

I have a text file, which contains bunch  of lines like this ones :  
(sorry about the identation)
   apphelp.dll5.1.2600.5512
Application Compatibility Client Library
   appmgmts.dll   5.1.2600.5512   Software  
installation Service
   appmgr.dll 5.1.2600.5512   Software  
Installation Snapin Extenstion
   asferror.dll   11.0.5721.5145  Definice  
chyb ASF

   asycfilt.dll   5.1.2600.5512
   ati2cqag.dll   6.14.10.233 Central  
Memory Manager / Queue Server Module
   ati2dvaa.dll   6.13.10.5019ATI RAGE  
128 WindowsNT Display Driver

  divxwmpexttype.dll


So I was doing scanning  the string (which came from the file)  
reading the library name and saving the result into productName,  
then the version and then the description,  then Im reading an empty  
string to  put the scanner on the next line,


[theScanner scanUpToString:@intoString:productName];
[theScanner scanString:@ intoString:NULL];
[theScanner scanUpToString:@   intoString:version];
[theScanner scanString:@ intoString:NULL];
[theScanner scanUpToString:@   intoString:des];
[theScanner scanString:@ intoString:NULL];

All the above in a while loop.
BUT!, here is where it got weird for me. the file is not consistent  
on each road, as you can see the line that contains the  
asycfilt.dll  has a version, but has no  description, so when  
running the loop, after it successfully scan the previous road,   
start scanning this particular line, gets the library name, then the  
version, and in the status will get the next library name, which its  
wrong, also it will happen something similar  with the last library  
name, which contains no version and no description, in this case in  
version will put the next library name(which is in the next line, I  
didn't put it), and the description will be the version of the last  
library name.


I have tried many things, but no success, I have getting the  
NScharacterset for a line break, and try to read until there, but  
its always doing the same thing, i guess im not using it properly. ,  
I have tried putting some conditionals to see what I have just  
scanned, but as you can see all data its different from each other.


I think the next thing you should try is reading the documentation  
again, in particular the part about 'scanUpToString:intoString:'  
skipping newline characters by default. If you change the default,  
you'll likely stop falling off the ends of the lines.



___

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

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

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

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


Re: Bindings and MenuItems

2009-04-03 Thread Ben Lachman

On Apr 3, 2009, at 6:14 AM, Alexander Spohr wrote:


Am 03.04.2009 um 06:49 schrieb Ben Lachman:

No.  That was what my original message outlined.  Say you have a  
table view selected and hit cmd-p.  NSView has a default  
implementation of print: so it will print the table view.  In my  
case and in many others what you really want to print is the detail  
view or some representation of it that actually shows the currently  
data of the selected object(s).  So no that's not really what the  
first responder is for.


Why not subclassing that table view and overriding print:?


This breaks the MVC paradigm.  You'd have to forward print: to another  
view or better, forward it up to the controller and let the controller  
figure out what to do with it, although I think this kind of breaks  
the validateMenuItem interface.  But you still have the problem that  
many different views can be first responder.  You'd basically have to  
subclass every view that accepts first responder and override print:  
in each.  It would also make code reuse much more cumbersome.  All the  
views for one printing state would have to have a separate subclass  
from the views for the other printing state (this was my original  
issue, how do you manage printing when you have two main detail views  
that you swap between?).


-Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009

___

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

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

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

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


Re: user access privileges to plist in /library/preferences

2009-04-03 Thread Greg Guerin

Memo Akten wrote:

I'm using -[NSDictionary writeToFile:atomically:] so I guess this  
isn't an option. But seeing as this file will not exist unless it  
was created by my app, and neither will the containing folder which  
I will create with full permissions, any file created in this  
folder will inherit the parents permissions?


No, it won't.  Neither files nor dirs inherit permissions from the  
enclosing folder when being created.  That's why it's important that  
you understand what the defaults are, how umask affects them, and  
what the parameters to the function do.  This is covered in the man  
pages or other references.  Please read them.


  -- 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: NSString* kMyKey = @aKey vs #define MYKEY @aKey

2009-04-03 Thread Nate Weaver
IIRC they're optimized to point to the same memory location (I wasn't  
sure, so I tested and confirmed).


I usually do:

NSString * const kConstantNameHere = @foo;

That's what I've seen in Apple headers (with an extern at the  
beginning and no assignment in said headers, of course).


On Apr 3, 2009, at 4:41 PM, Memo Akten wrote:


I was wondering if there is much difference between:

NSString* kMyKey = @aKey;

// and then throughout the application:
[myDictionary setObject:xxx forKey:kMyKey];
[myDictionary objectForKey: kMyKey];



vs

#define MYKEY @aKey

// and then throughout the application:
[myDictionary setObject:xxx forKey: MYKEY];
[myDictionary objectForKey: MYKEY];


The docs say the strings created with the @ construct are created at  
compile time. Does that mean potentially if we use the define 50  
times, there are 50 NSStrings with identical content created at  
compile time? Or does the compiler optimize that 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: NSDate with Format?

2009-04-03 Thread Pierce Freeman
--

NSDateFormatter is your friend.  =)

You use it like this:
NSDateFormatter * f = [[NSDateFormatter alloc] init];
[f setDateFormat:@-mm-dd];
NSLog([f stringFromDate:aDate]);
[f release];

There's also a really handy dateFromString method that will parse a
string according to the format string you specify.

This page has lots of good info on what the formatting specifiers are:
http://unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns

HTH,

Dave

--

@Dave DeLong

Sorry, didn't get your previous message.  I think something may be wrong
with my email account. ;)  In any event, here is my current code:

NSCalendarDate *date = [NSCalendarDate calendarDate];
NSString *dateString = [date descriptionWithCalendarFormat:@%Y-%m%d];

Now I am wondering how I can take that special formatted string and save it
back into NSCalendarDate or NSDate (knowing how it was formatted).  I looked
up some information regarding dateFromString but it returns null when I pass
it my string.  Though I could be doing something wrong regarding
dateFromString.


Thanks for any help.


___

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

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

Help/Unsubscribe/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* kMyKey = @aKey vs #define MYKEY @aKey

2009-04-03 Thread Quincey Morris

On Apr 3, 2009, at 15:15, Nate Weaver wrote:

IIRC they're optimized to point to the same memory location (I  
wasn't sure, so I tested and confirmed).


I usually do:

NSString * const kConstantNameHere = @foo;

That's what I've seen in Apple headers (with an extern at the  
beginning and no assignment in said headers, of course).


Except that the reason for *that* is to have the names of the strings  
in the public API but to keep the content of the strings out of it,  
which is presumably not a consideration for the OP.


I'd choose the #define version, and give the compiler elbow room to do  
its job of optimizing away duplicate literals -- and whatever else it  
can do, such as possibly putting string literals in read-only address  
space.


But the difference (if any) between the two approaches is so minimal  
that personal preference is a fine criterion for deciding. :)



___

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

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

Help/Unsubscribe/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-03 Thread Rich Collyer
My primary interest is to ensure that the content of an  
NSSecureTextField and any times I extract the string from it, the  
memory is not paged out, or cached.


+++
Rich Collyer - Senior Software Engineer
+++

On Apr 2, 2009, at 4:19 PM, Dave Carrigan wrote:



On Apr 2, 2009, at 3:50 PM, Rich Collyer wrote:

Is there a way to mark as application (or at least its heap) as non- 
pageable.



mlock(2) might be what you're looking for, but we would need more  
information on what you are specifically attempting to do.


--
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA





smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: NSString* kMyKey = @aKey vs #define MYKEY @aKey

2009-04-03 Thread Memo Akten
Thanks for the replies guys. I do prefer the #define method simply  
because it's less maintenance (only add to one header, instead of  
header + .m)


Cheers,

Memo.


On 3 Apr 2009, at 23:44, Quincey Morris wrote:


On Apr 3, 2009, at 15:15, Nate Weaver wrote:

IIRC they're optimized to point to the same memory location (I  
wasn't sure, so I tested and confirmed).


I usually do:

NSString * const kConstantNameHere = @foo;

That's what I've seen in Apple headers (with an extern at the  
beginning and no assignment in said headers, of course).


Except that the reason for *that* is to have the names of the  
strings in the public API but to keep the content of the strings out  
of it, which is presumably not a consideration for the OP.


I'd choose the #define version, and give the compiler elbow room to  
do its job of optimizing away duplicate literals -- and whatever  
else it can do, such as possibly putting string literals in read- 
only address space.


But the difference (if any) between the two approaches is so minimal  
that personal preference is a fine criterion for deciding. :)



___

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

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

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

This email sent to m...@memo.tv


___

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

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

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

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


Re: Dragging around an NSImageView

2009-04-03 Thread BJ Homer
On Fri, Apr 3, 2009 at 9:54 AM, Randall Meadows cocoa-...@not-pc.comwrote:

 On Apr 3, 2009, at 4:14 AM, Aaron Scott wrote:

  I'm trying to figure out how to be able to drag an NSImageView around. The
 NSImageView has been added as a subview to another NSImageView.

 Basically, I'm trying to drag a grey box around over the top of a picture.
 I can programmatically move it around but I can't seem to find the right
 code to allow me to drag it around.


 You don't actually drag a *view*, you drag an image.  Pedantic, perhaps,
 but important.

 When you start a drag, you specify the image that will be dragged.  See
 NSView's -dragImage:at:offset:event:pasteboard:source:slideBack:, as well as
 Dragging Sources in the Drag and Drop Programming Topics for Cocoa
 reference.


That's true if you're trying to do drag-and-drop programming, but I don't
think the OP was trying to do that.  I think he's basically trying to change
the frame of a subview.  If that's the case, I think you'll want to look at
the documentation for -[NSResponder mouseDragged].  (Note that NSImageView
is a type of NSResponder.)

-BJ
___

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

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

Help/Unsubscribe/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-03 Thread Clark Cox
On Fri, Apr 3, 2009 at 3:57 PM, Rich Collyer rcoll...@ironkey.com wrote:
 My primary interest is to ensure that the content of an NSSecureTextField
 and any times I extract the string from it, the memory is not paged out, or
 cached.

Then turn on Use Secure Virtual Memory in the Security Pane in
System Preferences.

-- 
Clark S. Cox III
clarkc...@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: NSString* kMyKey = @aKey vs #define MYKEY @aKey

2009-04-03 Thread Nate Weaver
I prefer the other for that exact reason since I don't have to have  
the actual definition in my headers, some of which (for notifications,  
e.g.) are used in a number of places.


From the Apple docs: In general, don’t use the #define preprocessor  
command to create constants. For integer constants, use enumerations,  
and for floating point constants use the const qualifier, as described  
above. and Define constants for strings used for such purposes as  
notification names and dictionary keys. By using string constants, you  
are ensuring that the compiler verifies the proper value is specified  
(that is, it performs spell checking). The Cocoa frameworks provide  
many examples of string constants [...].


(http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html 
)


As for read-only address space, does the const declaration not take  
care of that? (Serious question.)


But, like Quincey said, it really shouldn't matter much!

On Apr 3, 2009, at 6:05 PM, Memo Akten wrote:

Thanks for the replies guys. I do prefer the #define method simply  
because it's less maintenance (only add to one header, instead of  
header + .m)


Cheers,

Memo.


On 3 Apr 2009, at 23:44, Quincey Morris wrote:


On Apr 3, 2009, at 15:15, Nate Weaver wrote:

IIRC they're optimized to point to the same memory location (I  
wasn't sure, so I tested and confirmed).


I usually do:

NSString * const kConstantNameHere = @foo;

That's what I've seen in Apple headers (with an extern at the  
beginning and no assignment in said headers, of course).


Except that the reason for *that* is to have the names of the  
strings in the public API but to keep the content of the strings  
out of it, which is presumably not a consideration for the OP.


I'd choose the #define version, and give the compiler elbow room to  
do its job of optimizing away duplicate literals -- and whatever  
else it can do, such as possibly putting string literals in read- 
only address space.


But the difference (if any) between the two approaches is so  
minimal that personal preference is a fine criterion for deciding. :)

___

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

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

Help/Unsubscribe/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-03 Thread jmunson

Namaste!

Still plugging away at this...

I found one mistake where I didn't change the IBInspector class of  
File's Owner in the Inspector.xib to my Inspector subclass.  Doing  
that gave me an entry in the bottom box of the library, but no object  
in the middle pane...  How do I fix that?  Also, the image isn't  
displaying either.  I'm still getting the book entries under the  
Formatter name.


That being said, I also notice that my Inspector subclass doesn't  
have any sort of reference to my Formatter object.  Is it supposed to?  
 I should think it may need one.  The dox don't really go into that  
so I don't know for certain.  So, do I code it into the .h?  And also  
the .m?


Boy, I wish there was an example to follow...

Thanks!

Peace, Love, and Light,

/s/ Jon C. Munson II

___

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

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

Help/Unsubscribe/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-03 Thread Ricky Sharp


On Apr 3, 2009, at 6:43 PM, jmun...@his.com wrote:

I found one mistake where I didn't change the IBInspector class of  
File's Owner in the Inspector.xib to my Inspector subclass.  Doing  
that gave me an entry in the bottom box of the library, but no  
object in the middle pane...  How do I fix that?  Also, the image  
isn't displaying either.  I'm still getting the book entries under  
the Formatter name.


That being said, I also notice that my Inspector subclass doesn't  
have any sort of reference to my Formatter object.  Is it supposed  
to?  I should think it may need one.  The dox don't really go into  
that so I don't know for certain.  So, do I code it into the .h?   
And also the .m?


Boy, I wish there was an example to follow...



See the following for an example:

http://www.instantinteractive.com/private/samplecode/MyIBPlugin.zip

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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: IB Plugin help

2009-04-03 Thread jmunson

Namaste!

Thank you, that was/is a big help.

I also found BGHUDAppKit which was/is also invaluable help.

Between those two good examples I think I got my plug-in working  
(using it live is what remains to be seen).


I have one more question:  How does one replace the blue cube object  
icon that tags on the text field with my formatter's graphic?


Thanks!

Peace, Love, and Light,

/s/ Jon C. Munson II

Quoting Ricky Sharp rsh...@mac.com:



On Apr 3, 2009, at 6:43 PM, jmun...@his.com wrote:

I found one mistake where I didn't change the IBInspector class of   
File's Owner in the Inspector.xib to my Inspector subclass.
Doing that gave me an entry in the bottom box of the library, but   
no object in the middle pane...  How do I fix that?  Also, the   
image isn't displaying either.  I'm still getting the book   
entries under the Formatter name.


That being said, I also notice that my Inspector subclass doesn't  
 have any sort of reference to my Formatter object.  Is it supposed  
 to? I should think it may need one.  The dox don't really go into   
that so I don't know for certain.  So, do I code it into the .h?
And also the .m?


Boy, I wish there was an example to follow...



See the following for an example:

http://www.instantinteractive.com/private/samplecode/MyIBPlugin.zip

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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


Error: mutating method sent to immutable object

2009-04-03 Thread Priscila J . V .

Hello,
I'm trying to do this:
int p;
NSMutableArray * arregloNumeros = [[NSMutableArray alloc] init];
NSString * fileContents = [NSString 
stringWithContentsOfFile:@lineasFinal.txt];   NSEnumerator * 
lineFileEnumerator = [[fileContents componentsSeparatedByString:@|] 
objectEnumerator]; NSString * enumeratedFileLine;  // Prepare to 
process each line of numbers  NSEnumerator * numberEnumerator;
NSString * numberAsString;  while (enumeratedFileLine = 
[lineFileEnumerator nextObject]){   numberEnumerator = 
[[ enumeratedFileLine componentsSeparatedByString:@,] objectEnumerator];  
 while (numberAsString = [numberEnumerator nextObject]) 
 {   // change string to float  
 float auxFloat = [numberAsString floatValue];  
 [arregloNumeros addObject:[NSString stringWithFormat:@%f, auxFloat]];
 }  
 for (p = 0; p  7; p++) NSLog(@Position %d and 
number %@, p, [arregloNumeros objectAtIndex:p]);
[arregloNumeros release];   }
 But when I run the program in my log window appears the following 
message:
  -[NSCFArray addObject:]: mutating method sent to immutable object
 Does anyone know what is going on? and help me please to fix it.
Thanks in advance.
Priscila
_
Découvrez toutes les possibilités de communication avec vos proches
http://www.microsoft.com/windows/windowslive/default.aspx___

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

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

Help/Unsubscribe/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-03 Thread jmunson

OK, now I have one more question.

I'd like to install and use my plug-in.  However, when accessing  
IB's preferences-Plug-ins and attempting to add the plug-in I get:   
1) when simply adding the ibplugin an error that states the file is  
missing necessary resources and to reinstall the bundle, or 2) when  
opening the framework folder no error but also nothing else either.


What else did I miss

Thanks!

Peace, Love, and Light,

/s/ Jon C. Munson II

Quoting Ricky Sharp rsh...@mac.com:



On Apr 3, 2009, at 6:43 PM, jmun...@his.com wrote:

I found one mistake where I didn't change the IBInspector class of   
File's Owner in the Inspector.xib to my Inspector subclass.
Doing that gave me an entry in the bottom box of the library, but   
no object in the middle pane...  How do I fix that?  Also, the   
image isn't displaying either.  I'm still getting the book   
entries under the Formatter name.


That being said, I also notice that my Inspector subclass doesn't  
 have any sort of reference to my Formatter object.  Is it supposed  
 to? I should think it may need one.  The dox don't really go into   
that so I don't know for certain.  So, do I code it into the .h?
And also the .m?


Boy, I wish there was an example to follow...



See the following for an example:

http://www.instantinteractive.com/private/samplecode/MyIBPlugin.zip

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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


Dragging anything out of a WebView into other Cocoa controls

2009-04-03 Thread Steven Degutis
Hello,
I have been trying to figure out some way of dragging an image, text, link,
anything really, out of a WebView, and into another Cocoa control, such as
NSTextField, NSTableView, or NSImageView. Dragging these things out of my
WebView and into other applications works fine, for example dragging links
or images onto Safari, and text into TextEdit. But dragging into a control
that is in the same application does not work.

I've created and tested a test-case project that shows the bare bones. In
this project, I simply dragged a WebView and TextField into IB, set the
WebView's URL to google.com, ran the app, and tried dragging some text out
of the WebView into the NSTextField, and it snaps back with no option of
Copy or other actions being available.

Ultimately what I'd like to do is drag elements out of the WebView and into
an NSOutlineView, and extract the represented data out of the element.
Looking through the documentation, I've stumbled upon this page:

http://developer.apple.com/DOCUMENTATION/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/DragAndDrop.html

However, this seems to have nothing to do with dragging elements or items
out of the WebView and into other Cocoa controls, but only about dragging
them into other items in the WebView. It's possible that what I'm trying to
do is not possible, but I'm hoping this is not true.

Any help would not only be appreciated, but would be remembered for longer
than a day, and possibly thanked at an upcoming WWDC, maybe even more, who
knows.

~Steven Degutis
___

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

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

Help/Unsubscribe/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-03 Thread Graham Cox


On 04/04/2009, at 12:27 PM, Priscila J.V. wrote:



Hello,
I'm trying to do this:


int p;
NSMutableArray* arregloNumeros = [[NSMutableArray alloc] init];
NSString* 		fileContents = [NSString  
stringWithContentsOfFile:@lineasFinal.txt];
NSEnumerator* 		lineFileEnumerator = [[fileContents  
componentsSeparatedByString:@|] objectEnumerator];
NSString* 		enumeratedFileLine; 	// Prepare to process each line of  
numbers

NSEnumerator *  numberEnumerator;
NSString *  numberAsString;

while (enumeratedFileLine = [lineFileEnumerator nextObject])
{
	numberEnumerator = [[ enumeratedFileLine  
componentsSeparatedByString:@,] objectEnumerator];


while (numberAsString = [numberEnumerator nextObject])
{   // change string to float
float auxFloat = [numberAsString floatValue];
		[arregloNumeros addObject:[NSString stringWithFormat:@%f,  
auxFloat]]; } 		for (p = 0; p  7; p++)	
			NSLog(@Position %d and number %@, p, [arregloNumeros  
objectAtIndex:p]);

[arregloNumeros release];
}


But when I run the program in my log window appears the  
following message:

 -[NSCFArray addObject:]: mutating method sent to immutable object
Does anyone know what is going on? and help me please to fix it.
Thanks in advance.
Priscila



A little formatting goes a long way. Your mail is completely  
unreadable. I've reformatted it above.


There are numerous problems here. arregloNumeros is allocated once  
at the start, but after adding only one object to this list, you try  
and print out the first 7 objects. You should get a message that the  
index is out of range, which will throw an exception that aborts the  
whole thing anyway.


If it made it past that (e.g. if you commented out the logging), you  
then release arregloNumeros which will deallocate it. Then you have  
a stale pointer which points to nothing in particular. When you send - 
addObject to the stale pointer, that probably generates the mutation  
error message you're seeing depending on what random object the stale  
pointer happens to point to.


You need to review the memory management guidelines. 
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html

However, even once you get the above working it will be sorely  
inefficient for what you appear to be trying to do. Also check out  
NSScanner.


Tip: carelessness is a waste of your own time - the best programmers  
are insanely fastidious almost to the point of it being pathological.


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


Very interesting ordering caveat with NSArray arrayWithObjects:

2009-04-03 Thread Eric Hermanson
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];

- 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: Dismissing the iPhone keyboard

2009-04-03 Thread Steve Taylor
textFieldDidEndEditing is only triggered once first responder has been  
resigned by the field.


try something like

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == textField) {
[textField resignFirstResponder];
}
return YES;
}

where textField is you IBOutlet

cheers

steve


On 3 Apr 2009, at 14:30, Development wrote:


textFieldDidEndEditing




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

creating related objects

2009-04-03 Thread David Scheidt
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.

___

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

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

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

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


Re: Example of collapsible disclosure view

2009-04-03 Thread James Huddleston


This might be helpful too: 
http://www.cocoarocket.com/articles/disclosureTriangles.html

-James

On Apr 2, 2009, at 9:57 AM, Robert Mullen wrote:

I am working on a view and window that needs to collapse/expand with  
a disclosure triangle and cause the Window containing it to resize  
as well as the controls that are static to reposition. The effect I  
am after is much like the disclosure triangle in a print dialog. Is  
there an example of how to do this? I have found bits and pieces in  
different places but I am not able to stitch them together correctly  
and am a bit lost. So far I am using a borderless NSBox to contain  
the controls that I want to show and hide. I can hide and unhide  
them easy enough but the collapsing part is working less well. Any  
links or source code would be appreciated.


TIA
___

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

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

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

This email sent to hudd...@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: Automatic code generation for C++/Objective C bridge

2009-04-03 Thread Ashish Sharma
I think there are many situations where this approach is used/ could be
useful, for example, when you have your UI in cocoa and you want to
communicate with the C++ objects. Ofcourse you can mix obj-c and c++ in a
trivial way but that means your application sees both obj-c and C++ types. A
classic example would be an alternative for objective c bindings for
CORBA/SOAP. You can have Objective C wrappers over C++ bindings available
for SOAP/CORBA and use them in your application without your code been aware
of the C++ objects/types.
I don't know if I made my point clear :)

On Fri, Apr 3, 2009 at 8:26 AM, Scott Ribe scott_r...@killerbytes.comwrote:

 I don't see the point. I work extensively with Objective-C++ and I don't
 think I've ever seen a single situation where wrapping C++ objects in
 Objective-C wrappers would have been a good approach.

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



___

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

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

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

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


Screen recorder

2009-04-03 Thread Michaelian Ennis
I need a screen recorder to make some tutorials for using an
application.   The only real requirement is that there be a three
button mouse transparency showing the button presses.  This needs to
support the display of chording ( multiple mouse buttons pressed at
that same time ).   The
nature of the application is such that this really is the only way to
teach it.  Any suggestions?


Ian
___

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

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

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

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


WebKit: Javascript - Cocoa bridge not working

2009-04-03 Thread Marcel Hansemann
In my app, I have a WebView with JavaScript in it that occasionally  
needs to call externally defined Obj-C functions. According to  
documentation, this should be simple by conforming to the WebScripting  
protocol, but I just can't get it to work.


I set up the bridge object like this:

[[webView windowScriptObject] setValue:self forKey:@bridge];

And the class implements both

+ (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { return NO; }
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name { return NO; }
- (void) externalFunction{ /* external code  */};

Now, I load a HTML string like this into the WebView:

input type=button value=Extern  
onclick=bridge.externalFunction() /


and you would expect externalFunction to run when the user clicks the  
button. However, that's just not the case. externalFunction is never  
executed.


[[webView windowScriptObject] valueForKey:@bridge] is self when I  
check from Cocoa. If I check from JavaScript, though, window.bridge is  
undefined.


I'm thoroughly confused. What's more, if I build a new app from  
scratch for testing purposes, the above works just fine. There must be  
some factor in my application that keeps the bridge from working. But  
what could that be?


Any help much appreciated.

___
Marcel Hansemann

___

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

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

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

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


Re: Implementing NSOutlineView autosaveExpandedItems with CoreData

2009-04-03 Thread David Hoerl

[for the archives - old thread]

This is a brute force mechanism to save the expanded NSOutlineView 
items prior to changing a Managed Object context and then restoring 
them after the modification.


- (id)expandedState
{
NSMutableArray *state = [NSMutableArray array];
NSInteger count = [outlineView numberOfRows];
for (NSInteger row = 0; row  count; row++) {
id item = [outlineView itemAtRow:row];
if ([outlineView isItemExpanded:item])
{
[state addObject:[item representedObject] ];
}
}
return state;
}

// brute force solution: for each object, do a full tree search for 
the NSTreeNode item...at least it works!

-(id)recursiveSearch:(id)object set:(NSSet *)set
{
for (id item in set)
{
if ([item representedObject] == object) return item;

NSSet *children = [item valueForKey:@childNodes];

if ([children count]) {
id ret = [self recursiveSearch:object set:children];
if(ret) return ret;
}
}
return nil;
}

- (void)setExpandedState:(id)state
{
// Collapse everything first
[outline collapseItem:nil collapseChildren:YES];

for (id pobj in state) {
[outlineView expandItem:[self recursiveSearch:pobj 
set:[[treeController arrangedObjects] valueForKey:@childNodes]] ];

}
}

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: NSString* kMyKey = @aKey vs #define MYKEY @aKey

2009-04-03 Thread Andrew Farmer

On 03 Apr 09, at 15:15, Nate Weaver wrote:
IIRC they're optimized to point to the same memory location (I  
wasn't sure, so I tested and confirmed).


They'll point to the same object in memory within a single file, but  
multiple modules linked together aren't guaranteed to share string  
constants.

___

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

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

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

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


Re: Dragging anything out of a WebView into other Cocoa controls

2009-04-03 Thread Steven Degutis
[Solved]
Apparently I was using the wrong data source method to validate drops, which
explains why this was not working with my NSOutlineView. Thanks for all the
fish.

- Anonymous

On Fri, Apr 3, 2009 at 8:48 PM, Steven Degutis steven.degu...@gmail.comwrote:

 Hello,
 I have been trying to figure out some way of dragging an image, text, link,
 anything really, out of a WebView, and into another Cocoa control, such as
 NSTextField, NSTableView, or NSImageView. Dragging these things out of my
 WebView and into other applications works fine, for example dragging links
 or images onto Safari, and text into TextEdit. But dragging into a control
 that is in the same application does not work.

 I've created and tested a test-case project that shows the bare bones. In
 this project, I simply dragged a WebView and TextField into IB, set the
 WebView's URL to google.com, ran the app, and tried dragging some text out
 of the WebView into the NSTextField, and it snaps back with no option of
 Copy or other actions being available.

 Ultimately what I'd like to do is drag elements out of the WebView and into
 an NSOutlineView, and extract the represented data out of the element.
 Looking through the documentation, I've stumbled upon this page:


 http://developer.apple.com/DOCUMENTATION/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/DragAndDrop.html

 However, this seems to have nothing to do with dragging elements or items
 out of the WebView and into other Cocoa controls, but only about dragging
 them into other items in the WebView. It's possible that what I'm trying to
 do is not possible, but I'm hoping this is not true.

 Any help would not only be appreciated, but would be remembered for longer
 than a day, and possibly thanked at an upcoming WWDC, maybe even more, who
 knows.

 ~Steven Degutis




-- 
~Steven Degutis
President, Thoughtful Tree Software, Inc.
http://www.ThoughtfulTree.com/
http://www.TeachMeCocoa.com/
___

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

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

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

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


Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread WT

Thank you, Glenn and David.

In a perfect world, the application would be designed in a way that  
completely abstracts how the animations are going to be implemented  
but, alas, I'm not that experienced yet, so I am still trying to  
ascertain what the best approach to go with is, so I won't have to do  
a major retrofitting at the end.


openGL is not an option at the moment, since I have only a cursory  
knowledge of it and am not prepared to invest the time needed to learn  
it now.


I also have no direct experience with CoreAnimation, but it doesn't  
look so difficult and I *am* prepared to invest time on it.


I think the problem can be broken down in two parts:

1) drawing the grid itself in an animated fashion

This is a one-time event.

When the grid is first shown, I'd like to draw the balls in some  
interesting pattern, rather than the boring left-to-right along a row,  
one row at a time top-to-bottom. This part I have already done by  
collecting the grid balls into an array, in the sequence I want, and  
then firing a timer that grabs the next item off the array and draws  
it in its assigned position on the grid.


Currently, I am using UIImageViews for these grid items, so the timer  
callback simply sets their frames and adds them as subviews of the  
superview. Alternatively, I could use (cached) UIImages and draw them  
in the superview's -drawRect method, in which case the timer callback  
would set the correct state (say, the row and column indices of the  
next position to draw at and the image to draw there) and then call - 
setNeedsDisplay on the superview.


Given that drawing the grid this way happens only once, I think my  
current solution is probably good enough, performance-wise.


2) animating each grid ball

Each grid ball itself is animated at all times, going through 9 images  
ranging in size from 13x13 to 21x21 pixels. Since there are 2  
interlocking grids of 7x7 balls, we're talking about 98 independently  
animating entities.


If these entities are UIImageViews (as they are now), then there are  
98 subviews and at least 98 threads running (the docs say that  
UIImageView animates its images in a separate thread). 98 subviews  
aren't going to be a problem, I think, because I'm not moving them nor  
changing their relative positions in the view hierarchy. I am,  
however, concerned with 98 threads.


I imagine I could still have UIImageViews - but a single thread - by  
firing a timer that *sets* the current image of each UIImageView,  
rather than have them animate independently.


Alternatively, I could forgo the UIImageView idea altogether and have  
a timer that calls -setNeedsDisplay, just as before. I don't see much  
of an advantage here compared to the alternative immediately above.


I could also use Core Animation layers as suggested by Glenn. Another  
option is what David suggested, to use a texture atlas. I understand  
how texture atlases work and it sounds like a great idea. Either way,  
I can't evaluate off-hand what trade-offs are involved, since I'm not  
familiar with Core Animation.


I should point out that there will be 2 other entities moving on the  
screen, on top of the grid, and these other entities are also  
independently animated. Finally, there are 6 other entities elsewhere  
on the screen (not overlapping the grid) that *never* move, but also  
animate independently.


A movie is worth a million words, so here's the gist of it (with  
temporary art work and other things missing):


http://www.restlessbrain.com/iPhone/AnimTest.mov

Given these constraints, I'd be grateful for a recommendation on what  
approach is likely to be the most efficient. Yes, I know I should  
profile the application to answer that question, but the reality is  
that I cannot afford right now to spend the time needed to implement  
several different approaches, especially when I'm not sufficiently  
familiar with them all to be able to do it quickly and reasonably bug- 
free.


Thank you all in advance.
Wagner
___

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

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

Help/Unsubscribe/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* kMyKey = @aKey vs #define MYKEY @aKey

2009-04-03 Thread Dave Keck
 As for read-only address space, does the const declaration not take care of
 that? (Serious question.)

I just tested whether it's possible to write at the address of an
NSString declared with either:

NSString *const HelloString = @ABC123;
#define GoodbyeString @XYZ345

(If you're interested, you can download my test project here:
http://www.docdave.com/halla.zip)

In both cases, I was able to write to the address of the string
without crashing. I found this surprising, because I assumed at least
HelloString would be stored in the read-only _TEXT segment...

According to otool (otool -l), the _cstring section of the _TEXT
segment for my test app starts at the decimal offset 3740 in the
binary. With my handy HexEdit, I went to this offset, and sure enough,
there's my 'ABC123' and 'XYZ345'. (Perhaps I should also note that the
_cstring section is the only place where these two strings appear in
the binary.)

So it seems that the strings are stored as C strings in the binary
(not surprising, I guess) but are automagically converted to NSStrings
at runtime. These runtime-generated NSStrings are stored in a
read-write portion of the processes' address space, which is why I was
able to write directly to their addresses.

So I guess this is getting OT, but if someone (perhaps, The Runtime
Wrangler :)) knows how this works, I'd love to know.
___

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

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

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

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


Re: Screen recorder

2009-04-03 Thread Dave Keck
LMGTFY...

http://shinywhitebox.com/
http://www.telestream.net/screen-flow/overview.htm
http://www.macvcr.com/
http://www.ambrosiasw.com/utilities/snapzprox/

Personally, I've used ScreenFlow and it worked well.

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: hung in read$UNIX2003

2009-04-03 Thread Michael Ash
On Fri, Apr 3, 2009 at 2:42 PM, Ken Thomases k...@codeweavers.com wrote:
 On Apr 3, 2009, at 11:10 AM, Michael Ash wrote:

 On Fri, Apr 3, 2009 at 9:36 AM, Michael Domino
 michael.dom...@identityfinder.com wrote:

 I have a task prepared and launched with the code below, and when it
 returns
 (in this situation that status code returned from terminationStatus is
 0),
 it hangs in availableData, never to return. [...]

                               messagePipeError = [NSPipe pipe];
                               messagePipeOutput = [NSPipe pipe];
                               [task setLaunchPath:@/usr/bin/hdiutil];
                               [task setArguments:[NSArray
 arrayWithObjects:@info, nil]];
                               [task setStandardError:messagePipeError];

                               [task setStandardOutput:messagePipeOutput];

                               [task launch];
                               [task waitUntilExit];
                               status = [task terminationStatus];

                       NSData *messageDataError = [[messagePipeError
 fileHandleForReading] availableData];
                       messageError = [[[NSString alloc]
 initWithData:messageDataError encoding:NSUTF8StringEncoding]
 autorelease];

 I don't know if this is the cause of your problem or not, but never,
 ever do this. Don't call waitUntilExit before you read. Pipes have a
 small buffer (4kB?) and if it fills up then further writes will block.
 This means that if you do a waitUntilExit while the subprocess is
 writing more data than the pipe can buffer, you'll deadlock. The
 subprocess will be waiting for you to read data before it can
 continue, and you will be waiting for it to exit before you read data.
 Read all data (using readDataToEndOfFile or equivalent) *before* you
 do waitUntilExit.

 And, since you have two pipes, you're going to have to read from both
 simultaneously.  Otherwise, you still have a chance for deadlock, if you're
 blocking reading on one handle while the subprocess is blocking waiting for
 the other pipe to be drained.

 This is best done using the asynchronous methods of NSFileHandle.

An excellent point. I missed that particular feature of his code.

Personally, for a situation like this, where the subprocess is
expected to finish its work quickly, I would just write a little loop
calling select() and read() to drain both pipes at the same time. But
the important thing is just to read the data out of the pipes without
blocking on anything else or without blocking on either pipe
individually. How you do that is pretty much just a matter of taste,
or of what fits your code best.

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-03 Thread Michael Ash
On Fri, Apr 3, 2009 at 8:30 PM, Eric Hermanson zmons...@mac.com 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/archive%40mail-archive.com

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


Re: Screen recorder

2009-04-03 Thread Conrad Taylor
Hi, I would recommend Screen Flow to capture what you're doing on the  
computer and Mouse Posé to display your keyboard commands.


Good luck,

-Conrad

Sent from my iPhone

On Apr 3, 2009, at 7:15 PM, Michaelian Ennis  
michaelian.en...@gmail.com wrote:



I need a screen recorder to make some tutorials for using an
application.   The only real requirement is that there be a three
button mouse transparency showing the button presses.  This needs to
support the display of chording ( multiple mouse buttons pressed at
that same time ).   The
nature of the application is such that this really is the only way to
teach it.  Any suggestions?


Ian
___

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

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

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

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