Re: CoreData Property access compiles, but fails at runtime

2008-07-20 Thread Ben Trumbull

You probably should be using @synthesize instead


For modeled Core Data properties, @dynamic is better.

- Ben

___

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

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

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

This email sent to [EMAIL PROTECTED]


re: Autosaving in an NSPersistentDocument

2008-07-20 Thread Ben Trumbull

Rick,

There's a difference in NSDocument parlance between "save", "save as",  
"save to", and "auto save".  None of those things are "saves  
automatically, after a timer or notification"


You can easily implement "saves automatically".  Apps like iCal simply  
save at the end of the event, piggy back off the  
NSManagedObjectContextObjectsDidChangeNotification.


Core Data has always supported Save As... style functionality, and  
whether you trigger a -save: invocation by a menu action, binding,  
timer, or notification doesn't matter.


The difference between "auto-save" and "automatically saves" is  
whether or not the current document is clean or dirty afterwards.  An  
NSDocument auto-save creates a new backup document file, but does not  
in any way disturb the current edits that the user may be working  
with.  Automatically saving is just flushing the current edits to disk  
to the main document file.


The NSManagedObjectContext simply doesn't have a way to save, but  
pretend like all those changes are still pending.


You could fake it by migrating the store to the backup location,  
creating a second context, pulling all the deltas from the original,  
save, and then tossing the second context.


- Ben

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Outline View not retaining objects it uses. Why?

2008-07-20 Thread Ken Thomases

On Jul 19, 2008, at 7:52 PM, Paul Sargent wrote:

While you're right I would return different objects if I was called  
twice, I'm not. As I understand it the Outline View will only ask  
for objects when it knows the data has changed (e.g. after a  
reloadData or reloadItem call) at which point it needs to expect a  
different object.


This is incorrect.  An outline view is not expected to keep or manage  
the objects your data source returns to it.  Your data source _is_ the  
cache of objects which the outlive view uses for that purpose.  If the  
outline view were to implement its own cache, that would just be  
redundant.


It is not the case that the data source is only queried when you tell  
the outline view that the data has changed.  An outline view may ask  
for objects any time it needs to know something about them.  For  
example, if you scroll the view so that some rows are not visible, and  
then scroll back, the outline view may query the data source for the  
newly-revealed rows so that it can draw them.  It does not necessarily  
remember the items just because they were previously visible.


To quote the docs :


"Just like a table view, an outline view uses the data source solely  
to get information. An outline view does not own its data source (see  
Communicating With Objects). Similarly, it does not own the objects it  
gets from the data source—if they are released your application is  
likely to crash unless you tell the outline view to reload its data.  
[…]  The data source is […] responsible for retaining all of the  
objects it provides to an outline view, and updating the outline view  
when there’s a change to the model. It is therefore not safe to  
release the root item—or any children—until you’re no longer  
displaying it in the outline view."


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


Re: property name-to-accessor munging? (was: Dot Syntax docs missing?)

2008-07-20 Thread Ken Thomases

On Jul 18, 2008, at 11:53 PM, Rick Mann wrote:

I realize after all this, it's not really the Dot Syntax I need. I  
need to know how a property name (starts with lower-case letter) is  
transliterated into the getter/setter names.


The dot syntax uses the getter and setting specified for the property  
in the @property declaration.  As documented[1], if you don't  
explicitly supply getter or setter names in that directive, it  
defaults to the property name for the getter and "set" plus the  
property name with its first letter capitalized plus a trailing colon  
for the setter.


The naming conventions[2] used in Cocoa predate both Key-Value  
Coding[3] and the dot syntax, and therefore both follow them.


Cheers,
Ken



[1] http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_3.html#/ 
/apple_ref/doc/uid/TP30001163-CH17-SW2


[2] http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#/ 
/apple_ref/doc/uid/20001282-1004202-BCIGGFCC


[3] http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueCoding/Concepts/AccessorConventions.html#/ 
/apple_ref/doc/uid/20002174-178660

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: drawRect infinite loop -- argh!

2008-07-20 Thread Andy Lee

On Jul 19, 2008, at 11:51 PM, Brian Hughes wrote:
How do I track down the cause of an infinite loop in my drawRect  
method.


Have you tried putting a breakpoint in it?

Are there any other custom views in your view hierarchy, and if so,  
what do *their* -drawRect: methods look like?  One possible bug is  
that you are getting infinite recursion because a -drawRect: method is  
forcing a redraw, which causes -drawRect: to be called again, which  
forces another redraw, etc.


--Andy

___

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

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

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

This email sent to [EMAIL PROTECTED]


can't find NSDefaultRunLoopMode in 10.4.x

2008-07-20 Thread Matt Connolly
I'm writing a preference pane which uses a timer added to the current  
run loop in the mode NSDefaultRunLoopMode.


It seems that 10.4.x systems can't find this symbol with a dyld link  
error at load time, and the preference pane fails to load on 10.4.x  
systems. Works fine on 10.5.x.


My prefpane links to:
MattBookPro:MacOS matt$ otool -L FadeGuardian
FadeGuardian:
	/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa  
(compatibility version 1.0.0, current version 12.0.0)
	/System/Library/Frameworks/PreferencePanes.framework/Versions/A/ 
PreferencePanes (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security  
(compatibility version 1.0.0, current version 31122.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit  
(compatibility version 1.0.0, current version 275.0.0)
	/usr/lib/libcrypto.0.9.7.dylib (compatibility version 0.9.7, current  
version 0.9.7)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/ 
CoreFoundation (compatibility version 150.0.0, current version 476.0.0)
	/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation  
(compatibility version 300.0.0, current version 677.0.0)
	/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current  
version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current  
version 111.0.0)
	/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current  
version 227.0.0)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit  
(compatibility version 45.0.0, current version 949.0.0)



But interestingly enough:

MattBookPro:MacOS matt$ nm /System/Library/Frameworks/ 
Foundation.framework/Versions/C/Foundation | grep NSDefaultRunLoopMode

00272c56 S $ld$add$os10.4$_NSDefaultRunLoopMode

and

MattBookPro:MacOS matt$ nm /System/Library/Frameworks/ 
Foundation.framework/Versions/C/Foundation | grep NSRunLoopCommonModes

00272c57 S $ld$add$os10.4$_NSRunLoopCommonModes
 U _NSRunLoopCommonModes


Any ideas what's going on here?

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

Re: can't find NSDefaultRunLoopMode in 10.4.x

2008-07-20 Thread Stephen J. Butler
On Sun, Jul 20, 2008 at 3:58 AM, Matt Connolly
<[EMAIL PROTECTED]> wrote:
> I'm writing a preference pane which uses a timer added to the current run
> loop in the mode NSDefaultRunLoopMode.
>
> It seems that 10.4.x systems can't find this symbol with a dyld link error
> at load time, and the preference pane fails to load on 10.4.x systems. Works
> fine on 10.5.x.

Are you using the 10.4 SDK, or the 10.5?
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Outline View not retaining objects it uses. Why?

2008-07-20 Thread Paul Sargent


On 20 Jul 2008, at 09:02, Ken Thomases wrote:


On Jul 19, 2008, at 7:52 PM, Paul Sargent wrote:

While you're right I would return different objects if I was called  
twice, I'm not. As I understand it the Outline View will only ask  
for objects when it knows the data has changed (e.g. after a  
reloadData or reloadItem call) at which point it needs to expect a  
different object.


This is incorrect.  An outline view is not expected to keep or  
manage the objects your data source returns to it.  Your data source  
_is_ the cache of objects which the outlive view uses for that  
purpose.  If the outline view were to implement its own cache, that  
would just be redundant.


Ok thanks, I see what I need to do and how to design things in the  
future.


I wasn't really expecting the view to keep a cache at all. I was  
expecting it to request the item each time it wanted information about  
it (in which case an returning an autoreleased object seemed  
reasonable). The fact that the object had a longer life caught me out.  
The documentation does say "outlineView:child:ofItem: is called very  
frequently". Granted that does suggest I don't want to be creating an  
object every time.


I didn't hit either of the notes about it just because of the way a  
tend to traverse the documentation. The way the documentation is  
worded it does seem like it's an exception to the normal Cocoa memory  
management.


Paul
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Outline View not retaining objects it uses. Why?

2008-07-20 Thread ajb . lists


On Jul 20, 2008, at 5:25 AM, Paul Sargent wrote:

 wasn't really expecting the view to keep a cache at all. I was  
expecting it to request the item each time it wanted information  
about it (in which case an returning an autoreleased object seemed  
reasonable).


It may not have been your intention, but you are expecting it to cache  
your objects.  You created a dictionary and returned it to the view  
and did not maintain ownership of the object yourself.  Then, in  
outlineView:objectValueForTableColumn:byItem:, you retrieved values  
from that dictionary and you relied on the view to return a reference  
to that object, and you even stated you thought the view would retain  
the object.  So, effectively, you expected the view to cache it.


Aaron

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: property name-to-accessor munging? (was: Dot Syntax docs missing?)

2008-07-20 Thread Jean-Daniel Dupas


Le 20 juil. 08 à 10:33, Ken Thomases a écrit :


On Jul 18, 2008, at 11:53 PM, Rick Mann wrote:

I realize after all this, it's not really the Dot Syntax I need. I  
need to know how a property name (starts with lower-case letter) is  
transliterated into the getter/setter names.


The dot syntax uses the getter and setting specified for the  
property in the @property declaration.  As documented[1], if you  
don't explicitly supply getter or setter names in that directive, it  
defaults to the property name for the getter and "set" plus the  
property name with its first letter capitalized plus a trailing  
colon for the setter.



It also has a special case for boolean where getter may be prefixed by  
"is": enabled => isEnabled / setEnabled:.



The naming conventions[2] used in Cocoa predate both Key-Value  
Coding[3] and the dot syntax, and therefore both follow them.


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


NSDocument's isDocumentEdited

2008-07-20 Thread John Love
Within MyDocument's isDocumentEdited I have code to determine whether
MyDocument is edited and return the BOOLean flag accordingly.

I then discovered that the only way to set the window's "dirty" flag was to
*explicitly* call [window setDocumentEdited:editedFlag] within other methods
by duplicating the same code I have in MyDocument's isDocumentEdited method,
followed by setDocumentEdited on the window.

My "off the wall" guess *was* that Cocoa's main event loop called
isDocumentEdited and then set the window to "dirty" if needed.  This guess
is wrong, or otherwise I would not have had to set the window to "dirty"
elsewhere.

Anyone have a clue here?

Cheers, John Love
___

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

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

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

This email sent to [EMAIL PROTECTED]


Obtaining the number of characters in a string

2008-07-20 Thread Phil Faber

Still struggling with documentation!

Simple task.  I have two text fields (text1 & text2) and all I'm  
trying to achieve is to put into text2 a number specifying how many  
characters there are in the text in text1.


I started with:

[text2 setStringValue:[text1 stringValue]];

..just to make sure I was on the right track and it successfully  
placed a copy of the text1 text into text2.  Now all I needed was to  
change the code to put the character count instead.


I looked at the documentation and under NSString I found:

Getting a String’s Length
• – length
• – lengthOfBytesUsingEncoding:
• – maximumLengthOfBytesUsingEncoding:

So I click on 'length' and was told that this 'Returns the number of  
Unicode characters in the receiver.'  Not sure if that's the same  
thing as just counting characters but changed my code to:


[text2 setStringValue:[text1 length]];

and got ...'warning: passing argument 1 of 'setStringValue:' makes  
pointer from integer without a cast'


..so assuming this means I was trying to place a number into a text  
field, I changed the code to:


[text2 setIntValue:[text1 length]];

It compiled and linked fine but the code didn't put anything into text2!

Where am I going 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 [EMAIL PROTECTED]


Re: Obtaining the number of characters in a string

2008-07-20 Thread Tim Isted

Try using

	[text2 setStringValue:[NSString stringWithFormat:@"%i", [[textField1  
stringValue] length]]];


Using setIntValue on a text field won't set the text field's  
stringValue to be a string from that int.


Tim


On 20 Jul 2008, at 12:56, Phil Faber wrote:


Still struggling with documentation!

Simple task.  I have two text fields (text1 & text2) and all I'm  
trying to achieve is to put into text2 a number specifying how many  
characters there are in the text in text1.


I started with:

[text2 setStringValue:[text1 stringValue]];

..just to make sure I was on the right track and it successfully  
placed a copy of the text1 text into text2.  Now all I needed was to  
change the code to put the character count instead.


I looked at the documentation and under NSString I found:

Getting a String’s Length
• – length
• – lengthOfBytesUsingEncoding:
• – maximumLengthOfBytesUsingEncoding:

So I click on 'length' and was told that this 'Returns the number of  
Unicode characters in the receiver.'  Not sure if that's the same  
thing as just counting characters but changed my code to:


[text2 setStringValue:[text1 length]];

and got ...'warning: passing argument 1 of 'setStringValue:' makes  
pointer from integer without a cast'


..so assuming this means I was trying to place a number into a text  
field, I changed the code to:


[text2 setIntValue:[text1 length]];

It compiled and linked fine but the code didn't put anything into  
text2!


Where am I going 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/cocoa-dev%40timisted.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Obtaining the number of characters in a string

2008-07-20 Thread Ron Fleckner


On 20/07/2008, at 9:56 PM, Phil Faber wrote:


Still struggling with documentation!


That might be because the documentation makes the reasonable  
assumption that you already know how to use C and Objective-C.




Simple task.  I have two text fields (text1 & text2) and all I'm  
trying to achieve is to put into text2 a number specifying how many  
characters there are in the text in text1.


I started with:

[text2 setStringValue:[text1 stringValue]];

..just to make sure I was on the right track and it successfully  
placed a copy of the text1 text into text2.  Now all I needed was  
to change the code to put the character count instead.


I looked at the documentation and under NSString I found:

Getting a String’s Length
• – length
• – lengthOfBytesUsingEncoding:
• – maximumLengthOfBytesUsingEncoding:

So I click on 'length' and was told that this 'Returns the number  
of Unicode characters in the receiver.'  Not sure if that's the  
same thing as just counting characters but changed my code to:


[text2 setStringValue:[text1 length]];

and got ...'warning: passing argument 1 of 'setStringValue:' makes  
pointer from integer without a cast'


..so assuming this means I was trying to place a number into a text  
field, I changed the code to:


[text2 setIntValue:[text1 length]];

It compiled and linked fine but the code didn't put anything into  
text2!


Where am I going wrong?


You're not recognising the difference between the data types 'int'  
and 'pointer to object'.  The text field expects a pointer to an  
NSString.  Telling it to setIntValue:someInt is just you hoping it'll  
work.


What you need to do is [text2 setStringValue:[NSString  
stringWithFormat:@"%d", [text1 length]]];


You should read the documentation, paying attention to method return  
types and etcetera.  Also, bone up on basic C.  It will help a lot.


Ron___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSDocument's isDocumentEdited

2008-07-20 Thread Graham Cox
Normally you "tell" a document that it is edited in one of two ways -  
either a) by maintaining an Undo stack in which case it "just works",  
and b) by calling -updateChangeCount: The method you mention is a  
lower level method that is not meant to be overridden, as far as I'm  
aware. If you use -updateChangeCount: the window dirty state is  
handled for you - if not using Undo then you'd just call this for each  
change of state in your data model that should mark the document dirty.


hth,


Graham



On 20 Jul 2008, at 9:31 pm, John Love wrote:


Within MyDocument's isDocumentEdited I have code to determine whether
MyDocument is edited and return the BOOLean flag accordingly.

I then discovered that the only way to set the window's "dirty" flag  
was to
*explicitly* call [window setDocumentEdited:editedFlag] within other  
methods
by duplicating the same code I have in MyDocument's isDocumentEdited  
method,

followed by setDocumentEdited on the window.

My "off the wall" guess *was* that Cocoa's main event loop called
isDocumentEdited and then set the window to "dirty" if needed.  This  
guess
is wrong, or otherwise I would not have had to set the window to  
"dirty"

elsewhere.

Anyone have a clue here?

Cheers, John Love
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Obtaining the number of characters in a string

2008-07-20 Thread Graham Cox
You can also use a formatter (which can be set up in IB) that allows  
you to call setIntValue: on a text field and have it display something  
sensible.


Not sure if that will help or hinder, but it's there FWIW,

hth

Graham


On 20 Jul 2008, at 10:12 pm, Tim Isted wrote:


Try using

	[text2 setStringValue:[NSString stringWithFormat:@"%i",  
[[textField1 stringValue] length]]];


Using setIntValue on a text field won't set the text field's  
stringValue to be a string from that int.


Tim





[text2 setIntValue:[text1 length]];



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Dot Syntax docs missing?

2008-07-20 Thread Bill Royds


On 19-Jul-08, at  22:42:05 , Marcel Weiher <[EMAIL PROTECTED]>  
wrote:


On Jul 19, 2008, at 18:34 , Ian Joyner wrote:


On 19/07/2008, at 11:36 PM, Michael Ash wrote:


The universe of programming languages extends far beyond this little
island of ALGOL-lookalikes. Objective-C messaging syntax is utterly
mundane compared to many common, useful syntaxes used in practical
(but different) languages every day. IMO you do yourself a  
disservice
if you don't branch out and try some different things once in a  
while,

and remember that they're just programming languages, and syntax is
just syntax, nothing really all that important.


Except that syntax is the medium to convey meaning, thus to make it  
easier for others to understand what a program is about. If it were  
not so, we may as well have stuck to programming machine language  
in 1s and 0s. Thus syntax is important... or at least the  
manifestation of that which is important.


Yep.  For example, the Smalltalk syntax that Objective-C's 'bracket'  
syntax is based on went through several iterations until they found  
one that gave the most readable and predictable results.


Funny. I find the Objective-C syntax much cleaner than the C++  
template based syntax, especially the complicated method call syntax.   
I started Object oriented programming with Simula 67, then Smalltalk,  
so C++ was the anomaly, not Objective-C.

Syntax ease depends on your experience as much as inherent difficulty.

I find that I use dot syntax for value (including property)  
extraction, while bracket for message passing. That makes my code  
easier to scan looking for calls versus value change.







Bill Royds



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Obtaining the number of characters in a string

2008-07-20 Thread Andy Lee

On Jul 20, 2008, at 8:12 AM, Tim Isted wrote:

Try using

	[text2 setStringValue:[NSString stringWithFormat:@"%i",  
[[textField1 stringValue] length]]];


Using setIntValue on a text field won't set the text field's  
stringValue to be a string from that int.


I believe this is incorrect.  Try simply

[text2 setIntValue:[[text1 stringValue] length]];

The original mistake was using [text1 length], which asks the text  
*field* for its length (no such method) instead of asking the text  
field's *string*.


Using +stringWithFormat: works too, but it's doing more than you need.

--Andy

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: opaque types in NSArray

2008-07-20 Thread Michael Ash
On Sun, Jul 20, 2008 at 12:28 AM, lajos kamocsay <[EMAIL PROTECTED]> wrote:
> It seems that in order to add an opaque type (for example CFPathRef) to an
> NSArray it needs to be wrapped into an object. What's the best way of doing
> this?

I assume you mean a CGPathRef. That's a CFType, and all CFTypes are
also valid Objective-C objects, although the compiler doesn't know
this. So just cast to id and insert directly into the 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 [EMAIL PROTECTED]


Re: property name-to-accessor munging? (was: Dot Syntax docs missing?)

2008-07-20 Thread mmalc crawford


On Jul 20, 2008, at 4:17 AM, Jean-Daniel Dupas wrote:

The dot syntax uses the getter and setting specified for the  
property in the @property declaration.  As documented[1], if you  
don't explicitly supply getter or setter names in that directive,  
it defaults to the property name for the getter and "set" plus the  
property name with its first letter capitalized plus a trailing  
colon for the setter.


It also has a special case for boolean where getter may be prefixed  
by "is": enabled => isEnabled / setEnabled:.



For dot syntax, no it doesn't.
If you want to use isEnabled, you must specify it in the property  
declaration.


mmalc


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: property name-to-accessor munging? (was: Dot Syntax docs missing?)

2008-07-20 Thread Clark Cox
On Sun, Jul 20, 2008 at 4:17 AM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:
>
> Le 20 juil. 08 à 10:33, Ken Thomases a écrit :
>
>> On Jul 18, 2008, at 11:53 PM, Rick Mann wrote:
>>
>>> I realize after all this, it's not really the Dot Syntax I need. I need
>>> to know how a property name (starts with lower-case letter) is
>>> transliterated into the getter/setter names.
>>
>> The dot syntax uses the getter and setting specified for the property in
>> the @property declaration.  As documented[1], if you don't explicitly supply
>> getter or setter names in that directive, it defaults to the property name
>> for the getter and "set" plus the property name with its first letter
>> capitalized plus a trailing colon for the setter.
>
>
> It also has a special case for boolean where getter may be prefixed by "is":
> enabled => isEnabled / setEnabled:.

This is not true. Each (read/write) property defines one setter and
one getter, there is no special case for BOOL properties. If you want
the getter to be called "isEnabled", you have to specify that:

@property (getter = isEnabled) enabled;

-- 
Clark S. Cox III
[EMAIL PROTECTED]
___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: property name-to-accessor munging? (was: Dot Syntax docs missing?)

2008-07-20 Thread Jean-Daniel Dupas


Le 20 juil. 08 à 16:31, Clark Cox a écrit :


On Sun, Jul 20, 2008 at 4:17 AM, Jean-Daniel Dupas
<[EMAIL PROTECTED]> wrote:


Le 20 juil. 08 à 10:33, Ken Thomases a écrit :


On Jul 18, 2008, at 11:53 PM, Rick Mann wrote:

I realize after all this, it's not really the Dot Syntax I need.  
I need

to know how a property name (starts with lower-case letter) is
transliterated into the getter/setter names.


The dot syntax uses the getter and setting specified for the  
property in
the @property declaration.  As documented[1], if you don't  
explicitly supply
getter or setter names in that directive, it defaults to the  
property name
for the getter and "set" plus the property name with its first  
letter

capitalized plus a trailing colon for the setter.



It also has a special case for boolean where getter may be prefixed  
by "is":

enabled => isEnabled / setEnabled:.


This is not true. Each (read/write) property defines one setter and
one getter, there is no special case for BOOL properties. If you want
the getter to be called "isEnabled", you have to specify that:

@property (getter = isEnabled) enabled;


You're right.
I thought that the "name <=> selector mapping" was the same for  
properties and for KVC.





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: opaque types in NSArray

2008-07-20 Thread lajos kamocsay

Thanks! (I did mean CGPathRef..)

-lajos

On Jul 20, 2008, at 10:25 AM, Michael Ash wrote:

On Sun, Jul 20, 2008 at 12:28 AM, lajos kamocsay <[EMAIL PROTECTED]>  
wrote:
It seems that in order to add an opaque type (for example  
CFPathRef) to an
NSArray it needs to be wrapped into an object. What's the best way  
of doing

this?


I assume you mean a CGPathRef. That's a CFType, and all CFTypes are
also valid Objective-C objects, although the compiler doesn't know
this. So just cast to id and insert directly into the 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/l1sts%40panka.com

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Being notified of changes to a file

2008-07-20 Thread Yann Disser

Hi everyone.

I am trying to execute a ruby script from within a Cocoa application.  
I want to use NSTask (any better ideas?).


My scripts outputs its progress by printing single lines on standard  
out containing percentages (e.g. "15%"). How can I update my  
application continuously depending on that progress? (for progress  
bars and other output)


Thank you a lot,
Yann
___

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

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

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

This email sent to [EMAIL PROTECTED]


How to get a table column header with an image instead of text?

2008-07-20 Thread Marc Respass

Hi All,

I have run a number of searches and cannot find any documentation nor  
examples for putting an image in a table column header. I tried  
setting the table header column cell to an NSImageCell but that failed  
fabulously. It seems that I need to sub-class NSTableHeaderCell and  
draw the image myself instead of text. Can anyone point me in the  
right direction? Subclassing is fun, no doubt, but if there's a better  
way, I haven't found it so that's the path I'm planning to take.


Thanks a lot
Marc
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to get a table column header with an image instead of text?

2008-07-20 Thread Marc Respass

Hi again,

I hate answering my own question but I did figure it out. I sub- 
classed NSTableHeaderCell then created an instance using  
initImageCell. Then it occurred to me that it seemed a bit silly. If I  
can init an image cell, maybe I can just set the cell. So, create an  
outlet to the column (or find it somehow) and in awakeFromNib,


NSImage *image = [NSImage imageNamed:@"CellImage"];
[[theColumn headerCell] setImage:image];

Now to figure out how to prevent the sort indicator from displaying :).

Thanks
Marc

On Jul 20, 2008, at 1:38 PM, Marc Respass wrote:


Hi All,

I have run a number of searches and cannot find any documentation  
nor examples for putting an image in a table column header. I tried  
setting the table header column cell to an NSImageCell but that  
failed fabulously. It seems that I need to sub-class  
NSTableHeaderCell and draw the image myself instead of text. Can  
anyone point me in the right direction? Subclassing is fun, no  
doubt, but if there's a better way, I haven't found it so that's the  
path I'm planning to take.


Thanks a lot
Marc
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


looking for help with http post example

2008-07-20 Thread Richard Nichols

Hi

I'm looking for a simple example that will show me how to do an http  
POST with user and password in cocoa.


All I want to do is send some text to a php script but it expects the  
see the user and password and I'm not sure what classes to use and how  
to set them up.


I've looked at a number of examples on the web but they appear too  
complex or convoluted...


Thanks
ran6110
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to get a table column header with an image instead of text?

2008-07-20 Thread Jean-Daniel Dupas


Le 20 juil. 08 à 19:54, Marc Respass a écrit :


Hi again,

I hate answering my own question but I did figure it out. I sub- 
classed NSTableHeaderCell then created an instance using  
initImageCell. Then it occurred to me that it seemed a bit silly. If  
I can init an image cell, maybe I can just set the cell. So, create  
an outlet to the column (or find it somehow) and in awakeFromNib,


NSImage *image = [NSImage imageNamed:@"CellImage"];
[[theColumn headerCell] setImage:image];

Now to figure out how to prevent the sort indicator from  
displaying :).


Subclass NSTableColumneHeaderCell and override

- (void)drawSortIndicatorWithFrame:(NSRect)cellFrame inView: 
(NSView*)controlView ascending:(BOOL)ascending priority: 
(NSInteger)priority



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to get a table column header with an image instead of text?

2008-07-20 Thread Adam R. Maxwell


On Jul 20, 2008, at 10:57 AM, Jean-Daniel Dupas wrote:



Le 20 juil. 08 à 19:54, Marc Respass a écrit :


Hi again,

I hate answering my own question but I did figure it out. I sub- 
classed NSTableHeaderCell then created an instance using  
initImageCell. Then it occurred to me that it seemed a bit silly.  
If I can init an image cell, maybe I can just set the cell. So,  
create an outlet to the column (or find it somehow) and in  
awakeFromNib,


NSImage *image = [NSImage imageNamed:@"CellImage"];
[[theColumn headerCell] setImage:image];

Now to figure out how to prevent the sort indicator from  
displaying :).


Subclass NSTableColumneHeaderCell and override

- (void)drawSortIndicatorWithFrame:(NSRect)cellFrame inView: 
(NSView*)controlView ascending:(BOOL)ascending priority: 
(NSInteger)priority


I'd try -[NSTableView setIndicatorImage:inTableColumn:] passing nil  
for the indicator image first.


--
Adam



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

Re: looking for help with http post example

2008-07-20 Thread Jean-Daniel Dupas


Le 20 juil. 08 à 19:55, Richard Nichols a écrit :


Hi

I'm looking for a simple example that will show me how to do an http  
POST with user and password in cocoa.


All I want to do is send some text to a php script but it expects  
the see the user and password and I'm not sure what classes to use  
and how to set them up.


I've looked at a number of examples on the web but they appear too  
complex or convoluted...


Thanks


If you just need send simple string value, you can use the easy way,  
encoding it as a "application/x-www-form-urlencoded"


See the following link for an sample code:

http://deusty.blogspot.com/2006/11/sending-http-get-and-post-from-cocoa.html


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: drawRect infinite loop -- argh!

2008-07-20 Thread Brian Hughes

Thanks for all of the replies.  I do use the debugger, but even with the 
debugger I couldn't figure out why it is looping. 
Obviously, there is something I am not understanding which is why I am writing 
to cocoa-dev.

I also removed the NSLog statement but it is still looping.  I can't see it in 
the run log but I my G5 fans start wailing and when
I step through it , it loops.

Here is the whole sequence in the debugger:'

The drawRect method is being called originally when I go to the tab in the 
tabView where the custom View is located.

Thread 1
-[LNTab3View drawRect:] at LNTab3View.m:102
-[NSView _drawRect:clip:]
-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
 _recursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
_recursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
_recursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
_recursiveDisplayInRect2
 CFArrayApplyFunction
-[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSThemeFrame 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
-[NSView displayIfNeeded]
-[NSWindow displayIfNeeded]
-[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
-[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:]
loadNib
_loadNibFile:nameTable:withZone:ownerBundle:]
+[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:]
+[NSBundle(NSNibLoading) loadNibNamed:owner:]
NSApplicationMain

Thread-1
-[LNTba3View drawRect:]
-[NSView _drawRect:clip]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSThemeFrame 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
-[NSView displayIfNeeded]
-[NSWindow displayIfNeeded]

Thread 2
-[LNTab3View drawRect:] at LNTab3View.m:52
-[NSView _drawRect:clip:]
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
-[NSButtonCell(NSDefaultButtonIndicatorPrivate) heartBeat:]
-[NSWindow(NSWindow_Theme) heartBeat:]
-[NSUIHeartBeat _heartBeatThread:] 

Thread-1
-[LNTba3View drawRect:]
-[NSView _drawRect:clip]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSThemeFrame 
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
-[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
-[NSView displayIfNeeded]
-[NSWindow displayIfNeeded]

Thread 2
-[LNTab3View drawRect:] at LNTab3View.m:52
-[NSView _drawRect:clip:]
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
-[NSButtonCell(NSDefaultButtonIndicatorPrivate) heartBeat:]
-[NSWindow(NSWindow_Theme) heartBeat:]
-[NSUIHeartBeat _heartBeatThread:]

And so it begins again.

Maybe the problem is obvious to you guys but it is not to me.  Any help would 
be great.



























_
Use video conversation to talk face

StopWatch Application Help

2008-07-20 Thread Eric Lee
I'm trying to make a stopwatch application, and I'm having trouble  
getting the Timer to fire, and then having the Text field being updated.


Here's the code:

AppController.h


@interface AppController : NSObject {
IBOutlet NSTextField *textField;
NSTimer *timer;
NSDate *startTime;
}

- (IBAction)startWatch:(id)sender;
- (IBAction)stopWatch:(id)sender;

---

AppController.m

---

#import "AppController.h"


@implementation AppController

- (IBAction)startWatch:(id)sender
{
NSDate *currentDate = [NSDate date];
NSString *string = [timer value];
	timer = [NSTimer timerWithTimeInterval:1 target:self  
selector:@selector(startWatch:) userInfo:nil repeats: YES];

[timer isValid];
[textField setValue:string];
	[[NSRunLoop currentRunLoop] addTimer:timer forMode:  
NSDefaultRunLoopMode];

[timer setFireDate:currentDate];
}
- (IBAction)stopWatch:(id)sender
{
[timer invalidate];
[timer release];
}

@end

---

I know that there is definitely some mistakes, as this is my first  
time using NSTimer, and NSTimeInterval (i'm trying to learn this class  
for another application).


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


Re: looking for help with http post example

2008-07-20 Thread Richard Nichols

Thank you for the link,

I'm missing something, how do I get the user and password information  
inserted?


As a little additional information, I'm trying to talk to a php script  
that has an API similar to Twitter.


So I need to have user password and UTF8 text.

It should be simple but I've been spoiled with components on the  
windows platform that sets all of this up for me.


Thanks,
ran6110


On Jul 20, 2008, at 11:23 AM, Jean-Daniel Dupas wrote:



Le 20 juil. 08 à 19:55, Richard Nichols a écrit :


Hi

I'm looking for a simple example that will show me how to do an  
http POST with user and password in cocoa.


All I want to do is send some text to a php script but it expects  
the see the user and password and I'm not sure what classes to use  
and how to set them up.


I've looked at a number of examples on the web but they appear too  
complex or convoluted...


Thanks


If you just need send simple string value, you can use the easy way,  
encoding it as a "application/x-www-form-urlencoded"


See the following link for an sample code:

http://deusty.blogspot.com/2006/11/sending-http-get-and-post-from-cocoa.html




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: StopWatch Application Help

2008-07-20 Thread Marco Masser
I'm trying to make a stopwatch application, and I'm having trouble  
getting the Timer to fire, and then having the Text field being  
updated.


Here's the code:


The essential part is missing: the method in which you are updating  
your text field.



- (IBAction)startWatch:(id)sender
{
NSDate *currentDate = [NSDate date];
NSString *string = [timer value];
	timer = [NSTimer timerWithTimeInterval:1 target:self  
selector:@selector(startWatch:) userInfo:nil repeats: YES];

[timer isValid];
[textField setValue:string];
	[[NSRunLoop currentRunLoop] addTimer:timer forMode:  
NSDefaultRunLoopMode];

[timer setFireDate:currentDate];
}


What you are doing is this: you create a timer and tell it to fire  
every second (starting in one second), you add it to the default run  
loops, then you tell it to fire "now". Every time the timer fires, it  
is looking for a method with the signature - (void)startWatch:(NSTimer  
*)timer. Again, read the docs for NSTimer and take a good look at what  
the method should look like, whose selector you pass in.


Btw: the line [timer isValid] does nothing here.

The code should look like this (I write this in Mail, there may be  
errors):


- (IBAction)startWatch:(id)sender {
[timer invalidate]; // Just in case the timer is already running
[timer autorelease];

	// +scheduledTimer... methods do The Right Thing (TM) about run loops  
in this case
	timer = [NSTimer scheduledTimerWithInterval:1.0 target:self selector: 
(updateTextfield:) userInfo:nil repeasts:YES];


[startTime autorelease];
	startTime = [NSDate timeIntervalSinceReferenceDate]; // startTime is  
of type NSTimeInterval here! Update your header file!

}

// This is the method the timer tries to call. Everything you want to  
happen every second should be in here

- (void)updateTextfield:(NSTimer *)timer {
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
NSTimeInterval difference = now - startTime;
NSString *timeString = [NSString stringWithFormat:@"%f", difference];
[textField setStringValue:timeString];
}



- (IBAction)stopWatch:(id)sender
{
[timer invalidate];
[timer release];
}


That's OK.


Hope this helps!
___

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

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

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

This email sent to [EMAIL PROTECTED]


drawRect doesn't get called when using CoreAnimation?

2008-07-20 Thread Rick Mann
I have Wants Core Animation Layer checked in IB on my view, and when I  
do, my view subclass' drawRect doesn't get called. Is there any way to  
have it also called (preferably after CA draws my layers)?


Mostly this is just for experimentation, so I can draw while figuring  
out how to convert my drawing to CA.


--
Rick

___

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

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

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

This email sent to [EMAIL PROTECTED]


newbie question: NSURLConnection delegation and "method instance"

2008-07-20 Thread JB Ashton
Hi all,

I'm struggling with "receivedData is declared as a method instance
elsewhere" in this explanation of NSURLConnection delegation:
http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

When I declare the receivedData as NSMutableData in the delegate's header
file, I get this warning from the compiler: "warning: local declaration of
'receivedData' hides instance variable".

Where should I declare the receivedData variable so that it is available to
all the delegation methods (connection:didReceiveResponse:, etc.), but won't
be hidden by the local declaration above?  Won't local declarations in each
delegate method refer to different NSMutableData objects?

Many thanks,
JB
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to get a table column header with an image instead of text?

2008-07-20 Thread Marc Respass


On Jul 20, 2008, at 2:05 PM, Adam R. Maxwell wrote:



On Jul 20, 2008, at 10:57 AM, Jean-Daniel Dupas wrote:



Le 20 juil. 08 à 19:54, Marc Respass a écrit :


Hi again,

I hate answering my own question but I did figure it out. I sub- 
classed NSTableHeaderCell then created an instance using  
initImageCell. Then it occurred to me that it seemed a bit silly.  
If I can init an image cell, maybe I can just set the cell. So,  
create an outlet to the column (or find it somehow) and in  
awakeFromNib,


NSImage *image = [NSImage imageNamed:@"CellImage"];
[[theColumn headerCell] setImage:image];

Now to figure out how to prevent the sort indicator from  
displaying :).


Subclass NSTableColumneHeaderCell and override

- (void)drawSortIndicatorWithFrame:(NSRect)cellFrame inView: 
(NSView*)controlView ascending:(BOOL)ascending priority: 
(NSInteger)priority


I'd try -[NSTableView setIndicatorImage:inTableColumn:] passing nil  
for the indicator image first.


Thank you both.

[[indicatorColumn tableView] setIndicatorImage:nil  
inTableColumn:indicatorColumn];


still displays the image. I imagine it uses the default (clearing your  
potential custom image) if you pass nil. However, it seems like a hack  
but the column is narrow. If it is resized to fit the image in the  
column header, then the indicator image does not show. In fact, I can  
simply set the column to not be resizable and invoke sizeToFit which  
sizes it perfectly.


Thanks again.
Marc___

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

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

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

This email sent to [EMAIL PROTECTED]


Core Data Sync Question (Managed Object Contexts)

2008-07-20 Thread Manoj Patwardhan
I am using Core Data syncing which uses its own managed object context  
to apply sync changes. In the pulling stage, my application's managed  
object context's mergeChangesFromContextDidSaveNotification method is  
getting called. However, the application has some array controllers  
that are listening to changes to that managed object context, and  
those are never called. In other words, even though the application's  
managed object context is notified of changes merged by the syncing  
managed object context, the array controllers that are observing the  
former are not made aware of the change.


When syncing using Core Data syncing, how can one make the array  
controllers reload their contents after syncing happens?


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


Re: Obtaining the number of characters in a string

2008-07-20 Thread Phil Faber
Thanks to all who helped me with this challenge of obtaining the  
number of characters in a string.


On 20 Jul 2008, at 13:12, Tim Isted wrote:

Try using

	[text2 setStringValue:[NSString stringWithFormat:@"%i", [[Field1  
stringValue] length]]];


Using setIntValue on a text field won't set the text field's  
stringValue to be a string from that int.


That worked perfectly - thanks Tim.



On 20 Jul 2008, at 13:16, Ron Fleckner wrote:


Still struggling with documentation!


That might be because the documentation makes the reasonable  
assumption that you already know how to use C and Objective-C.


You're not recognising the difference between the data types 'int'  
and 'pointer to object'.  The text field expects a pointer to an  
NSString.  Telling it to setIntValue:someInt is just you hoping  
it'll work.


What you need to do is [text2 setStringValue:[NSString  
stringWithFormat:@"%d", [text1 length]]];


You should read the documentation, paying attention to method return  
types and etcetera.  Also, bone up on basic C.  It will help a lot.


I'm trying!  Honest!  I've studied 'Learn C for Cocoa' at http://cocoadevcentral.com/articles/81.php 
, and a C programming book, as well as looking up stuff on the Web but  
it's a very slow process.  The fact that I'm dyslexic doesn't help  
(although that's not a good excuse) as I need to go over things again  
and again to 'get' them ... although once I've 'got it', it tends to  
stay put!  Getting there.  Slowly.




On 20 Jul 2008, at 14:41, Andy Lee wrote:

On Jul 20, 2008, at 8:12 AM, Tim Isted wrote:

Try using

	[text2 setStringValue:[NSString stringWithFormat:@"%i",  
[[textField1 stringValue] length]]];


Using setIntValue on a text field won't set the text field's  
stringValue to be a string from that int.


I believe this is incorrect.  Try simply

[text2 setIntValue:[[text1 stringValue] length]];

The original mistake was using [text1 length], which asks the text  
*field* for its length (no such method) instead of asking the text  
field's *string*.


Interesting.  Although Tim's original suggest did work (so it wasn't  
'wrong' as such...) your simpler version also works and seems much  
neater as it simply asks for the length of the string value of text1.


Thanks everyone!

Phil
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: StopWatch Application Help

2008-07-20 Thread Marco Masser

Thanks. That solved many issues.

However, I still have another question.

How about if I wanted the Timer to start at from 0, and then go to  
1, 2, 3, etc..., not from January 1st like - 
timeIntervalSinceReferenceDate does? I tried doing  
timeIntervalSinceDate:, but it wouldn't work, and  
timeIntervalSinceNow doesn't work either!


Actually, you shouldn't care about which time the timer uses as its  
internal date. What you do care about is the time from the creation of  
the timer until "now", whereas "now" is the time at which your UI  
update method is called. Therefore, you just need the difference  
between "now" and "then", you don't care about the actual values of  
"now" and "then". Therefore, they both use a reference date, which is  
the reason why NSTimer provides a method called  
+timeIntervalSinceReferenceDate.




I revised my code, and it now looks like this:







- (IBAction)startWatch:(id)sender
{
NSDate *currentDate = [NSDate date];
	timer = [NSTimer timerWithTimeInterval:1 target:self  
selector:@selector(updateTextfield:) userInfo:nil repeats: YES];
	[[NSRunLoop currentRunLoop] addTimer:timer forMode:  
NSDefaultRunLoopMode];

[timer setFireDate:currentDate];
}


Again, you don't have to add the timer to the run loops in your case.  
The Timer Reference specifically states:


The following two class methods automatically register the new timer  
with the current NSRunLoop object in the default mode  
(NSDefaultRunLoopMode).


scheduledTimerWithTimeInterval:invocation:repeats:
scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
(http://developer.apple.com/documentation/Cocoa/Conceptual/Timers/Tasks/createtimer.html#/ 
/apple_ref/doc/uid/2807)



- setFireDate: sets the date at which your timer fires. I don't know  
about the implementation details of NSTimer, but I think setting it to  
the current date will prevent it from firing at all because this date  
*will* never be reached (it *has been* reached). In your application,  
you do not  want to set the fire date manually, you simply want your  
timer to fire every second. Remove that line, or it won't work.



- (void)updateTextfield:(NSTimer *)timer
{
NSTimeInterval now =[NSDate timeIntervalSinceReferenceDate];

NSTimeInterval startTime;

NSTimeInterval difference = now - startTime;
NSString *timeString = [NSString stringWithFormat:@"%f", difference];
[textField setStringValue:timeString];
}


startTime should be an ivar, declaring it every time this method is  
executed and not assigning it any value will yield unexpected results.  
Simply declaring a variable of a primitive data type without an  
assignment will give you some random number.
Again, to your first question: This is where you calculate how long  
your stop watch is running already. You only need the difference  
between "now" and "then", whereas "then" is the time at which your  
timer started. Therefore, you must remember that time in -startWatch:




- (IBAction)stopWatch:(id)sender
{
[timer invalidate];
[timer release];
}


I forgot to mention this in my last mail: "timer" is released here,  
but it is never retained by your code. Honestly, I forgot about the  
memory management of timers, I had to read that up again (see the link  
above, its right on that page). Because the run loop retains the  
timer, you can actually remove the -release in -stopWatch:. You could  
also retain it in -startWatch:, just make sure the number of -alloc/- 
retain/-copy and -release messages match.


Additionally, add [timer invalidate] to your -windowWillClose or - 
dealloc method to make sure the timer is stopped and removed from the  
run loop.



___

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

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

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

This email sent to [EMAIL PROTECTED]


NSThread and UI

2008-07-20 Thread Torsten Curdt

AFAIU accessing UI elements from within an NSThread is a big no-no.

So in the following naive code I would have to either wrap the calls  
to the progressIndicator object through a performSelectorOnMainThread  
or could send NSNotifications to update it on the main thread. But  
looking around the net I haven't seen any example where either of both  
approaches is being used. Did I just not look at the right places?


I am also wondering whether using NSRunCriticalAlertPanel() in the  
thread is OK or not.


cheers
--
Torsten


[NSThread detachNewThreadSelector:@selector(convert)
 toTarget:self
   withObject:nil];

- (void) convert {

[progressIndicator setMaxValue:10];
[progressIndicator startAnimation:self];

if (...) {
NSRunCriticalAlertPanel(...);   
}

int i;
for(i = 0; i < 10; i++) {
[progressIndicator setDoubleValue:(double)i];
[progressIndicator displayIfNeeded];
...
}

[progressIndicator stopAnimation:self];
}

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: drawRect doesn't get called when using CoreAnimation?

2008-07-20 Thread Scott Anguish


On 20-Jul-08, at 3:40 PM, Rick Mann wrote:

I have Wants Core Animation Layer checked in IB on my view, and when  
I do, my view subclass' drawRect doesn't get called. Is there any  
way to have it also called (preferably after CA draws my layers)?




No.

If you're using layer-backed views (you set wants layer, but not the  
layer) you should only use view drawing code. You should not add  
layers to it. In fact, ignore the layers entirely.


If you're using layer-hosting (you create the layer and set it for the  
view, then turn on wants layer) you should only use layer drawing  
code. You should ignore the view drawRect: entirely. You should not  
add subviews to the hosting view.


Mostly this is just for experimentation, so I can draw while  
figuring out how to convert my drawing to CA.





___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: newbie question: NSURLConnection delegation and "method instance"

2008-07-20 Thread Scott Anguish
receivedData should be an instance variable of the class that contains  
the code in Listing 1 - Creating a connection using NSURLConnection.


often an instance of that class is also used as the delegate (which is  
what this example code is assuming)


the code for these snippets really needs to be available (and linked  
to) as a sample. it is on my to-do list. But if you file a bug, that  
may help push it up in the queue.



On 20-Jul-08, at 3:43 PM, JB Ashton wrote:


Hi all,

I'm struggling with "receivedData is declared as a method instance
elsewhere" in this explanation of NSURLConnection delegation:
http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

When I declare the receivedData as NSMutableData in the delegate's  
header
file, I get this warning from the compiler: "warning: local  
declaration of

'receivedData' hides instance variable".



It sounds like on of the methods might also be declaring the variable  
name.. do a search for the receivedData string to find it.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: newbie question: NSURLConnection delegation and "method instance"

2008-07-20 Thread Dmitri Goutnik


On Jul 20, 2008, at 11:43 PM, JB Ashton wrote:


Hi all,

I'm struggling with "receivedData is declared as a method instance
elsewhere" in this explanation of NSURLConnection delegation:
http://developer.apple.com/documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

When I declare the receivedData as NSMutableData in the delegate's  
header
file, I get this warning from the compiler: "warning: local  
declaration of

'receivedData' hides instance variable".

Where should I declare the receivedData variable so that it is  
available to
all the delegation methods (connection:didReceiveResponse:, etc.),  
but won't
be hidden by the local declaration above?  Won't local declarations  
in each

delegate method refer to different NSMutableData objects?

Many thanks,
JB


Without seeing the source code, I'm just guessing here -  are you  
declaring receivedData as method local variable in the same method  
where you calling [[NSURLConnection alloc] initWithRequest:delegate: ?


You should declare it in delegate header and just use it in delegate  
methods, otherwise local declaration would indeed hide the instance  
variable.


@interface ConnectionDelegate : NSObject {
NSURLConnection *connection;
NSMutableData   *receivedData;
}

@implementation ConnectionDelegate

- (void)setupConnection {
// ...
	connection=[[NSURLConnection alloc] initWithRequest:theRequest  
delegate:self];

if (connection) {
receivedData = [NSMutableData new];
// ...
}
}

@end

- Dmitri

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSThread and UI

2008-07-20 Thread Bruce Johnson
AppKit stuff isn't thread safe.  AppKit stuff is usually the user
interface stuff (like Progress bars) So that should be run on the main
thread, something like:

> [NSThread detachNewThreadSelector:@selector(convert)
> toTarget:self
>   withObject:nil];
>
> - (void) convert {
>
>
>if (...) {
>NSRunCriticalAlertPanel(...);
>}
>
>int i;
>for(i = 0; i < 10; i++) {
>[self performSelectorOnMainThread: 
> @selector(updateProgressBarWithValue:) withObject: [NSNumber numberWithInt: i 
> waitUntilDone: NO]]
>...
>}
>
>[progressIndicator stopAnimation:self];
> }

- (void) updateProgressBarWithValue: (NSNumber *) aNumber
{
 [progressIndicator setDoubleValue: [aNumber doubleValue]]];
}

or some such...
-- 

Bruce Johnson
[EMAIL PROTECTED]
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Documentation on changing dock icon programmatically?

2008-07-20 Thread Diop Mercer
Thanks, guys.

-m

On Fri, Jul 18, 2008 at 1:34 AM, Kyle Sluder
<[EMAIL PROTECTED]> wrote:
> On Thu, Jul 17, 2008 at 8:35 PM, Ken Thomases <[EMAIL PROTECTED]> wrote:
>> -[NSApplication setApplicationIconImage:] to set the dock tile.
>
> Also take a look at NSDockTile, which is Leopard-only.  It doesn't
> allow you to badge your icon with an image, but it does allow you to
> badge it with text.  This would be a worthwhile case for an
> enhancement request ( http://bugreport.apple.com ).
>
> --Kyle Sluder
>
___

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

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

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

This email sent to [EMAIL PROTECTED]


Create a window with status bar at its bottom, how to do?

2008-07-20 Thread Cloud Strife
Hi everyone. I am interested to create a window with status bar at its
bottom. Hmm, you can see Xcode editor window as an example, once we open a
.m source file, the editor window has a status bar at its bottom. When click
the build and run buttom, you can see the prompt information from Xcode
showing there. It is quite a useful feature to provide notification to
users.

Then, is anyone here having the knowledge to accomplish that? I am totally
messed up with lots lots of document of NSWindow...
Any guidance is greatly appreciate! :-)

Thank you very much.


-- 
Best regards.
___

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

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

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

This email sent to [EMAIL PROTECTED]


WebKit, programmatic form input, form submits

2008-07-20 Thread Diop Mercer
Hi, I've been playing with WebKit, and I've written a Cocoa app that
brings up a site in a WebView. That was easy, but now I'd like to go
to a site with a form and have the Cocoa app fill in the form fields
and submit the form.  Can anyone point me to documentation on how to
programmatically fill in web forms using WebKit? And also how to
programmatically click buttons?



Thanks,
-m
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: WebKit, programmatic form input, form submits

2008-07-20 Thread Mike Abdullah
You'll need to use the DOM API. Either from the ObjC API, or another  
language such as javascript.


On 20 Jul 2008, at 17:39, Diop Mercer wrote:


Hi, I've been playing with WebKit, and I've written a Cocoa app that
brings up a site in a WebView. That was easy, but now I'd like to go
to a site with a form and have the Cocoa app fill in the form fields
and submit the form.  Can anyone point me to documentation on how to
programmatically fill in web forms using WebKit? And also how to
programmatically click buttons?



Thanks,
-m
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSThread and UI

2008-07-20 Thread Ken Thomases

On Jul 20, 2008, at 4:01 PM, Torsten Curdt wrote:


AFAIU accessing UI elements from within an NSThread is a big no-no.


There are exceptions, but that's a good rule of thumb.

Here are Apple's specific guidelines: http://developer.apple.com/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/chapter_950_section_2.html#/ 
/apple_ref/doc/uid/1057i-CH12-123351-BBCFIIEB



So in the following naive code I would have to either wrap the calls  
to the progressIndicator object through a  
performSelectorOnMainThread or could send NSNotifications to update  
it on the main thread.


NSNotifications are delivered on the same thread from which they are  
sent/posted.  So, they don't help -- in and of themselves -- for  
moving work from a secondary thread to the main thread.


I'm pretty sure that, at some point, you have to use  
performSelectorOnMainThread:... or the equivalent to pass the  
information about whatever progress has been made from the secondary  
thread to the main thread.  Since some of the methods you invoke on  
progressIndicator take scalar values, and  
performSelectorOnMainThread:... requires a selector which takes an  
object pointer as its argument, you need to create wrapper methods in  
your own class to invoke on the main thread.  These wrappers take  
their object parameter (likely an NSNumber) and "unpack" a value from  
it to pass along to methods of progressIndicator.


I would recommend that you do the -setMaxValue: and -startAnimation:  
calls from the main thread before detaching the background thread.   
Likewise, you should have a final method on your class which the  
background thread invokes using performSelectorOnMainThread:... just  
before it exits.  That method signals that the background thread has  
completed its work.  Among other things, that's where you would invoke  
-stopAnimation:.


Taken all together, you end up defining a small ad-hoc protocol  
between your background thread and the main thread.  The background  
thread never actually touches the progressIndicator.  Instead, it just  
messages self via performSelectorOnMainThread:... and the methods  
invoked in that way are responsible for updating progressIndicator.



I am also wondering whether using NSRunCriticalAlertPanel() in the  
thread is OK or not.


Good question.  I don't find a specific note about that.  However, the  
above-linked guide says this:


"You can create a modal window on a secondary thread. The Application  
Kit blocks the calling secondary thread while the main thread runs the  
modal loop."


I think that means that NSRunCriticalAlertPanel is safe to use from a  
secondary thread.


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


Re: Obtaining the number of characters in a string

2008-07-20 Thread Ron Fleckner


On 21/07/2008, at 6:26 AM, Phil Faber wrote:



On 20 Jul 2008, at 13:16, Ron Fleckner wrote:


Still struggling with documentation!


That might be because the documentation makes the reasonable  
assumption that you already know how to use C and Objective-C.


You're not recognising the difference between the data types 'int'  
and 'pointer to object'.  The text field expects a pointer to an  
NSString.  Telling it to setIntValue:someInt is just you hoping  
it'll work.


What you need to do is [text2 setStringValue:[NSString  
stringWithFormat:@"%d", [text1 length]]];


You should read the documentation, paying attention to method  
return types and etcetera.  Also, bone up on basic C.  It will  
help a lot.


I'm trying!  Honest!  I've studied 'Learn C for Cocoa' at http:// 
cocoadevcentral.com/articles/81.php, and a C programming book,  
as well as looking up stuff on the Web but it's a very slow  
process.  The fact that I'm dyslexic doesn't help (although that's  
not a good excuse) as I need to go over things again and again to  
'get' them ... although once I've 'got it', it tends to stay put!   
Getting there.  Slowly.



OK, sorry.  I think I got out of the wrong side of bed that morning.   
As it turns out, the 'solution' I posted was wrong anyway.  [text1  
length] won't work because an NSTextField doesn't respond to  
'length'.  It should be [[text1 stringValue] length]


Happy coding,

Ron
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Being notified of changes to a file

2008-07-20 Thread Jens Alfke


On 20 Jul '08, at 9:37 AM, Yann Disser wrote:

I am trying to execute a ruby script from within a Cocoa  
application. I want to use NSTask (any better ideas?).


You can use the Ruby C API to run Ruby inside your process, but that's  
definitely more work.


My scripts outputs its progress by printing single lines on standard  
out containing percentages (e.g. "15%"). How can I update my  
application continuously depending on that progress? (for progress  
bars and other output)


Your subject implies you're writing to a file; don't do that. The Ruby  
script should write to stdout, and you app should hook up an NSPipe to  
the NSTask to read its output directly. (This can be a bit tricky, but  
there's Apple sample code that shows how to do it.)


—Jens

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

Re: looking for help with http post example

2008-07-20 Thread Jens Alfke


On 20 Jul '08, at 11:53 AM, Richard Nichols wrote:

As a little additional information, I'm trying to talk to a php  
script that has an API similar to Twitter.

So I need to have user password and UTF8 text.


Does the website support HTTP authentication? That's the preferred way  
to interact with non-browsers. (Most websites with developer APIs,  
like Twitter and del.icio.us, work this way.) NSURLConnection supports  
this directly; you need to implement the callback for an  
"authorization challenge" and return the username and password.


If the site _doesn't_ support HTTP auth, and thinks you're a web  
browser and expects you to type the username and password into an HTML  
form, and then gives you a cookie to send back ... then things are  
more awkward. You have to
— Assume the site's layout isn't going to change (if the login URL or  
the form fields change, your app will break)
— Construct an NSURLRequest with an HTTP method of "POST", pointing to  
the login URL
— Set the request's body to the username and password and any othe  
required fields, using the x-www-form-urlencoded data format

— Send the request
— Somehow figure out whether the login was accepted, probably based on  
what URL you get redirected to, or what the contents of the returned  
cookie are.


If you succeeded, you can just send regular requests to the site.  
Cocoa will send the cookie automatically. If you ever get logged out  
or the session expires, you'll have to somehow detect that based on  
getting redirected back to the login page or something like that.


I'd be surprised if Windows had any components that did this stuff,  
because it's a total kludge to do and very unreliable. I think you  
mean components for HTTP auth, which Cocoa provides as well.


—Jens

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

Re: Create a window with status bar at its bottom, how to do?

2008-07-20 Thread Jens Alfke


On 19 Jul '08, at 8:10 PM, Cloud Strife wrote:


Hi everyone. I am interested to create a window with status bar at its
bottom. Hmm, you can see Xcode editor window as an example, once we  
open a

.m source file, the editor window has a status bar at its bottom.


In Interface Builder, just move the bottom of the main scrollview up  
about 16 pixels from the bottom of the window, and put a wide skinny  
NSTextView along the bottom. Set the resizing behavior so it's  
attached to the left, bottom and right edges but stretches  
horizontally. You'll want to make the text non-editable and non- 
selectable.


Then just declare an NSTextView* as an IBOutlet in your window  
controller class, and wire a connection from that outlet to the text  
field. At runtime you can call -setStringValue: on that instance  
variable to change the status message.


—Jens

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

Re: WebKit, programmatic form input, form submits

2008-07-20 Thread Jens Alfke


On 20 Jul '08, at 9:39 AM, Diop Mercer wrote:


Hi, I've been playing with WebKit, and I've written a Cocoa app that
brings up a site in a WebView. That was easy, but now I'd like to go
to a site with a form and have the Cocoa app fill in the form fields
and submit the form.  Can anyone point me to documentation on how to
programmatically fill in web forms using WebKit? And also how to
programmatically click buttons?


Read "Using the Document Object Model From Objective-C" in the "WebKit  
Objective-C Programming Guide".


file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/DOMObjCBindings.html

—Jens

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

Re: How to get cursor text from a Mac window

2008-07-20 Thread Jens Alfke


On 19 Jul '08, at 5:00 AM, Gang Chen wrote:

I am new to Cocoa and Mac dev, and I want to make a simple  
dictionary program with Cocoa on MacOSX. Can anybody help and tell  
me how to get any words on screen where cursor points in Cocoa?


I'm not exactly sure how the built-in Dictionary app does this; I  
think it's using the accessibility or screen-reading system APIs. This  
doesn't seem like something you'd want to get into as a newbie Cocoa  
developer. I would advise focusing on building regular apps for a  
while until you get comfortable with Cocoa, before starting on things  
that interact with other applications.


—Jens



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

Re: Drawer examples?

2008-07-20 Thread Jens Alfke


On 19 Jul '08, at 1:53 PM, Ashley Perrien wrote:

am having no luck with getting the custom view within the drawer to  
redraw except by closing and reopening it. I throw setNeedsDisplay:  
YES at it from everywhere I can think of and it just won't redraw.


Usually when something like this happens, the outlet that points to  
the view didn't get wired up, and so its value is nil. (Messages to  
nil are no-ops.) Try adding an assertion before the call, like

NSAssert(_customView!=nil,@"Outlet isn't wired up");
[_customView setNeedsDisplay: YES];

—Jens

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

Re: Redrawing CALayer subclass when super layer is scaled

2008-07-20 Thread Rick Mann


On Jul 16, 2008, at 16:23:23, David Duncan wrote:

Can't really say what you are or are not seeing here, I'd probably  
have to see code. If this is critical, I'd recommend filing a DTS  
incident.



David, I checked my code again, and realized I was setting the bias to  
1 (I thought I saw that in a sample). I don't really understand how  
the numbers are interpreted, but when I set it higher (4, and then  
10), my layers started getting redrawn.


However, I'm seeing some incorrect drawing behavior as I zoom in. I  
made a movie demonstrating this:


http://roderickmann.org/stuff/XcodeScreenSnapz001.mov

Any idea what I'm seeing?

TIA,


--
Rick

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: drawRect doesn't get called when using CoreAnimation?

2008-07-20 Thread Gordon Apple
OK, now that is at least the type of definitive statement I've been
looking for.  (I have recently opened a discussion with DTS on some of these
issues.)  So apparently, there are some things internal that change when you
call "setLayer" besides just the layer?

I have also figured out (and had confirmed in the archives) that if you
want to use layers in a scrollable view, the scroll view (or at least the
clip view) better be layer backed.  But that implies that the scrollable
view will also automatically be layer backed.  Apparently, that changes when
you do "setView" on it that makes it layer-hosting?

Then that raises the question of what happens to the view's layer when
you change the frame of the main (scrollable) view?  Does it automatically
resize?  Or should you programatically resize the layer?  Or just replace it
using setView again to set it's frame to the new view frame size?


On 7/20/08 4:33 PM, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

> If you're using layer-backed views (you set wants layer, but not the
> layer) you should only use view drawing code. You should not add
> layers to it. In fact, ignore the layers entirely.
> 
> If you're using layer-hosting (you create the layer and set it for the
> view, then turn on wants layer) you should only use layer drawing
> code. You should ignore the view drawRect: entirely. You should not
> add subviews to the hosting view.

G. Apple



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: drawRect infinite loop -- argh!

2008-07-20 Thread Bill Bumgarner

On Jul 20, 2008, at 11:52 AM, Brian Hughes wrote:

Thread 2
-[LNTab3View drawRect:] at LNTab3View.m:52
-[NSView _drawRect:clip:]
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
_lightWeightRecursiveDisplayInRect2
CFArrayApplyFunction
-[NSView _lightWeightRecursiveDisplayInRect:]
-[NSButtonCell(NSDefaultButtonIndicatorPrivate) heartBeat:]
-[NSWindow(NSWindow_Theme) heartBeat:]
-[NSUIHeartBeat _heartBeatThread:]

And so it begins again.

Maybe the problem is obvious to you guys but it is not to me.  Any  
help would be great.


Are you doing anything during the drawing that calls -setNeedsDisplay:  
or otherwise makes the view hierarchy think that regions have been  
invalidated?


The actual bug may not be in LNTab3View's -drawRect:.  That particular  
method may just be a symptom.  The actual cause might be something  
somewhere that is invalidating the drawing during the view hierarchy  
refresh.


Explicit calls to -display could cause this, too.

b.bum



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

Newbie CALayer Questions

2008-07-20 Thread Bob Barnes

hi,

   I have some questions related to CALayer drawing. I want to be able 
to display images, text, 2D graphics or a PDF page. I'm able to display 
an image by directly setting the contents property using a CGImageRef 
or subclassing CALayer, overriding display and sending setNeedsDisplay, 
but nothing I do seems to trigger the call to drawInContext. I've tried 
using a delegate for the CALayer and  subclassing CALayer, but 
drawInContext never gets called. Is there something fundamental that 
I'm missing?


tia,

Bob
 
  


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie CALayer Questions

2008-07-20 Thread Jens Alfke


On 20 Jul '08, at 5:00 PM, Bob Barnes wrote:

  I have some questions related to CALayer drawing. I want to be  
able to display images, text, 2D graphics or a PDF page. I'm able to  
display an image by directly setting the contents property using a  
CGImageRef or subclassing CALayer, overriding display and sending  
setNeedsDisplay, but nothing I do seems to trigger the call to  
drawInContext. I've tried using a delegate for the CALayer and   
subclassing CALayer, but drawInContext never gets called. Is there  
something fundamental that I'm missing?


I've found that you can't have both content and custom drawing; if you  
set the layer's content property, its drawInContext: method won't be  
called. Maybe that explains it?


—Jens

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

Re: NSThread and UI

2008-07-20 Thread Chris Hanson

On Jul 20, 2008, at 2:01 PM, Torsten Curdt wrote:

So in the following naive code I would have to either wrap the calls  
to the progressIndicator object through a  
performSelectorOnMainThread or could send NSNotifications to update  
it on the main thread.


Notifications — whether via NSNotificationCenter or Key-Value  
Observing — are synchronous.  Thus they're delivered in the same  
thread in which they're posted, which in multi-threaded code generally  
isn't what you want.


I am also wondering whether using NSRunCriticalAlertPanel() in the  
thread is OK or not.


I wouldn't.  Even if you can do it, it's probably a layering  
violation.  Your operation is generally happening at the model level,  
so you shouldn't directly do UI from it.


Instead of using -[NSObject  
detachNewThreadSelector:toTarget:withObject:] to encapsulate all of  
the threaded operation into one method, I'd create a separate object  
to do that stuff, and I'd give it a delegate, notification, or KVO API  
for things like progress updates that the UI can observe.


For example, the API might look like this:

  @protocol ConversionOperationDelegate;

  @interface ConversionOperation : NSObject {
  id delegate;
  float progress;
  // and any other properties, of course
  }

  - (id)init;

  @property(readwrite, assign) id  
delegate;
  // other properties too, of course, for set-up before starting the  
conversion


  - (void)start;

  @property(readonly) float progress;
  // a property that can be bound to and that gets updated on the  
main thread


  @end

  @protocol ConversionOperationDelegate 
  @required
  - (void)conversionOperation:(ConversionOperation *)operation  
encounteredError:(NSError *)error;


  @optional
  - (void)conversionOperationDidStart:(ConversionOperation *)operation;
  - (void)conversionOperationDidFinish:(ConversionOperation  
*)operation;

  @end

I would use -[NSObject  
performSelectorOnMainThread:withObject:waitUntilDone:] to actually  
invoke the internal-to-ConversionOperation methods that wind up  
invoking delegate methods and changing the progress property, so don't  
have to worry about things happening on the background thread.


Note that if you're targeting Leopard or later, you can use  
NSOperation to encapsulate some of this.  However, you'll still have  
to use techniques like - 
performSelectorOnMainThread:withObject:waitUntilDone: to update your  
detailed progress information in a way that doesn't cause thread- 
synchronization issues.


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


Re: Newbie CALayer Questions

2008-07-20 Thread Bob Barnes

On Jul 20, 2008, at 5:06 PM, Jens Alfke wrote:



On 20 Jul '08, at 5:00 PM, Bob Barnes wrote:

  I have some questions related to CALayer drawing. I want to be able 
to display images, text, 2D graphics or a PDF page. I'm able to 
display an image by directly setting the contents property using a 
CGImageRef or subclassing CALayer, overriding display and sending 
setNeedsDisplay, but nothing I do seems to trigger the call to 
drawInContext. I've tried using a delegate for the CALayer and  
subclassing CALayer, but drawInContext never gets called. Is there 
something fundamental that I'm missing?


I've found that you can't have both content and custom drawing; if you 
set the layer's content property, its drawInContext: method won't be 
called. Maybe that explains it?


—Jens


   I should have been clearer. The CALayer is question has its contents 
property set to nil. Calling setNeedsDisplay results in the display 
method being called, but not the drawInContext method.


Bob

___

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

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

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

This email sent to [EMAIL PROTECTED]


Unarchiving a plugin custom control

2008-07-20 Thread Anders Lassen

Hi,

I am working on a custom control, which has a few simple properties.

The object is a subclass of NSBox, and is therefore initialized with  
initWithCoder.


When the object is created for the first time and nothing has been  
saved to the archive, all properties are set to zero values.


My problem is that I would like to bypass the decoding when the achive  
is "empty", and assign other default values (than zero).


I wonder whether this is possible?


___

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

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

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

This email sent to [EMAIL PROTECTED]


Design question, which controller class to use

2008-07-20 Thread James W. Walker
I have these windows, each of which has a table displaying data from  
an array of dictionaries.  The data is never stored on disk, so I  
don't think of these windows as "documents".  Since there is a window  
(which has a title that depends on the data) I thought I should use a  
subclass of NSWindowController.  On the other hand, there is an array  
being displayed in a table, and I gather that's easier to set up using  
bindings if I use an NSArrayController.  Any suggestions or references?

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Design question, which controller class to use

2008-07-20 Thread Jens Alfke


On 20 Jul '08, at 8:05 PM, James W. Walker wrote:

Since there is a window (which has a title that depends on the data)  
I thought I should use a subclass of NSWindowController.  On the  
other hand, there is an array being displayed in a table, and I  
gather that's easier to set up using bindings if I use an  
NSArrayController.  Any suggestions or references?


Those are two very different types of controllers, and you should  
probably use both.
An NSWindowController helps manage a window. It's a good idea to use  
these for all non-document windows. This will be the "file's owner" in  
your nib.
An NSArrayController manages an NSArray and lets you bind GUI controls  
to it. So you'd probably put one of those in your nib as well, to help  
run your table.


—Jens

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

RE: setting image for person in address book

2008-07-20 Thread Vijay Kanse
I have Tried initWithContentsOfURL. But I am getting exception.
NSData *imageData = [[NSData alloc] initWithContentOfURL:@"
file://localhost/volumes/DATA/image/ 
> play.tiff "];

What Might be problem with That ?
Is there any other problem with my code ?

Thank You.


-Original Message-
From: Heinrich Giesen [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 19, 2008 6:24 PM
To: cocoa-dev@lists.apple.com
Cc: Vijay Kanse
Subject: Re: setting image for person in address book


On 19.07.2008, at 13:35, Vijay Kanse wrote:

> NSData *imageData = [[NSData alloc]
> initWithContentsOfFile:@"file://localhost/volumes/DATA/image/ 
> play.tiff"]
> ;


> I am tracing program and I am not getting any value in imageData.
>


In your program the parameter of -initWithContentsOfFile: is not a  
file, it's an URL.
Try to read instead with -initWithContentsOfURL:


-- 
Heinrich Giesen
[EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: setting image for person in address book

2008-07-20 Thread Kyle Sluder
On Sun, Jul 20, 2008 at 11:40 PM, Vijay Kanse <[EMAIL PROTECTED]> wrote:
> I have Tried initWithContentsOfURL. But I am getting exception.

It's -initWithContentsOfURL, not -initWithContentOfURL: as your code
seems to indicate.  And in the future, if you are getting errors or
exceptions, you need to paste those in; nobody on this list can read
minds.

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


RE: setting image for person in address book

2008-07-20 Thread Vijay Kanse
I am getting the Image set for the Person.
I was Missing to write [NSURL URLWithString@"url path"].

Thank You.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Kyle Sluder
Sent: Monday, July 21, 2008 9:39 AM
To: Vijay Kanse
Cc: Heinrich Giesen; cocoa-dev@lists.apple.com
Subject: Re: setting image for person in address book

On Sun, Jul 20, 2008 at 11:40 PM, Vijay Kanse <[EMAIL PROTECTED]>
wrote:
> I have Tried initWithContentsOfURL. But I am getting exception.

It's -initWithContentsOfURL, not -initWithContentOfURL: as your code
seems to indicate.  And in the future, if you are getting errors or
exceptions, you need to paste those in; nobody on this list can read
minds.

--Kyle Sluder
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie CALayer Questions

2008-07-20 Thread Brian Christensen

On Jul 20, 2008, at 20:00, Bob Barnes wrote:

  I have some questions related to CALayer drawing. I want to be  
able to display images, text, 2D graphics or a PDF page. I'm able to  
display an image by directly setting the contents property using a  
CGImageRef or subclassing CALayer, overriding display and sending  
setNeedsDisplay, but nothing I do seems to trigger the call to  
drawInContext. I've tried using a delegate for the CALayer and   
subclassing CALayer, but drawInContext never gets called. Is there  
something fundamental that I'm missing?


Is the needsDisplayOnBoundsChange property set to YES on your layer?

/brian



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

how to prevent baseline shift when using NSSuperscriptAttributeName on a NSTextView's NSAttributedString ?

2008-07-20 Thread Rua Haszard Morris
I am using NSSuperscriptAttributeName to make part of a string  
displayed in an NSTextView label display as superscript (to show "to  
the power of 2"). I may also use a smaller font attribute to make the  
"2" char smaller.


My problem is that thebaseline of the text drawn in the NSTextView is  
moved down (presumably to accommodate the superscript 2) and the label  
now looks wrong as the text doesn't line up with the other edits and  
labels on the line in the dialog.


Is there a correct, standard way to keep the baseline fixed when using  
an NSAttributedString in a NSTextView used as a label?


I've tried using a multi-line NSTextView, but this makes no  
difference. There is the possibility of tweaking the  
NSBaselineAttribute, or even the position of the NSTextView, but both  
approaches seem hacky or overkill (i.e. I'd need to correctly  
determine the baseline offset by querying the font superscript offset?  
and converting to pixels?)


thanks
Rua HM.
___

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

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

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

This email sent to [EMAIL PROTECTED]


ikimagebrowserview + bindings

2008-07-20 Thread Duncan Campbell
Does anyone know of any example code that demonstrate  
IKImageBrowserView working with bindings?


Cheers in advance,

Duncan.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-20 Thread Rick Mann


On Jul 16, 2008, at 16:23:23, David Duncan wrote:

This is also why when you scale up a CALayer its content its content  
looks interpolated - its the same number of pixels as before, just  
interpolated larger. If you exceed the maximum LOD of a tiled layer,  
you will see the same thing (which if you don't set a LOD bias means  
if you scale a tiled layer above 1.0 it will also have its content  
interpolated).



So why is it that when setting a CALayer's (not CATiledLayer)  
background color, corner and border properties, those render  
beautifully, no matter what the scale of the parent layer? Clearly, at  
some point, Quartz is getting called to fill & stroke the layer's  
frame with the appropriate CTM in place for it to appear as it does  
(scaled & rotated). I wish I could get it to do the same for my  
drawing code.


--
Rick

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: drawRect doesn't get called when using CoreAnimation?

2008-07-20 Thread Scott Anguish


On 20-Jul-08, at 7:21 PM, Gordon Apple wrote:


   OK, now that is at least the type of definitive statement I've been
looking for.  (I have recently opened a discussion with DTS on some  
of these
issues.)  So apparently, there are some things internal that change  
when you

call "setLayer" besides just the layer?


I can't speak to the specifics, I've not investigated if fully.




   I have also figured out (and had confirmed in the archives) that  
if you
want to use layers in a scrollable view, the scroll view (or at  
least the
clip view) better be layer backed.  But that implies that the  
scrollable
view will also automatically be layer backed.  Apparently, that  
changes when

you do "setView" on it that makes it layer-hosting?


if a view in a view hierarchy is configured as layer-backed, all  
subviews are (this is currently only documented in the Animation  
Overview, Hybrid Apps section... this will be fixed shortly.





   Then that raises the question of what happens to the view's layer  
when
you change the frame of the main (scrollable) view?  Does it  
automatically
resize?  Or should you programatically resize the layer?  Or just  
replace it

using setView again to set it's frame to the new view frame size?


haven't investigated this either.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Newbie CALayer Questions

2008-07-20 Thread Scott Anguish
that shouldn't be an issue if he's explicitly calling the  
setNeedsDisplay


is the method signature correct on your implementation of  
drawInContext:?




On 21-Jul-08, at 12:22 AM, Brian Christensen wrote:


On Jul 20, 2008, at 20:00, Bob Barnes wrote:

 I have some questions related to CALayer drawing. I want to be  
able to display images, text, 2D graphics or a PDF page. I'm able  
to display an image by directly setting the contents property using  
a CGImageRef or subclassing CALayer, overriding display and sending  
setNeedsDisplay, but nothing I do seems to trigger the call to  
drawInContext. I've tried using a delegate for the CALayer and   
subclassing CALayer, but drawInContext never gets called. Is there  
something fundamental that I'm missing?


Is the needsDisplayOnBoundsChange property set to YES on your layer?



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-20 Thread Scott Anguish


On 21-Jul-08, at 1:20 AM, Rick Mann wrote:



On Jul 16, 2008, at 16:23:23, David Duncan wrote:

This is also why when you scale up a CALayer its content its  
content looks interpolated - its the same number of pixels as  
before, just interpolated larger. If you exceed the maximum LOD of  
a tiled layer, you will see the same thing (which if you don't set  
a LOD bias means if you scale a tiled layer above 1.0 it will also  
have its content interpolated).



So why is it that when setting a CALayer's (not CATiledLayer)  
background color, corner and border properties, those render  
beautifully, no matter what the scale of the parent layer? Clearly,  
at some point, Quartz is getting called to fill & stroke the layer's  
frame with the appropriate CTM in place for it to appear as it does  
(scaled & rotated). I wish I could get it to do the same for my  
drawing code.


all the visual properties that are 'animatable' are applied at render  
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 [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-20 Thread Rick Mann


On Jul 20, 2008, at 22:44:37, Scott Anguish wrote:

all the visual properties that are 'animatable' are applied at  
render time.



Thanks for that answer, Scott.

So, can I not make my own drawing code an animatable property? I  
thought I could.


I was really hoping I would be able to do this:

1. Define arbitrary properties
2. Have CA interpolate to new values of those properties
3. Have CA call me to draw the contents, which I would do based on the  
"current" (mid-animation) value of those properties.
3a. Have my drawing environment set up to draw at the destination  
resolution.


I'm not even sure I see a way to do that by writing my own animators &  
renderers (I can't figure out how to subclass CARenderer, anyway).



--
Rick

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-20 Thread Scott Anguish


On 21-Jul-08, at 1:52 AM, Rick Mann wrote:



On Jul 20, 2008, at 22:44:37, Scott Anguish wrote:

all the visual properties that are 'animatable' are applied at  
render time.



Thanks for that answer, Scott.

So, can I not make my own drawing code an animatable property? I  
thought I could.


Nope. That is entirely private.

The reason I had mentioned the animatable properties is because those  
visuals (including background color and the border) are not scaled the  
same as your content, since they aren't cached..



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Redrawing CALayer subclass when super layer is scaled

2008-07-20 Thread Rick Mann


On Jul 20, 2008, at 22:57:12, Scott Anguish wrote:


Nope. That is entirely private.

The reason I had mentioned the animatable properties is because  
those visuals (including background color and the border) are not  
scaled the same as your content, since they aren't cached..



Okay, thanks for the info. I think it's clear that I cannot really use  
CA for my drawing, which is a pity. It seems like it's "really close"  
to giving me what I want, but in the end, doesn't.


I might still get what I need from CATiledLayer, if the drawing  
glitches I posted about earlier can be resolved.


Thanks again.

--
Rick

___

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

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

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

This email sent to [EMAIL PROTECTED]


NSWindowController getting over-released by NSDocument?

2008-07-20 Thread Markus Spoettl

Hi List,

  I'm having some problems with memory management of a window  
controller in a standard NSDocument based application. The problem is  
that my window controller gets released through an autorelease pool  
after the document has been deallocated (and released it in the  
process).


I've overwritten release and retain on the this window controller be  
able to examine the retain/release cycle. Unfortunately overwriting - 
autorelease does not work (contrary to -retain and -release) so I  
can't break when it's being put into the autorelease pool (why I don't  
know).


My document is creating the window controller in

- (void)makeWindowControllers
{
controller = [[RubiWindowController alloc]  
initWithWindowNibName:@"RubiDocument"];

[controller setShouldCloseDocument:YES];
[self addWindowController:controller];

}

and releases it in -dealloc:

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

Until here everything is balanced. The release here causes the  
controller's -dealloc: being executed.


However after this, an autorelease pool releases it again, which  
causes a EXC_BAD_ACCESS crash:


#0  0x949e36e8 in objc_msgSend
#1  0x94078cb6 in CFArrayApplyFunction
#2  0x9574d305 in -[NSView _recursiveBreakKeyViewLoop]
#3  0x94078cb6 in CFArrayApplyFunction
#4  0x9574d305 in -[NSView _recursiveBreakKeyViewLoop]
#5  0x94078cb6 in CFArrayApplyFunction
#6  0x9574d305 in -[NSView _recursiveBreakKeyViewLoop]
#7  0x9574bbe9 in -[NSWindow dealloc]
#8  0x9539e57f in NSPopAutoreleasePool
#9  0x956e2e54 in -[NSApplication run]
#10 0x956b0030 in NSApplicationMain
#11 0x3946 in main at main.m:13

I've tried both settings of "Releases when closed" in IB, but it  
crashes regardless of this setting.


Am I not supposed to release the window controller in the document  
even though I create it?


Thanks for any pointers!

Regards
Markus
--
__
Markus Spoettl



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

This email sent to [EMAIL PROTECTED]