Re: How to update table while in a method

2009-11-12 Thread Graham Cox

On 13/11/2009, at 6:20 PM, Ashley Perrien wrote:

> But it seems that the table refuses to redraw until after everything has been 
> updated. So when I do this process, I get the spinning cursor for a few 
> second (looks like it hung) and then the table updates. I'd prefer the table 
> to update as information comes in. Note that I'm not using any bindings in 
> this. 

The redraw is done once per event loop. Since in your simple loop the event 
loop isn't being run, you don't see anything happen. Naive loops like this are 
useless for lengthy tasks that depend on some external resource like a server, 
which might not return anything at all - in which case you've just hung your 
app.

> I tried spinning off the table update into a new NSOperationQueue and that 
> didn't help so I'm assuming spinning the resource update to another queue 
> also wouldn't help either. Any suggestions?

I'm assuming [resource updateInfo] does something network-y to get information 
from the web? In which case that should be handled asynchronously. As each 
result comes in you can call reloadData on the table. Asynchronous handling of 
the internet doesn't require a separate thread - I believe NSURLConnection does 
its thing as part of the normal run loop. But if it were on a thread, the table 
update would have to be called on the main thread, as it's an interface object, 
i.e. using -performSelectorOnMainThread:waitUntilDone:

The documentation and companion guides for NSURLConnection should get you 
started.

--Graham


___

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

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

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

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


How to update table while in a method

2009-11-12 Thread Ashley Perrien
I have an application that has a table of various internet resources and 
information on them. What I would like to be able to do is:

for (netResource *resource in anArrayOfResources) {
[resource updateInfo];
[resultsTable reloadData];
}

But it seems that the table refuses to redraw until after everything has been 
updated. So when I do this process, I get the spinning cursor for a few second 
(looks like it hung) and then the table updates. I'd prefer the table to update 
as information comes in. Note that I'm not using any bindings in this. 

I tried spinning off the table update into a new NSOperationQueue and that 
didn't help so I'm assuming spinning the resource update to another queue also 
wouldn't help either. Any suggestions?

Ashley

___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread Jerry Krinock


On 2009 Nov 12, at 14:24, Kyle Sluder wrote:


No.  Do not do this.  Follow the pattern of BetterAuthorizationSample:
http://developer.apple.com/mac/library/samplecode/BetterAuthorizationSample/listing4.html


Yes, what Kyle says is true.  AEWP is not recommended.

Now, thought, the *correct* way, integrating BetterAuthorizationSample  
into an app is a *lot* of work.  However, there is a very slick  
shortcut for which I credit Jean-Daniel Dupas:  If possible, send the  
Finder an AppleEvent instructing it to do the work for you.  In this  
case, for example, you might be able to ask Finder to copy that file  
from /Library to the user's temporary directory.  Now, if elevated  
privileges are needed, Finder should interface with Authorization  
Services to put up the authentication dialog, doing all of the heavy  
lifting.


___

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

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

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

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


Re: Array of dictionaries containing NSColor in NSUserDefaults

2009-11-12 Thread Martin Hewitson

On Nov 13, 2009, at 6:58 AM, Graham Cox wrote:

> 
> On 13/11/2009, at 4:41 PM, Martin Hewitson wrote:
> 
>> The point is to store an array of 'items' with a 'name' together with a 
>> 'color'. And later there may be more properties of an 'item'. 
> 
> 
> This really calls for your own 'item' class that holds all the various 
> properties that you have in mind. You can then easily bind to any property, 
> and the class becomes a strict "template" for the valid properties of the 
> item. A dictionary is open-ended and can't be made to conform to a common 
> template. You will therefore be doing a lot of extra work to force it to fit 
> your design when a simple class is sufficient. Make it NSCoding compliant for 
> easy archiving to NSUserDefaults.
> 

Oh yes, this is a much nicer idea. Actually, the dictionary items are meant to 
stand for defaults of an NSManagedObject class. I guess I can just make that 
class conform to NSCoding and go from there. I'd read somewhere that it was a 
bad idea to make a subclass of NSManagedObject conform to NSCoding, but I don't 
recall the rational behind that. Anyway, for this very simple object (entity) 
it seems like the way to go.

Again, thanks for your thoughts on this!

Martin


> KVC makes the ordinary properties of an object "look like" a kind of 
> dictionary, but forcing an actual NSDictionary to stand in for an object is 
> often quite painful and more hassle than it's worth just to save implementing 
> a simple class, or to gain some minor functionality for free, such as 
> archiving. As it stands an 'item' class with two properties shouldn't take 
> very long to code - you'll be glad you did.
> 
> --Graham
> 
> 


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

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

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

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


Re: Array of dictionaries containing NSColor in NSUserDefaults

2009-11-12 Thread Graham Cox

On 13/11/2009, at 4:41 PM, Martin Hewitson wrote:

> The point is to store an array of 'items' with a 'name' together with a 
> 'color'. And later there may be more properties of an 'item'. 


This really calls for your own 'item' class that holds all the various 
properties that you have in mind. You can then easily bind to any property, and 
the class becomes a strict "template" for the valid properties of the item. A 
dictionary is open-ended and can't be made to conform to a common template. You 
will therefore be doing a lot of extra work to force it to fit your design when 
a simple class is sufficient. Make it NSCoding compliant for easy archiving to 
NSUserDefaults.

KVC makes the ordinary properties of an object "look like" a kind of 
dictionary, but forcing an actual NSDictionary to stand in for an object is 
often quite painful and more hassle than it's worth just to save implementing a 
simple class, or to gain some minor functionality for free, such as archiving. 
As it stands an 'item' class with two properties shouldn't take very long to 
code - you'll be glad you did.

--Graham


___

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

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

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

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


Re: Array of dictionaries containing NSColor in NSUserDefaults

2009-11-12 Thread Martin Hewitson

On Nov 13, 2009, at 1:39 AM, Graham Cox wrote:

> 
> On 13/11/2009, at 8:18 AM, Martin Hewitson wrote:
> 
>> Has anyone tried something like this, or can anyone see what I'm doing wrong?
> 
> 
> I'm a bit mystified by your data structure here. Why do you use a separate 
> dictionary for each key/value pair (name/colour pair)? Why not just use one 
> dictionary for the list of colours, and add that as a single item to the user 
> defaults? It would be much simpler and efficient, and probably less prone to 
> difficult to understand code paths as you'd have one less level of 
> indirection (or possibly two less - you wouldn't need the array either).

The point is to store an array of 'items' with a 'name' together with a 
'color'. And later there may be more properties of an 'item'. 

Martin

> 
> I expect the problem is because the changes you're making are an extra level 
> of indirection inside the data structure and are not being observed by the 
> user defaults binding. I could be wrong though as bindings is not something 
> I'm very intimate with.
> 
> Also, check out whether NSColorList will do what you need here - it already 
> maintains lists of named colours.
> 
> --Graham
> 
> 


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

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

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

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


Re: Auto-scrolling view

2009-11-12 Thread Graham Cox

On 13/11/2009, at 1:25 PM, Symadept wrote:

> How to design Auto-scrolling view. Any pointers are highly appreciable.


[NSView autoscroll:]

If that isn't appropriate, I refer you to my earlier reply to another message 
you posted:

http://catb.org/~esr/faqs/smart-questions.html

--Graham


___

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

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

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

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


Re: can't read NSMenuItem titles from NSMenu's below first NSMenu

2009-11-12 Thread Graham Cox

On 13/11/2009, at 2:09 PM, SRD wrote:

> When selecting anything off the first menu (item-2 or item-3), the
> value of 'sender' prints fine and I can compare it using the code
> below. But if I select the first item which is an NSMenu and leads to
> another NSMenu with it's item (item-1), then the method menuReader: is
> called, but sender does not hold any value at all, it's just blank.
> 
> Anyone understand what I'm doing wrong here?
> 
> - (IBAction) menuReader:(id) sender
> {
>NSLog(@"sender %@", [sender titleOfSelectedItem]);
> 
>   if ([[sender titleOfSelectedItem] isEqualToString:@"item1"]) {
>   // ...
>   }
>   else if ([[sender titleOfSelectedItem] isEqualToString:@"item2"]) {
>   // ...
>   }
>   else if ([[sender titleOfSelectedItem] isEqualToString:@"item3"]) {
>   // ...
>   }
> }
> 
> Any help much appreciated.


You are calling [sender titleOfSelectedItem], but for the submenu, the sender 
isn't the pop-up button so it doesn't respond to that message. Why not log what 
the sender actually is, and you'll see what's going on:

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

--Graham


___

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

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

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

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


can't read NSMenuItem titles from NSMenu's below first NSMenu

2009-11-12 Thread SRD
I have an NSPopUpButton of type pulldown with the following structure:

NSMenu
|- NSMenu ---> item-1  // can't read value from sender
|- item-2 // can read sender
|- item-3 // can read sender

When selecting anything off the first menu (item-2 or item-3), the
value of 'sender' prints fine and I can compare it using the code
below. But if I select the first item which is an NSMenu and leads to
another NSMenu with it's item (item-1), then the method menuReader: is
called, but sender does not hold any value at all, it's just blank.

Anyone understand what I'm doing wrong here?

- (IBAction) menuReader:(id) sender
{
NSLog(@"sender %@", [sender titleOfSelectedItem]);

if ([[sender titleOfSelectedItem] isEqualToString:@"item1"]) {
// ...
}
else if ([[sender titleOfSelectedItem] isEqualToString:@"item2"]) {
// ...
}
else if ([[sender titleOfSelectedItem] isEqualToString:@"item3"]) {
// ...
}
}

Any help much appreciated.
___

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

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

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

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


All Address Book person unique IDs are the same [solved]

2009-11-12 Thread Greg Hoover
I extended NSManagedObject to provide a uniqueId accessor similar to that of 
ABRecord.  Turns out that this messed with the uniqueId accessor of ABRecord.  
The docs don't say that ABRecord inherits from NSManagedObject but somewhere 
they do I guess (it seems reasonable that they would)...lesson learned.

___

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

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

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

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


Auto-scrolling view

2009-11-12 Thread Symadept
How to design Auto-scrolling view. Any pointers are highly appreciable.

Regards
symadept
___

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

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

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

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


Re: Possible hardware-platform-dependent bug in NSTextView?!?

2009-11-12 Thread Jay Reynolds Freeman
The instance of my subclass of NSTextView in question is narrow
from top to bottom; there is only room for one line.  When the
unexpected scrolling happens, the place where the user was typing
-- where the cursor and insert point are -- scrolls out of
sight off the bottom of the view.  This is most confusing, not
what is wanted, and not what happens in my own Macintoshes.

--  Jay Reynolds Freeman
-
jay_reynolds_free...@mac.com
http://web.mac.com/jay_reynolds_freeman (personal web site)


On Nov 12, 2009, at 3:37 PM, Kyle Sluder wrote:

On Thu, Nov 12, 2009 at 3:31 PM, Jay Reynolds Freeman
 wrote:
> The bug occurs when a user is typing into an instance of a
> subclass of NSTextView that I have created.  (Side issue:  I
> do believe I had good reason to subclass rather than to use a
> delegate, details on request.)  On some platforms, it appears
> that the following happens:

Please do elaborate.

>   The view scrolls by one line.  The direction of
>   scroll is that if the insert cursor was 10 cm
>   up from the bottom of the screen before the 'space',
>   it will appear at 9.something cm up from the bottom
>   of the screen after the 'space' has been typed.

I don't see how this is a bug.  Could one of your users provide a
before/after screenshot?  Sounds to me like NSTextView is just
reorienting itself so that the line is completely visible.  Perhaps
I'm just misunderstanding.

--Kyle Sluder

___

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

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

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

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


Re: Array of dictionaries containing NSColor in NSUserDefaults

2009-11-12 Thread Matt Mashyna

Are you calling setObject and sync with   NSUserdefaults at some point?


Matt

Sent from my iPhone

On Nov 12, 2009, at 4:18 PM, Martin Hewitson  
 wrote:



Dear list,

The hardest part of this problem may be explaining it, but here goes.

I want to store an array of dictionaries in NSUserDefaults. In each  
dictionary I have a string and a color. The color is stored as data  
using NSArchiver.


So I build an array of these dictionaries, then put that array in  
another dictionary, which becomes the registered defaults.


So in my app delegate +initialize: I have something like:

   NSMutableDictionary *item1 = [[[NSMutableDictionary alloc]  
initWithCapacity:1] autorelease];
   NSMutableDictionary *item2 = [[[NSMutableDictionary alloc]  
initWithCapacity:1] autorelease];

   [item1 setValue:@"name1" forKey:@"name" ];
   [item1 setValue:[NSArchiver archivedDataWithRootObject:[NSColor  
blueColor]] forKey:@"color"];

   [item2 setValue:@"name1" forKey:@"name" ];
   [item2 setValue:[NSArchiver archivedDataWithRootObject:[NSColor  
redColor]] forKey:@"color"];


   NSArray *catArray = [NSArray arrayWithObjects:item1,item2, nil];

   // add defaults to dictionary
   NSMutableDictionary *defaultValues = [NSMutableDictionary  
dictionary];

   [defaultValues setObject:catArray forKey:@"MyItemList"];

   // register the defaults
   [[NSUserDefaults standardUserDefaults]  
registerDefaults:defaultValues];


Now comes the UI. I have a nib with a preferences panel. On the  
panel I have a table with two columns: one for 'name' and one for  
'color'. So I put an array controller in the nib and bind it to  
userdefaults.values.MyItemList with the 'Handles Content As Compound  
Value' field checked (I read somewhere this was necessary). Then I  
bind the columns of the table to the array controller. For the  
'color' column I have a value transformer NSUnarchiveFromData. The  
'color' column uses a custom cell which fires a callback in the  
preferences controller to launch a color panel. The action of the  
color panel is set to the following selector:


- (void) colorChanged: (id) sender
{
   NSArray *items = [itemArrayController arrangedObjects];
   NSDictionary *item = [items objectAtIndex:[defaultItemsTable  
selectedRow] ];
   [item setValue:[NSArchiver archivedDataWithRootObject:[sender  
color]] forKey:@"color"];

   [defaultItemsTable setNeedsDisplay:YES];
}

Now the problem. I can change the 'name' values and they stay  
changed between app launches. I can change colors and they change in  
the table, no problem. However, the new colors are not written to  
the user defaults. So if I relaunch the app the colors are back to  
the factory defaults. If I try to access the user defaults during  
the same running instance of the app, they are still the factory  
defaults. I can also add new items to the array controller, and they  
appear as they should on app relaunch. It's just the colors that are  
causing trouble.


Has anyone tried something like this, or can anyone see what I'm  
doing wrong?


Thanks in advance,

Martin



Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
   Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

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

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

This email sent to a...@frodis.com


___

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

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

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

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


Re: Array of dictionaries containing NSColor in NSUserDefaults

2009-11-12 Thread Graham Cox

On 13/11/2009, at 8:18 AM, Martin Hewitson wrote:

> Has anyone tried something like this, or can anyone see what I'm doing wrong?


I'm a bit mystified by your data structure here. Why do you use a separate 
dictionary for each key/value pair (name/colour pair)? Why not just use one 
dictionary for the list of colours, and add that as a single item to the user 
defaults? It would be much simpler and efficient, and probably less prone to 
difficult to understand code paths as you'd have one less level of indirection 
(or possibly two less - you wouldn't need the array either).

I expect the problem is because the changes you're making are an extra level of 
indirection inside the data structure and are not being observed by the user 
defaults binding. I could be wrong though as bindings is not something I'm very 
intimate with.

Also, check out whether NSColorList will do what you need here - it already 
maintains lists of named colours.

--Graham


___

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

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

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

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


Re: How do I get Lucida Grande italic into my application?

2009-11-12 Thread Graham Cox

On 13/11/2009, at 6:37 AM, Eric Gorr wrote:

> My matrix math is a bit rusty...how would I turn that into a series of method 
> calls to NSAffineTransform?


For a skew transform you can't use a series of method calls, you have to fill 
in the transform struct yourself and use -setTransformStruct:

--Graham


___

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

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

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

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


Re: Possible hardware-platform-dependent bug in NSTextView?!?

2009-11-12 Thread Kyle Sluder
On Thu, Nov 12, 2009 at 3:31 PM, Jay Reynolds Freeman
 wrote:
> The bug occurs when a user is typing into an instance of a
> subclass of NSTextView that I have created.  (Side issue:  I
> do believe I had good reason to subclass rather than to use a
> delegate, details on request.)  On some platforms, it appears
> that the following happens:

Please do elaborate.

>       The view scrolls by one line.  The direction of
>       scroll is that if the insert cursor was 10 cm
>       up from the bottom of the screen before the 'space',
>       it will appear at 9.something cm up from the bottom
>       of the screen after the 'space' has been typed.

I don't see how this is a bug.  Could one of your users provide a
before/after screenshot?  Sounds to me like NSTextView is just
reorienting itself so that the line is completely visible.  Perhaps
I'm just misunderstanding.

--Kyle Sluder
___

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

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

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

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


Possible hardware-platform-dependent bug in NSTextView?!?

2009-11-12 Thread Jay Reynolds Freeman
I *think* this is the right group, I would be glad to
take it elsewhere if not.

I have reports from users of a problem which seems to be
dependent on the Mac hardware platform my code is running on.
The bug unfortunately does not seem to occur on any Macintosh
that I happen to own, so it is very hard to investigate.
Before I make an appointment to go into the Apple
Compatibility Lab and start fishing, I thought I would ask
for clues and comments here.

The bug occurs when a user is typing into an instance of a
subclass of NSTextView that I have created.  (Side issue:  I
do believe I had good reason to subclass rather than to use a
delegate, details on request.)  On some platforms, it appears
that the following happens:

1) When there is more than one line of text in the
   instance ...
2) And the insertion point is at the end of the text
   (that is, the next ordinary character typed will
   become the new last character in the text) ...
3) And the user types a blank-space character, then ...

   The view scrolls by one line.  The direction of
   scroll is that if the insert cursor was 10 cm
   up from the bottom of the screen before the 'space',
   it will appear at 9.something cm up from the bottom
   of the screen after the 'space' has been typed.

   That is true whether or not there is any other
   text preceding the new 'space', in the last line
   of the text.

In my subclass, I did override keyDown, but there is nothing
in my code that treats 'space"' in any special way; that is,
it is *very* mystifying why the display scrolls for 'space'
but does not scroll for, e.g., 'a', 'b', 'c', -- they are all
passed through to [super keyDown:theEvent] without any
variation in treatment in my code.

The bug has been reported in both 32-bit and 64-bit versions
of my software (the program "Wraith Scheme") running on in the 
following environments:

  - An iMac 8,1 running MacOS 10.6.1 and (later) 10.6.2
  - A MacBook Pro 5,5, running MacOS 10.6.2

I am quite certain I have not seen it in any version of
Wraith Scheme that I have ever run on any of the following
platforms, which are all the Macintoshes I own:

  - Mac Pro 3,1, running 10.6.0, 10.6.1, 10.6.2, and 
  various 10.5 (both 32- and 64-bit versions of Wraith
  Scheme)
  - Macbook 13 1,1, running various versions of 10.6,
  10.5, and 10.4 (32-bit version of Wraith Scheme
  only, that Macbook won't run 64-bit code).
  - iBook 4,2 (PowerBook 4,2), running various versions
  of 10.4 32-bit version of Wraith Scheme only, that
  iBook won't run 64-bit code).

Has anyone seen or heard of anything like this?

I won't be such a fool as to draw conclusions about the 
cause of this bug at this stage, but it is at least
logically conceivable that Apple's own software for
NSTextView is doing different things on different
platforms, which is why I thought I would bring the
subject up here.

I will of course report a bug to Apple if it continues
to look like something weird in NSTextView.

Thank you very much.

--  Jay Reynolds Freeman
-
jay_reynolds_free...@mac.com
http://web.mac.com/jay_reynolds_freeman (personal web site)


___

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

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

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

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


Re: Multiple variable rules in for() statement

2009-11-12 Thread Jonathon Kuo

On Nov 12, 2009, at 12:14 PM, Greg Parker wrote:


On Nov 12, 2009, at 11:29 AM, Jonathon Kuo wrote:
I can't chance upon the right incantation for using both an  
existing variable and an inline new one in a for loop. I've boiled  
this down to a trivial show case, same results for both gcc 4.0.1  
and 4.2.1:


int i;
 . . .
for (i=0, int m=0; i<5; i++) { . . . };
printf("Final value of i: %d\n",i);

error: syntax error before ‘int’
error: syntax error before ‘)’ token

So I tried this:

int i;
 . . .
for (int m=0,i=0; i<5; i++) { . . . };
printf("Final value of i: %d\n",i);

error: redefinition of ‘i’

Is there a rule that ALL initialized loop variables are either new  
and local to the loop, or that none are? Surely Im doing something  
wrong here!


The first clause of a C99 for loop may be a single expression, or a  
single declaration. `i=0, m=0` is an expression: two assignment  
expressions joined by the comma operator. `int i=0, m=0` is a  
declaration, creating two new integer variables. `i=0, int m=0` is  
invalid; the RHS of that comma is a declaration, but the comma  
operator only allows expressions on both sides.


If you want both variables initialized to the same value, you can  
use this:

   int i;
   for (int m = i = 0; i < 5; i++) { ... }
It's a declaration, whose initializater happens to have the side- 
effect of assigning to another variable.


You can get the two variables initialized to different values:
   int i;
   for (int m = (i = 0, 10); i < 5; i++) { ... }
Again, a declaration with a complicated initializer.

But if you do that, keep in mind this irregular verb form:
   My code is elegant.
   Your code is sneaky.
   His code is an ugly hack.


Okay, so yes, all initialized for loop variables are either new and  
local to the loop, or none are, at least if one wishes to keep with  
legible coding practices. Sort of non-obvious at first glance, but  
makes sense.


Thanks!
Jon

___

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

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

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

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


Re: CGImageRef printing issue

2009-11-12 Thread Shawn Erickson
On Thu, Nov 12, 2009 at 2:26 PM, Mirko Viviani  wrote:

> Do you mean that there is no way to print an image using a grid of 300 PPI 
> with Cocoa/Quartz?
> If not, why? Alternatives?




etc.

-Shawn
___

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

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

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

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


Re: CGImageRef printing issue

2009-11-12 Thread Kyle Sluder
On Thu, Nov 12, 2009 at 2:26 PM, Mirko Viviani  wrote:
> Do you mean that there is no way to print an image using a grid of 300 PPI 
> with Cocoa/Quartz?
> If not, why? Alternatives?

Resolution independence.  Your physical screen may have 96 pixels per
inch, but the system exposes it as 72 points per inch.  In the case of
printing, it actually gets this right and maps these virtual points to
physical, real-world 1/72 of an inch.  In the case of onscreen
graphics, the system currently does not do the points -> pixels
mapping such that 1 point = 1/72 inch.  You can turn that on with
Quartz Debug, though, and then everything behaves as if you were
printing.

--Kyle Sluder
___

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

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

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

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


Re: CGImageRef printing issue

2009-11-12 Thread David Duncan
On Nov 12, 2009, at 2:26 PM, Mirko Viviani wrote:

> On 12/ago/2009, at 21.30, David Duncan wrote:
> 
>>> From my experience on Windows, DPIHeight and DPIWidth are properties of the
>>> display device the image is drawn on, and not properties of the image
>>> itself.
>> 
>> They are properties of both. In the case of printing, you are using a fixed 
>> grid at 72 PPI. Your source image of course has its own DPI that determines 
>> the actual size of the image in real world units. You combine the two to 
>> print or display an image at its natural size.
> 
> Do you mean that there is no way to print an image using a grid of 300 PPI 
> with Cocoa/Quartz?
> If not, why? Alternatives?


Just like with all CGContexts you can apply a transform matrix to change the 
coordinate system. However in general this isn't necessary. If you want an 
image to display in a 1" x 1" area on screen, draw it into a 72x72 box. The 
pixel size of the image will determine DPI. If you wanted to draw a 1" image at 
300 DPI then you would just need a 300x300 image drawn into a 72x72 box. If you 
wanted to draw a 1" image at 600 DPI then you would need a 600x600 image drawn 
into the same 72x72 box.
--
David Duncan
Apple DTS Animation and Printing

___

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

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

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

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


Re: CGImageRef printing issue

2009-11-12 Thread Mirko Viviani
On 12/ago/2009, at 21.30, David Duncan wrote:

>> From my experience on Windows, DPIHeight and DPIWidth are properties of the
>> display device the image is drawn on, and not properties of the image
>> itself.
> 
> They are properties of both. In the case of printing, you are using a fixed 
> grid at 72 PPI. Your source image of course has its own DPI that determines 
> the actual size of the image in real world units. You combine the two to 
> print or display an image at its natural size.

Do you mean that there is no way to print an image using a grid of 300 PPI with 
Cocoa/Quartz?
If not, why? Alternatives?

-- 
Ciao,
Mirko

___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread Kyle Sluder
On Thu, Nov 12, 2009 at 9:44 AM, JongAm Park
 wrote:
> Should I use AuthorizationExecuteWithPrivileges() and invoke an external
> command like "cp"?

No.  Do not do this.  Follow the pattern of BetterAuthorizationSample:
http://developer.apple.com/mac/library/samplecode/BetterAuthorizationSample/listing4.html

--Kyle Sluder
___

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

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

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

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


Re: controlTextDidEndEditing and buttons...

2009-11-12 Thread Kyle Sluder
On Nov 12, 2009, at 12:52 PM, Carlo Caione   
wrote:


How can I send a controlTextDidEndEditing: to a NSTextField when I  
click on another button (without using tab or enter)?


You want to use NSEditorRegistration.

--Kyle Sluder
___

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

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

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

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


Array of dictionaries containing NSColor in NSUserDefaults

2009-11-12 Thread Martin Hewitson
Dear list,

The hardest part of this problem may be explaining it, but here goes.

I want to store an array of dictionaries in NSUserDefaults. In each dictionary 
I have a string and a color. The color is stored as data using NSArchiver.

So I build an array of these dictionaries, then put that array in another 
dictionary, which becomes the registered defaults.

So in my app delegate +initialize: I have something like:

NSMutableDictionary *item1 = [[[NSMutableDictionary alloc] 
initWithCapacity:1] autorelease];
NSMutableDictionary *item2 = [[[NSMutableDictionary alloc] 
initWithCapacity:1] autorelease];
[item1 setValue:@"name1" forKey:@"name" ];
[item1 setValue:[NSArchiver archivedDataWithRootObject:[NSColor 
blueColor]] forKey:@"color"];
[item2 setValue:@"name1" forKey:@"name" ];
[item2 setValue:[NSArchiver archivedDataWithRootObject:[NSColor 
redColor]] forKey:@"color"];

NSArray *catArray = [NSArray arrayWithObjects:item1,item2, nil];

// add defaults to dictionary
NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary]; 
[defaultValues setObject:catArray forKey:@"MyItemList"];

// register the defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];

Now comes the UI. I have a nib with a preferences panel. On the panel I have a 
table with two columns: one for 'name' and one for 'color'. So I put an array 
controller in the nib and bind it to userdefaults.values.MyItemList with the 
'Handles Content As Compound Value' field checked (I read somewhere this was 
necessary). Then I bind the columns of the table to the array controller. For 
the 'color' column I have a value transformer NSUnarchiveFromData. The 'color' 
column uses a custom cell which fires a callback in the preferences controller 
to launch a color panel. The action of the color panel is set to the following 
selector:

- (void) colorChanged: (id) sender 
{
NSArray *items = [itemArrayController arrangedObjects];
NSDictionary *item = [items objectAtIndex:[defaultItemsTable 
selectedRow] ];
[item setValue:[NSArchiver archivedDataWithRootObject:[sender color]] 
forKey:@"color"];
[defaultItemsTable setNeedsDisplay:YES];
} 

Now the problem. I can change the 'name' values and they stay changed between 
app launches. I can change colors and they change in the table, no problem. 
However, the new colors are not written to the user defaults. So if I relaunch 
the app the colors are back to the factory defaults. If I try to access the 
user defaults during the same running instance of the app, they are still the 
factory defaults. I can also add new items to the array controller, and they 
appear as they should on app relaunch. It's just the colors that are causing 
trouble.

Has anyone tried something like this, or can anyone see what I'm doing wrong?

Thanks in advance,

Martin



Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

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

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

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


controlTextDidEndEditing and buttons...

2009-11-12 Thread Carlo Caione
Hi,
How can I send a controlTextDidEndEditing: to a NSTextField when I click on 
another button (without using tab or enter)?

Thanks

--
CC___

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

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

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

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


Re: How do I get Lucida Grande italic into my application?

2009-11-12 Thread Jens Alfke


On Nov 12, 2009, at 11:37 AM, Eric Gorr wrote:

CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE *  
acosf(0) / 90), 1, 0, 0));
My matrix math is a bit rusty...how would I turn that into a series  
of method calls to NSAffineTransform?


Looks like those parameters are the six values in the  
CFAffineTransform struct; and NSAffineTransformStruct is declared  
identically. You could just put those six values into an  
NSAffineTransformStruct and then store that into a transform object.


—Jens___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread Nick Zitzmann

On Nov 12, 2009, at 1:17 PM, JongAm Park wrote:

> What is interesting was that it didn't require to use PreAuthoriazation flag 
> when invoking "cp".

You don't need to pre-authorize if you're only going to invoke an authorization 
once; you only need to do that if there is a chance that you need to call 
AEWP() more than once.

Nick Zitzmann


___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread JongAm Park

Thank you all.

It works now.
What is interesting was that it didn't require to use PreAuthoriazation 
flag when invoking "cp".
I think the "Factored Application" case in the document was about an 
external program which are not Unix commands but something else.


Thank you again.
JongAm Park
___

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

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

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

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


Re: Multiple variable rules in for() statement

2009-11-12 Thread Greg Parker
On Nov 12, 2009, at 11:29 AM, Jonathon Kuo wrote:
> I can't chance upon the right incantation for using both an existing variable 
> and an inline new one in a for loop. I've boiled this down to a trivial show 
> case, same results for both gcc 4.0.1 and 4.2.1:
> 
>  int i;
>   . . .
>  for (i=0, int m=0; i<5; i++) { . . . };
>  printf("Final value of i: %d\n",i);
> 
> error: syntax error before ‘int’
> error: syntax error before ‘)’ token
> 
> So I tried this:
> 
>  int i;
>   . . .
>  for (int m=0,i=0; i<5; i++) { . . . };
>  printf("Final value of i: %d\n",i);
> 
> error: redefinition of ‘i’
> 
> Is there a rule that ALL initialized loop variables are either new and local 
> to the loop, or that none are? Surely Im doing something wrong here!

The first clause of a C99 for loop may be a single expression, or a single 
declaration. `i=0, m=0` is an expression: two assignment expressions joined by 
the comma operator. `int i=0, m=0` is a declaration, creating two new integer 
variables. `i=0, int m=0` is invalid; the RHS of that comma is a declaration, 
but the comma operator only allows expressions on both sides.

If you want both variables initialized to the same value, you can use this:
int i;
for (int m = i = 0; i < 5; i++) { ... }
It's a declaration, whose initializater happens to have the side-effect of 
assigning to another variable.

You can get the two variables initialized to different values:
int i;
for (int m = (i = 0, 10); i < 5; i++) { ... }
Again, a declaration with a complicated initializer.

But if you do that, keep in mind this irregular verb form:
My code is elegant.
Your code is sneaky.
His code is an ugly hack.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

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

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

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


Re: Multiple variable rules in for() statement

2009-11-12 Thread BJ Homer
I believe this is actually independent of being in a for loop.  Your first
line corresponds to code like this:

int i;
i=0, int m=0;

Which is syntactically incorrect.

Your second example corresponds to this:

int i;
int m=0, i;

Which is an attempt to re-declare i.

So you're correct; you can't have both an old variable and a new variable in
the for loop initialization.

-BJ
___

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

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

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

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


Re: How do I get Lucida Grande italic into my application?

2009-11-12 Thread Eric Gorr

On Nov 12, 2009, at 2:21 PM, Jens Alfke wrote:

> 
> On Nov 12, 2009, at 9:39 AM, Eric Gorr wrote:
> 
>> Unfortunately, the link
>> 
>> 
>> is no longer valid
> 
> The file's been moved in the WebKit source tree since that URL was posted. 
> Searching for 'FontMac.mm' in Trac shows that the up to date URL is
>   
> http://trac.webkit.org/browser/trunk/WebCore/platform/graphics/mac/FontMac.mm
> 
> 
> On Nov 12, 2009, at 10:46 AM, Eric Gorr wrote:
>> [italicTransform rotateByDegrees:kRotationForItalicText];
> 
> You don't want a rotation for that; use a skew transform.

Thanks for the updated link.

From there, if I located the correct bit of code, I found:

CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 
1, 0, 0));

where SYNTHETIC_OBLIQUE_ANGLE = 14. 

My matrix math is a bit rusty...how would I turn that into a series of method 
calls to NSAffineTransform?

> And as a font weenie I am compelled to point out that this is not an italic 
> font, it's an oblique; and a synthetic oblique at that.
> 
> FYI, the 'Lucida Sans' font family, which is all but identical to Lucida 
> Grande, includes a true italic. It's on every Mac I've used, but I'm not sure 
> if it's in the base install, or installed as part of an external package like 
> iWork. It would be worth looking into, as the real italic looks much nicer 
> than a fake oblique.


I agree. I would much rather use a real italic, but, as you pointed out, I need 
to be certain that the font does exist. Of course, I could put in a lot of code 
to take all of the different failure cases into account...an option.




___

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

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

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

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


Multiple variable rules in for() statement

2009-11-12 Thread Jonathon Kuo
I can't chance upon the right incantation for using both an existing  
variable and an inline new one in a for loop. I've boiled this down to  
a trivial show case, same results for both gcc 4.0.1 and 4.2.1:


  int i;
   . . .
  for (i=0, int m=0; i<5; i++) { . . . };
  printf("Final value of i: %d\n",i);

error: syntax error before ‘int’
error: syntax error before ‘)’ token

So I tried this:

  int i;
   . . .
  for (int m=0,i=0; i<5; i++) { . . . };
  printf("Final value of i: %d\n",i);

error: redefinition of ‘i’

Is there a rule that ALL initialized loop variables are either new and  
local to the loop, or that none are? Surely Im doing something wrong  
here!



___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread JongAm Park

Thank you. I will try AuthorizationExecuteWithPrivileges().

JongAm Park

Nick Zitzmann wrote:

On Nov 12, 2009, at 11:34 AM, JongAm Park wrote:

  

You cannot escalate the privileges of a running task on Mac OS X. So if a 
running task does not have root privileges, then it never will.
  

Then how?



That's what AEWP() is for. Once you've pre-authorized, you pass your 
authorization ref to AEWP(), and it will run the program you want it to run 
with root privileges. But you can never elevate the privileges of an 
unprivileged app, not even for one call.

Note that AEWP() does not run tasks _as_ root (and yes, there's a difference). 
If you need that, then you need to invoke AEWP() with a wrapper that sets the 
uid. Search the archives for details.

Nick Zitzmann



  


___

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

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

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

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


Re: How do I get Lucida Grande italic into my application?

2009-11-12 Thread Jens Alfke


On Nov 12, 2009, at 9:39 AM, Eric Gorr wrote:


Unfortunately, the link


is no longer valid


The file's been moved in the WebKit source tree since that URL was  
posted. Searching for 'FontMac.mm' in Trac shows that the up to date  
URL is


http://trac.webkit.org/browser/trunk/WebCore/platform/graphics/mac/FontMac.mm


On Nov 12, 2009, at 10:46 AM, Eric Gorr wrote:

[italicTransform rotateByDegrees:kRotationForItalicText];


You don't want a rotation for that; use a skew transform.

And as a font weenie I am compelled to point out that this is not an  
italic font, it's an oblique; and a synthetic oblique at that.


FYI, the 'Lucida Sans' font family, which is all but identical to  
Lucida Grande, includes a true italic. It's on every Mac I've used,  
but I'm not sure if it's in the base install, or installed as part of  
an external package like iWork. It would be worth looking into, as the  
real italic looks much nicer than a fake oblique.


—Jens___

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

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

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

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


Re: How do I get Lucida Grande italic into my application?

2009-11-12 Thread Eric Gorr
Well, I experimented a bit and tried:

const CGFloat kRotationForItalicText = -15.0;

NSAffineTransform *italicTransform = [NSAffineTransform transform];

[italicTransform scaleBy:[NSFont 
systemFontSizeForControlSize:NSMiniControlSize]];
[italicTransform rotateByDegrees:kRotationForItalicText];

but, the text drawn with the system font created with this transform was not 
what I would call very readable. A 15 degree rotation seems to be correct.

If anyone has any suggestions on how best to handle this, I would be interested.


On Nov 12, 2009, at 12:39 PM, Eric Gorr wrote:

> I need to be able to do this same thing and found this old thread and reply:
> 
> http://lists.apple.com/archives/Cocoa-dev/2007/Jan/msg00577.html
> 
> I assume the answer has not changed. Unfortunately, the link
> 
> 
> 
> 
> is no longer valid and I was wondering if anyone knew what the appropriate 
> NSAffineTransform would be to pass into +fontWithDescriptor:textTransform:
> 
> Ultimately, I believe the call I will want to make is:
> 
> [NSFont fontWithDescriptor:[[NSFont 
> systemFontSizeForControlSize:NSMiniControlSize] fontDescriptor] 
> textTransform:italicTransform];


___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread Nick Zitzmann

On Nov 12, 2009, at 11:34 AM, JongAm Park wrote:

>> You cannot escalate the privileges of a running task on Mac OS X. So if a 
>> running task does not have root privileges, then it never will.
> 
> Then how?

That's what AEWP() is for. Once you've pre-authorized, you pass your 
authorization ref to AEWP(), and it will run the program you want it to run 
with root privileges. But you can never elevate the privileges of an 
unprivileged app, not even for one call.

Note that AEWP() does not run tasks _as_ root (and yes, there's a difference). 
If you need that, then you need to invoke AEWP() with a wrapper that sets the 
uid. Search the archives for details.

Nick Zitzmann


___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread JongAm Park

Hi,

I already took a look at it. It is to use "factored" approach.

Thank you.

Volker in Lists wrote:

Hi,

I am using this and I guess it is the recommended way of doing. Works 
well: 
http://developer.apple.com/mac/library/samplecode/BetterAuthorizationSample/index.html 



Volker

Am 12.11.2009 um 18:44 schrieb JongAm Park:


Hello,

I'm trying to copy a file from a desktop to a /Library/Application 
Supports/../Plugins directory.
Because the directory requires to obtain system administrator's 
privilege I should be authorized.


so, I wrote codes like this.

- (void)awakeFromNib
{
  [self authorize];
}

- (void) applicationWillTerminate:(NSNotification *)aNotification
{
  OSStatus myStatus;
  NSLog( @"applicationWillTerminate");
myStatus = AuthorizationFree( mAuthorizationRef, 
kAuthorizationFlagDestroyRights );

 }

-(IBAction)copyWithNSFileManager:(id)sender
{
  NSString *PlugInPath = [NSString 
stringWithString:@"/Library/Application Support/Final Cut Pro System 
Support/Plugins/test3.valm"];
NSString *sourceFile = [NSString 
stringWithFormat:@"%@/Desktop/test3.valm", NSHomeDirectory()];

BOOL isSuccessful;
  isSuccessful = [[NSFileManager defaultManager] copyPath:sourceFile 
toPath:PlugInPath handler:nil];

}

-(IBAction)copyWithNSWorkspace:(id)sender
{
  NSString *PluginPath = [NSString 
stringWithString:@"/Library/Application Support/Final Cut Pro System 
Support/Plugins"];
  NSString *sourceDirectory = [NSString 
stringWithFormat:@"%@/Desktop", NSHomeDirectory()];

  NSArray *files = [NSArray arrayWithObject:@"test3.valm"];
NSInteger tag;
  BOOL isSuccessful = [[NSWorkspace sharedWorkspace] 
performFileOperation:NSWorkspaceCopyOperation

   source:sourceDirectory
  destination:PluginPath
files:files
  tag:&tag];
NSLog(@"isSuccessful = %@", isSuccessful? @"YES":@"NO" );
}

- (void)authorize
{  OSStatus myStatus;
  myStatus = AuthorizationCreate(NULL, 
kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, 
&mAuthorizationRef);

AuthorizationItem myItems[1];
myItems[0].name = "com.greenleaf.FileCopyTest.myRight1";
  myItems[0].valueLength = 0;
  myItems[0].value = NULL;
  myItems[0].flags = 0;
  AuthorizationRights myRights;
  myRights.count = sizeof( myItems ) / sizeof( myItems[0] );
  myRights.items = myItems;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults | 
kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
myStatus = AuthorizationCopyRights(mAuthorizationRef, &myRights, 
kAuthorizationEmptyEnvironment, myFlags, NULL);

  if( myStatus == errAuthorizationSuccess )
  {
  NSLog(@"Successful in authorizing.. " );
  }
 }

Although it returns "errAuthorizationSuccess" in "authorize" method, 
when a file is to be copied, it returns "fail" state and the file is 
not copied.

Can anyone help me to figure out why?

Should I use AuthorizationExecuteWithPrivileges() and invoke an 
external command like "cp"?
I think it should be possible to copy files with proper privilege 
with Cocoa calls.


Thank you.
JongAm Pawrk
___

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

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

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



This email sent to volker_li...@ecoobs.de





___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread JongAm Park

Nick Zitzmann wrote:

On Nov 12, 2009, at 10:44 AM, JongAm Park wrote:

  

  NSString *PlugInPath = [NSString stringWithString:@"/Library/Application 
Support/Final Cut Pro System Support/Plugins/test3.valm"];



Apologies for being a little pedantic here, but calling +stringWithString: is 
almost never necessary and in this case is just cluttering the autorelease 
pool/garbage collector. You can set NSString pointers to NSString constants 
with no problems.

  
It's intermediate code. I have good reason to use stringWithString or 
stringWithFormat. It was revised to hide something from original code, 
but I didn't want to change much to post the code to the mailing list. 
So, I used remainder from the original code.




Although it returns "errAuthorizationSuccess" in "authorize" method, when a file is to be 
copied, it returns "fail" state and the file is not copied.
Can anyone help me to figure out why?



You cannot escalate the privileges of a running task on Mac OS X. So if a 
running task does not have root privileges, then it never will.

  


Then how?

Should I use AuthorizationExecuteWithPrivileges() and invoke an external command like 
"cp"?
I think it should be possible to copy files with proper privilege with Cocoa 
calls.



Yes. Apple actually wants you to use AEWP() to run your own helper tool for 
security reasons, though it's highly unlikely you'll run into problems by doing 
direct invocations. Check the list archives for details.

Nick Zitzmann



  


___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread JongAm Park

I'm sorry, but the scenario doesn't apply to mine.

Thank you.

Sherm Pendley wrote:

On Thu, Nov 12, 2009 at 12:44 PM, JongAm Park
 wrote:
  

NSString *sourceFile = [NSString
stringWithFormat:@"%@/Desktop/test3.valm", NSHomeDirectory()];



Have you tried this?

[[NSWorkspace sharedWorkspace] openFile:sourceFile];

Many apps register their plugin extensions as document types, so you
can simply open them and let the app handle the installation for you.
The screen saver app, for example, does this with .saver plugins.

sherm--

  


___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread Sherm Pendley
On Thu, Nov 12, 2009 at 12:44 PM, JongAm Park
 wrote:
>
>     NSString *sourceFile = [NSString
> stringWithFormat:@"%@/Desktop/test3.valm", NSHomeDirectory()];

Have you tried this?

[[NSWorkspace sharedWorkspace] openFile:sourceFile];

Many apps register their plugin extensions as document types, so you
can simply open them and let the app handle the installation for you.
The screen saver app, for example, does this with .saver plugins.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread Nick Zitzmann

On Nov 12, 2009, at 10:44 AM, JongAm Park wrote:

>   NSString *PlugInPath = [NSString stringWithString:@"/Library/Application 
> Support/Final Cut Pro System Support/Plugins/test3.valm"];

Apologies for being a little pedantic here, but calling +stringWithString: is 
almost never necessary and in this case is just cluttering the autorelease 
pool/garbage collector. You can set NSString pointers to NSString constants 
with no problems.

> Although it returns "errAuthorizationSuccess" in "authorize" method, when a 
> file is to be copied, it returns "fail" state and the file is not copied.
> Can anyone help me to figure out why?

You cannot escalate the privileges of a running task on Mac OS X. So if a 
running task does not have root privileges, then it never will.

> Should I use AuthorizationExecuteWithPrivileges() and invoke an external 
> command like "cp"?
> I think it should be possible to copy files with proper privilege with Cocoa 
> calls.

Yes. Apple actually wants you to use AEWP() to run your own helper tool for 
security reasons, though it's highly unlikely you'll run into problems by doing 
direct invocations. Check the list archives for details.

Nick Zitzmann


___

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

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

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

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


Re: boundingRectWithSize:Option: and height constraint

2009-11-12 Thread Matt Neuburg
> Date: Thu, 12 Nov 2009 04:06:17 -0500
> From: Bill Cheeseman 
> Subject: Re: boundingRectWithSize:Option: and height constraint
> 
> But I was not looking for efficiency gains, only ease of coding.

The "coding" involved here is pretty much copy-and-paste from the existing
examples - in other words, no coding at all. You have not said anything in
this thread about what your *actual* needs are (i.e. what you're trying to
print), but the text system already knows how to print lengthy styled text
without worrying about lines being "cut off" by the page bottom. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com



___

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

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

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

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


Re: [Q] copy operation and authorization

2009-11-12 Thread Volker in Lists

Hi,

I am using this and I guess it is the recommended way of doing. Works  
well: http://developer.apple.com/mac/library/samplecode/BetterAuthorizationSample/index.html


Volker

Am 12.11.2009 um 18:44 schrieb JongAm Park:


Hello,

I'm trying to copy a file from a desktop to a /Library/Application  
Supports/../Plugins directory.
Because the directory requires to obtain system administrator's  
privilege I should be authorized.


so, I wrote codes like this.

- (void)awakeFromNib
{
  [self authorize];
}

- (void) applicationWillTerminate:(NSNotification *)aNotification
{
  OSStatus myStatus;
  NSLog( @"applicationWillTerminate");
myStatus = AuthorizationFree( mAuthorizationRef,  
kAuthorizationFlagDestroyRights );

 }

-(IBAction)copyWithNSFileManager:(id)sender
{
  NSString *PlugInPath = [NSString stringWithString:@"/Library/ 
Application Support/Final Cut Pro System Support/Plugins/test3.valm"];
NSString *sourceFile = [NSString stringWithFormat:@"%@/Desktop/ 
test3.valm", NSHomeDirectory()];

BOOL isSuccessful;
  isSuccessful = [[NSFileManager defaultManager] copyPath:sourceFile  
toPath:PlugInPath handler:nil];

}

-(IBAction)copyWithNSWorkspace:(id)sender
{
  NSString *PluginPath = [NSString stringWithString:@"/Library/ 
Application Support/Final Cut Pro System Support/Plugins"];
  NSString *sourceDirectory = [NSString stringWithFormat:@"%@/ 
Desktop", NSHomeDirectory()];

  NSArray *files = [NSArray arrayWithObject:@"test3.valm"];
NSInteger tag;
  BOOL isSuccessful = [[NSWorkspace sharedWorkspace]  
performFileOperation:NSWorkspaceCopyOperation

   source:sourceDirectory
  destination:PluginPath
files:files
  tag:&tag];
NSLog(@"isSuccessful = %@", isSuccessful? @"YES":@"NO" );
}

- (void)authorize
{  OSStatus myStatus;
  myStatus = AuthorizationCreate(NULL,  
kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults,  
&mAuthorizationRef);

AuthorizationItem myItems[1];
myItems[0].name = "com.greenleaf.FileCopyTest.myRight1";
  myItems[0].valueLength = 0;
  myItems[0].value = NULL;
  myItems[0].flags = 0;
  AuthorizationRights myRights;
  myRights.count = sizeof( myItems ) / sizeof( myItems[0] );
  myRights.items = myItems;
AuthorizationFlags myFlags = kAuthorizationFlagDefaults |  
kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
myStatus = AuthorizationCopyRights(mAuthorizationRef, &myRights,  
kAuthorizationEmptyEnvironment, myFlags, NULL);

  if( myStatus == errAuthorizationSuccess )
  {
  NSLog(@"Successful in authorizing.. " );
  }
 }

Although it returns "errAuthorizationSuccess" in "authorize" method,  
when a file is to be copied, it returns "fail" state and the file is  
not copied.

Can anyone help me to figure out why?

Should I use AuthorizationExecuteWithPrivileges() and invoke an  
external command like "cp"?
I think it should be possible to copy files with proper privilege  
with Cocoa calls.


Thank you.
JongAm Pawrk
___

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

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

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

This email sent to volker_li...@ecoobs.de


___

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

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

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

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


Re: Weird problem with Core Text

2009-11-12 Thread Aki Inoue
> Your comments do make sense. But the glitch lies in the code where it tries 
> to format a chunk of text with CTFrameSetter. I doubt it might have been 
> trapped into some infinite loop of  memory allocation in the implementation 
> of 
> CTFrameSetterCreateFrame, and that's the reason why it's allocating a memory 
> beyond boundary (but somehow 64-bit worked?).
Yes, I agree CoreText should not cause crashes even with huge documents that 
way.  That situation should be handled more gracefully.

Please file a bug against CoreText.

Thanks,

Aki___

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

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

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

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


[Q] copy operation and authorization

2009-11-12 Thread JongAm Park

Hello,

I'm trying to copy a file from a desktop to a /Library/Application 
Supports/../Plugins directory.
Because the directory requires to obtain system administrator's 
privilege I should be authorized.


so, I wrote codes like this.

- (void)awakeFromNib
{
   [self authorize];
}

- (void) applicationWillTerminate:(NSNotification *)aNotification
{
   OSStatus myStatus;
   NSLog( @"applicationWillTerminate");
  
   myStatus = AuthorizationFree( mAuthorizationRef, 
kAuthorizationFlagDestroyRights );
  
}


-(IBAction)copyWithNSFileManager:(id)sender
{
   NSString *PlugInPath = [NSString 
stringWithString:@"/Library/Application Support/Final Cut Pro System 
Support/Plugins/test3.valm"];
  
   NSString *sourceFile = [NSString 
stringWithFormat:@"%@/Desktop/test3.valm", NSHomeDirectory()];
  
   BOOL isSuccessful;
   isSuccessful = [[NSFileManager defaultManager] copyPath:sourceFile 
toPath:PlugInPath handler:nil];

}

-(IBAction)copyWithNSWorkspace:(id)sender
{
   NSString *PluginPath = [NSString 
stringWithString:@"/Library/Application Support/Final Cut Pro System 
Support/Plugins"];
   NSString *sourceDirectory = [NSString 
stringWithFormat:@"%@/Desktop", NSHomeDirectory()];

   NSArray *files = [NSArray arrayWithObject:@"test3.valm"];
  
   NSInteger tag;
   BOOL isSuccessful = [[NSWorkspace sharedWorkspace] 
performFileOperation:NSWorkspaceCopyOperation

source:sourceDirectory
   destination:PluginPath
 files:files
   tag:&tag];
  
   NSLog(@"isSuccessful = %@", isSuccessful? @"YES":@"NO" );

}

- (void)authorize
{   
   OSStatus myStatus;
   myStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, 
kAuthorizationFlagDefaults, &mAuthorizationRef);
  
   AuthorizationItem myItems[1];
  
   myItems[0].name = "com.greenleaf.FileCopyTest.myRight1";

   myItems[0].valueLength = 0;
   myItems[0].value = NULL;
   myItems[0].flags = 0;
  
  
   AuthorizationRights myRights;

   myRights.count = sizeof( myItems ) / sizeof( myItems[0] );
   myRights.items = myItems;
  
   AuthorizationFlags myFlags = kAuthorizationFlagDefaults | 
kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;
  
   myStatus = AuthorizationCopyRights(mAuthorizationRef, &myRights, 
kAuthorizationEmptyEnvironment, myFlags, NULL);

   if( myStatus == errAuthorizationSuccess )
   {
   NSLog(@"Successful in authorizing.. " );
   }
  
}


Although it returns "errAuthorizationSuccess" in "authorize" method, 
when a file is to be copied, it returns "fail" state and the file is not 
copied.

Can anyone help me to figure out why?

Should I use AuthorizationExecuteWithPrivileges() and invoke an external 
command like "cp"?
I think it should be possible to copy files with proper privilege with 
Cocoa calls.


Thank you.
JongAm Pawrk
___

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

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

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

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


How do I get Lucida Grande italic into my application?

2009-11-12 Thread Eric Gorr
I need to be able to do this same thing and found this old thread and reply:

 http://lists.apple.com/archives/Cocoa-dev/2007/Jan/msg00577.html

I assume the answer has not changed. Unfortunately, the link

 


is no longer valid and I was wondering if anyone knew what the appropriate 
NSAffineTransform would be to pass into +fontWithDescriptor:textTransform:

Ultimately, I believe the call I will want to make is:

 [NSFont fontWithDescriptor:[[NSFont 
systemFontSizeForControlSize:NSMiniControlSize] fontDescriptor] 
textTransform:italicTransform];


Thank you.

___

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

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

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

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


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Kyle Sluder

On Nov 12, 2009, at 6:52 AM, Jeremy Pereira  wrote:



On 12 Nov 2009, at 14:23, Hank Heijink (Mailinglists) wrote:



Why is that? The only difference between setValue:forKey: and  
setObject:forKey: is that the former uses the latter unless value  
is nil, in which case the key will be removed. Come to think of it,  
using setObject:forKey: will give me the advantage of raising an  
exception if I try to add nil to the dictionary instead of failing  
silently - I think I'll switch. Thanks!


That shows that one should check the docs before saying something.   
I always thought setValue:forKey: was only for use with key-value  
coding but the docs for NSMutableDictionary seem to imply you can  
also use it in the more general way as you are doing.


While -setValue:forKey: will work, you are correct in saying that you  
should only use it for key-value coding. KVC keys must be strings,  
NSMutableDictionary will prefer to respond to it's own properties  
before checking its contents, nil is handled differently…


--Kyle Sluder___

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

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

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

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


Re: NSXMLParser choking on single quotes

2009-11-12 Thread Matt Neuburg
On Thu, 12 Nov 2009 12:08:20 + (UTC), kentoz...@comcast.net said:
>I'm using NSXMLParser to parse XML output from Microsoft Word and am finding
that if a string contains a single quote, the parser is only giving me the part
of the string from the single quote onward. For example given the following
string: 
>
>
>"The topic of Jim's discussion was on the yeti crab"

But that isn't XML. Can you give an example using XML? That would make it
possible for others to reproduce and consider the actual problem. m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

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

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

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


re: iPhone CLLocation Accuracy?

2009-11-12 Thread Stephen Hoffman
on Wed, 11 Nov 2009 16:42:28 -0500 Chunk 1978  writes

> how accurate is CLLocation's kCLLocationAccuracyBest?  about a meter
> or more?  or is it hyper accurate as in centimeters?  anyone know?

FWIW, location determination by cell tower might be precise, but it is not 
necessarily accurate.

iPhone (sans GPS) can be off by a couple of kilometers and well outside its own 
circular error display, in my 
experience.___

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

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

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

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


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Jeremy Pereira

On 12 Nov 2009, at 14:23, Hank Heijink (Mailinglists) wrote:

> On Nov 12, 2009, at 5:59 AM, Jeremy Pereira wrote:
> 
>>> for (NSUInteger i = 0; i < nTags; i++) {
>>> unsigned long pcLength = 0;
>>> if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, 
>>> &pcLength) != 0) continue;
>> 
>> Religious rant first:
>> 
>> The above line is an abomination in my opinion.  What's wrong with
>> 
>>  if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, &pcLength) == 
>> 0) {
>> 
>>  // rest of loop code
>> 
>>  }
> 
> Matter of taste, in my opinion. There's nothing wrong with your version 
> either.

That's why I prefixed it with "Religious Rant".  I prefer my version because 
the control structure is made explicit i.e. it is obvious at a glance (with 
proper indentation) that all the code below the line with "if" on it is 
conditional.


> 
>>> [tempDict setValue:contents forKey:key];
>> 
>> I think this should be[tempDict setObject:contents forKey:key];
> 
> Why is that? The only difference between setValue:forKey: and 
> setObject:forKey: is that the former uses the latter unless value is nil, in 
> which case the key will be removed. Come to think of it, using 
> setObject:forKey: will give me the advantage of raising an exception if I try 
> to add nil to the dictionary instead of failing silently - I think I'll 
> switch. Thanks!

That shows that one should check the docs before saying something.  I always 
thought setValue:forKey: was only for use with key-value coding but the docs 
for NSMutableDictionary seem to imply you can also use it in the more general 
way as you are doing.


>>> [tempDict release];
>> 
>> 
>> The other observation I would make is are you sure that getMetadata() 
>> completely fills your buffer from zero to pBuffer, because if it doesn't it 
>> could leave some garbage non ASCII bytes in it.  This, in turn would cause 
>> initWithCString:encoding: to return nil when using the ASCII encoding.  I 
>> would allocate the buffer like this:
>> 
>>  pBuffer = (unsigned char*) calloc(pcLength + 1, sizeof(unsigned char));
>> 
>> which zeros the whole buffer.  Thus copying any amount of non nul ASCII 
>> chars <= pcLength will automatically result in a C string.
> 
> That's a very good point. I'll try that.

I think this is most likely where your issue lies, particularly as it has 
already been pointed out that initWithCString:encoding: gives undefined results 
if the C string is not ASCII encoded.


> 
> Best,
> Hank
> 


__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

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

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

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

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


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Hank Heijink (Mailinglists)

On Nov 12, 2009, at 5:59 AM, Jeremy Pereira wrote:


for (NSUInteger i = 0; i < nTags; i++) {
unsigned long pcLength = 0;
		if (getLengthOfMetaData(fileHandle, metadataTags[i], 0,  
&pcLength) != 0) continue;


Religious rant first:

The above line is an abomination in my opinion.  What's wrong with

	if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, &pcLength)  
== 0) {


// rest of loop code

}


Matter of taste, in my opinion. There's nothing wrong with your  
version either.



[tempDict setValue:contents forKey:key];


I think this should be[tempDict setObject:contents forKey:key];


Why is that? The only difference between setValue:forKey: and  
setObject:forKey: is that the former uses the latter unless value is  
nil, in which case the key will be removed. Come to think of it, using  
setObject:forKey: will give me the advantage of raising an exception  
if I try to add nil to the dictionary instead of failing silently - I  
think I'll switch. Thanks!






[key release];
[contents release];
}

free(pBuffer);
}

_metaData = [[NSDictionary alloc] initWithDictionary:tempDict];
[tempDict release];



The other observation I would make is are you sure that getMetadata 
() completely fills your buffer from zero to pBuffer, because if it  
doesn't it could leave some garbage non ASCII bytes in it.  This, in  
turn would cause initWithCString:encoding: to return nil when using  
the ASCII encoding.  I would allocate the buffer like this:


	pBuffer = (unsigned char*) calloc(pcLength + 1, sizeof(unsigned  
char));


which zeros the whole buffer.  Thus copying any amount of non nul  
ASCII chars <= pcLength will automatically result in a C string.


That's a very good point. I'll try that.

Best,
Hank

___

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

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

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

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


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Hank Heijink (Mailinglists)
-initWithCString:encoding: should copy the bytes. You can verify  
that yourself with a small test:


   char buf[10+1] = "0123456789";
   NSString *s = [[NSString alloc] initWithCString:buf  
encoding:NSASCIIStringEncoding];

   NSLog(@"before %@", s);
   memset(buf, 'x', 10);
   NSLog(@"after  %@", s);

If the bytes were not copied then `before` and `after` would differ.

I don't see any memory errors in your code. My next suspect would be  
memory errors in getMetadata() or getLengthOfMetadata(). Try  
replacing getLengthOfMetadata(...) with pcLength=10, and/or  
getMetadata(...) with memset(pBuffer, 'x', pcLength). If one of  
those changes makes the crash go away then those two functions look  
much more suspicious.


Sure enough, replacing those functions makes the crash go away.  
Unfortunately, those functions are in a third-party library, and I  
can't get around using them. I'll contact the developers of that  
library and see what we can work out.


Thanks!

Hank

___

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

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

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

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


Re: [MEET] CocoaHeads-NYC this Thursday, 11/12 (tonight)

2009-11-12 Thread Andy Lee

A reminder:

On Nov 10, 2009, at 11:20 AM, Andy Lee wrote:

Demitri Muna will talk about Cappuccino, a web UI framework that  
lets you build desktop-like apps using code that is eerily similar  
to Cocoa.  Cappuccino uses Objective-J, an extension of JavaScript  
that looks and works like Objective-C.


As usual:

(1) Please feel free to bring questions, code, and works in  
progress.  We have a projector and we like to see code and try to  
help.

(2) We'll have burgers and beer afterwards.
(3) If there's a topic you'd like presented, let us know.
(4) If *you'd* like to give a talk, let me know.

Thursday, November 12
6:00- 8:00
Downstairs at Tekserve, on 23rd between 6th and 7th
 for directions and map
Everyone's welcome.  Just tell the person at the front you're there  
for CocoaHeads.


Hope to see you there!

--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 arch...@mail-archive.com


NSXMLParser choking on single quotes

2009-11-12 Thread kentozier
Hi 


I'm using NSXMLParser to parse XML output from Microsoft Word and am finding 
that if a string contains a single quote, the parser is only giving me the part 
of the string from the single quote onward. For example given the following 
string: 


"The topic of Jim's discussion was on the yeti crab" 


the parser would only give me: 


"'s discussion was on the yeti crab" 


I looked at the NSXMLParser docs but didn't see any options for customizing how 
it handles special characters. Is there some trick I'm missing? 


Thanks for any help 
___

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

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

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

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


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Jens Miltner


Am 11.11.2009 um 20:58 schrieb Hank Heijink (Mailinglists):


Hi all,

I've run into a funny crash when using -[NSString  
stringWithCString:encoding:]. The code in question runs in the  
iPhone Simulator. I haven't found anything on the web about this,  
but I found out some things by experimenting. I have a workaround,  
but I'm curious what's going on. I'd be very interested to hear your  
thoughts on this - apologies for the lengthy post!


This is the relevant piece of code - I'm sorry I can't post it in  
full (NDA prohibits):


nTags = 15;
	unsigned long metadataTags[] = { /* fifteen tags defined in some  
library */ };


	NSMutableDictionary *tempDict = [[NSMutableDictionary alloc]  
initWithCapacity:nTags];


for (NSUInteger i = 0; i < nTags; i++) {
unsigned long pcLength = 0;
		if (getLengthOfMetaData(fileHandle, metadataTags[i], 0,  
&pcLength) != 0) continue;


// pcLength is now the required buffer size.
// Fill the buffer with metadata (and make room for a \0)
unsigned char *pBuffer = malloc(pcLength + 1);

		if (getMetadata(fileHandle, metadataTags[i], pBuffer, pcLength) ==  
0) {

pBuffer[pcLength] = '\0';

			NSString *key = [[NSString alloc] initWithFormat:@"%d",  
metadataTags[i]];
			NSString *contents = [[NSString alloc] initWithCString:(const  
char *)pBuffer encoding:NSASCIIStringEncoding];


[tempDict setValue:contents forKey:key];

[key release];
[contents release];
}

free(pBuffer);
}

_metaData = [[NSDictionary alloc] initWithDictionary:tempDict];
[tempDict release];

The code runs as part of an -init method, and sets the _metaData  
instance variable (it's an NSDictionary *) of the class in question.  
Most of the time, but not always, the last line ([tempDict release])  
crashes with the following stack backtrace (MyApp, MyFile, etc. do  
have better names than that):


Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0005
Crashed Thread:  0

Application Specific Information:
iPhone Simulator 3.1 (139.1), iPhone OS 3.0 (7A341)

Thread 0 Crashed:
0   CoreFoundation  0x302042c0 CFRelease + 96
	1   CoreFoundation	0x30227249  
__CFDictionaryDeallocate + 281

2   CoreFoundation  0x30204421 _CFRelease + 241
	3   MyApp   	0x4ca0 -[MyFile  
getMetaDataFromFileHandle:] + 859 (MyFile.m:247)
	4   MyApp   	0x42fd -[MyFile initWithPath:]  
+ 382 (MyFile.m:62)
	5   MyApp   	0x26b4 -[MyAppDelegate  
applicationDidFinishLaunching:] + 407 (MyAppDelegate.m:68)
	6   UIKit 	0x308f8ac3 -[UIApplication  
_performInitializationWithURL:sourceBundleID:] + 500
	7   UIKit 	0x30901bf5 -[UIApplication  
_runWithURL:sourceBundleID:] + 594
	8   UIKit 	0x308fef33 -[UIApplication  
handleEvent:withNewEvent:] + 1532
	9   UIKit 	0x308fad82 -[UIApplication  
sendEvent:] + 71
	10  UIKit 	0x309013e1  
_UIApplicationHandleEvent + 4865
	11  GraphicsServices  	0x32046375 PurpleEventCallback +  
1533
	12  CoreFoundation	0x30245560 CFRunLoopRunSpecific  
+ 3888

13  CoreFoundation  0x30244628 CFRunLoopRunInMode + 
88
	14  UIKit 	0x308f930d -[UIApplication _run]  
+ 611
	15  UIKit 	0x309021ee UIApplicationMain +  
1157

16  MyApp   0x2324 main + 102 
(main.m:13)
17  MyApp   0x2292 start + 54

Here's what I found:

1. If I use -[NSString initWithUTF8String:], the crash doesn't happen.
2. If I allocate pBuffer only once, outside of the loop, the crash  
doesn't happen.
3. If I print out the memory ranges that pBuffer occupies, it seems  
that the crash happens when one allocation of pBuffer overlaps  
another one. If they start at the same address, it's no problem, but  
if they start at different addresses and overlap, it's a problem.  
This is why the app doesn't always crash: if the memory ranges don't  
happen to overlap, all is well.


So, I'm curious about how -[NSString initWithCString:encoding:]  
works. According to the documentation, it returns "An NSString  
object initialized using the characters from nullTerminatedCString."  
Does that mean it doesn't copy the bytes? Then what does it do? - 
[NSString initWithUTF8String] explicitly states that it returns "An  
NSString object initialized by copyi

Re: Drag-Move the Transparent windowed app over the screen

2009-11-12 Thread Symadept
Hi Kiran,

Excellent. Since my window is transparent and doing at runtime, I have to
mention its properties during creation.

- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle
backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {

// Using NSBorderlessWindowMask results in a window without a title bar.

self = [super initWithContentRect:contentRect

styleMask:NSBorderlessWindowMask | NSTexturedBackgroundWindowMask

  backing:NSBackingStoreBuffered defer:NO];

if (self != nil) {

// Start with no transparency for all drawing into the window

[self setAlphaValue:1.0];

// Turn off opacity so that the parts of the window that are not
drawn into are transparent.

[self setOpaque:NO];

}

return self;

}

Thanks a million. But can you put some rational on that, how does it made it
to happen. What does it mean by Textured. Besides giving metallic background
it is doing something more. What is that and how? How it unfroze my window
from moving once I gave this property?

Hope I am putting in proper manner.

Regards
Mustafa Shaik

On Thu, Nov 12, 2009 at 5:58 PM, kirankumar wrote:

> Hi,
>
> goto attributes for your window ,enable the texture checkbox so that
> you can drag your window.
>
>
> Regards,
> kiran.
>
>
>
>
>
> On Nov 12, 2009, at 2:09 PM, Symadept wrote:
>
>  Hi,
>>
>> My app's window is a BorderLess Window because of which I will not
>> have the Titlebar (Ref: RoundTransparentWindow of Apple examples).
>>
>> Because of which I can't drag and move over the screen. Any
>> pointers to solve this.
>>
>> Regards
>> symadept
>>
>>
>
> The information contained in this email and any attachments is confidential
> and may be subject to copyright or other intellectual property protection.
> If you are not the intended recipient, you are not authorized to use or
> disclose this information, and we request that you notify us by reply mail
> or telephone and delete the original message from your mail system.
>
___

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

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

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

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


Re: Connecting up a drop down menu

2009-11-12 Thread Symadept
Hi Karen,

This is how I will do.

http://mustafashaik.blogspot.com/2009/11/dropdown-box-popup-menu.html

In this example refer to the awakeFromNib of DropDownButtonController and
the handlers that I have registered during creation of the menu-items.

Hope this is useful for you.

Happy coding!

Regards
Mustafa Shaik


On Thu, Nov 12, 2009 at 4:52 PM, Karen van Eck <
karen.van@sonoco-trident.com> wrote:

> Hi,
>
> Please could someone point me in the direction of a tutorial or something
> that shows how to bind up a drop down menu. I've been googling, reading, but
> am just getting more and more confused.
>
> I am looking for something very simple and clear, which assumes nothing,
> which will show me how to get the values from my program into the drop-down,
> and the selected value back into a string.
>
> Thank you
>
> Karen
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/symadept%40gmail.com
>
> This email sent to symad...@gmail.com
>
___

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

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

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

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


Re: -[NSString stringWithCString:encoding:] memory management question

2009-11-12 Thread Jeremy Pereira

On 11 Nov 2009, at 19:58, Hank Heijink (Mailinglists) wrote:

> Hi all,
> 
> I've run into a funny crash when using -[NSString 
> stringWithCString:encoding:]. The code in question runs in the iPhone 
> Simulator. I haven't found anything on the web about this, but I found out 
> some things by experimenting. I have a workaround, but I'm curious what's 
> going on. I'd be very interested to hear your thoughts on this - apologies 
> for the lengthy post!
> 
> This is the relevant piece of code - I'm sorry I can't post it in full (NDA 
> prohibits):
> 
>   nTags = 15;
>   unsigned long metadataTags[] = { /* fifteen tags defined in some 
> library */ };
> 
>   NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] 
> initWithCapacity:nTags];
>   
>   for (NSUInteger i = 0; i < nTags; i++) {
>   unsigned long pcLength = 0;
>   if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, 
> &pcLength) != 0) continue;

Religious rant first:

The above line is an abomination in my opinion.  What's wrong with

if (getLengthOfMetaData(fileHandle, metadataTags[i], 0, &pcLength) == 
0) {

// rest of loop code

}


>   
>   // pcLength is now the required buffer size.
>   // Fill the buffer with metadata (and make room for a \0)
>   unsigned char *pBuffer = malloc(pcLength + 1);
>   
>   if (getMetadata(fileHandle, metadataTags[i], pBuffer, pcLength) 
> == 0) {
>   pBuffer[pcLength] = '\0';
>   
>   NSString *key = [[NSString alloc] initWithFormat:@"%d", 
> metadataTags[i]];
>   NSString *contents = [[NSString alloc] 
> initWithCString:(const char *)pBuffer encoding:NSASCIIStringEncoding];
>   
>   [tempDict setValue:contents forKey:key];

I think this should be[tempDict setObject:contents forKey:key];


>   
>   [key release];
>   [contents release];
>   }
>   
>   free(pBuffer);
>   }
>   
>   _metaData = [[NSDictionary alloc] initWithDictionary:tempDict];
>   [tempDict release];


The other observation I would make is are you sure that getMetadata() 
completely fills your buffer from zero to pBuffer, because if it doesn't it 
could leave some garbage non ASCII bytes in it.  This, in turn would cause 
initWithCString:encoding: to return nil when using the ASCII encoding.  I would 
allocate the buffer like this:

pBuffer = (unsigned char*) calloc(pcLength + 1, sizeof(unsigned char));

which zeros the whole buffer.  Thus copying any amount of non nul ASCII chars 
<= pcLength will automatically result in a C string.




__
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
__
___

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

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

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

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


Re: [iPhone] Authentication failing on device after changing registration data

2009-11-12 Thread Antonio Nunes
On 12 Nov 2009, at 08:43, Roland King wrote:

> are you definitely receiving a challenge the *second* time you run the app? 
> It is possible that the server sends a cookie representing the login which 
> the phone has now cached and is sending along with the request 
> (automatically) which is failing the login.

Yes, I receive the challenge. In fact, after initially spotting the problem, I 
implemented:

- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection
{
return NO;
}

so in fact, I'm now seeing the challenge on each login attempt.

> One thing you could try to see if it's that is to find the cookie storage on 
> startup and clean it out explicitly. That might then make the server do the 
> challenge again.

When I try:
NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] 
cookiesForURL:[NSURL URLWithString:@"www.some.url"]];

at application startup I receive an empty array, so it doesn't look like any 
cookies are being stored.

...

Hmmm, and now I can change accounts without problems. I'll test some more, but 
the most likely scenario is I was cooked when I was recently testing this.

Thanks for the suggestions Roland. I wasn't aware of NSHTTPCookie and 
NSHTTPCookieStorage, so at least I picked up some new info. If I run into 
trouble again with this, I'll follow up on this thread.

Cheers,
António


It is better to light a candle than to curse the darkness


___

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

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

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

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


Re: boundingRectWithSize:Option: and height constraint

2009-11-12 Thread Bill Cheeseman

On Nov 12, 2009, at 2:19 AM, Kyle Sluder wrote:

> Which leads to the question: have you a demonstrated performance need
> to make a shortcut here?  If so, you probably shouldn't be using
> NSStringDrawing anyway; it does a lot of temporary setup and takedown.

The most recent documentation indicates that the efficiency of the string 
drawing methods has been much improved and that we are supposed to feel free to 
use them more often.

But I was not looking for efficiency gains, only ease of coding.


--

Bill Cheeseman
b...@cheeseman.name

___

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

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

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

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


Re: Drag-Move the Transparent windowed app over the screen

2009-11-12 Thread Dave Keck
Here's a clue: there's a method that you can override that rhymes with
-houseTownTanGrooveRainbow. And it's documented! :D
___

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

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

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

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


Connecting up a drop down menu

2009-11-12 Thread Karen van Eck

Hi,

Please could someone point me in the direction of a tutorial or  
something that shows how to bind up a drop down menu. I've been  
googling, reading, but am just getting more and more confused.


I am looking for something very simple and clear, which assumes  
nothing, which will show me how to get the values from my program into  
the drop-down, and the selected value back into a string.


Thank you

Karen

___

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

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

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

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


Re: Mute/Unmute audio device

2009-11-12 Thread Symadept
Hi,

I am using core audio to Set/Get the Audio device volume. With reference to
the following code

+ (float)volume:(NSString*)deviceName isInput:(BOOL)isInput{

float b_vol;

OSStatus err;

UInt32 size;

UInt32 channels[2];

float volume[2];

  AudioDeviceID device = [AudioUtils DeviceIdFor:deviceName isInput
:isInput];

NSLog(@"Device:[%x] IsInput:[%d]", device, isInput);

//Assume here I am getting the device id of the devices with the specific
name.


 // try set master volume (channel 0)

size = sizeof( b_vol);

err = AudioDeviceGetProperty(device, 0, isInput,
kAudioDevicePropertyVolumeScalar, &size, &b_vol);

NSLog(@"Volume:[%f]", b_vol);

if(noErr==err) return b_vol;

 // otherwise, try seperate channels

// get channel numbers

size = sizeof(channels);

err = AudioDeviceGetProperty(device, 0, isInput,
kAudioDevicePropertyPreferredChannelsForStereo, &size,&channels);

if(err!=noErr) NSLog(@"error getting channel-numbers");

 size = sizeof(float);

err = AudioDeviceGetProperty(device, channels[0], isInput,
kAudioDevicePropertyVolumeScalar, &size, &volume[0]);

if(noErr!=err) NSLog(@"error getting volume of channel %d",channels[0]);

err = AudioDeviceGetProperty(device, channels[1], isInput,
kAudioDevicePropertyVolumeScalar, &size, &volume[1]);

if(noErr!=err) NSLog(@"error getting volume of channel %d",channels[1]);

 b_vol = (volume[0]+volume[1])/2.00;

NSLog(@"Volumes:V1[%f] V2[%f] Final:[%f]", volume[0], volume[1], b_vol);

 return  b_vol;

}

This code works fine  for getting volume. Similarly can I set the audio
device to Mute/Unmute.

Any pointers highly appreciable.
Regards
Mustafa

On Thu, Nov 12, 2009 at 12:58 PM,  wrote:

> which technology are you asking about?
>
>
> On Nov 12, 2009 2:47pm, Symadept  wrote:
> > Hi,
> >
> > How to Mute/Unmute audio device.
> >
> > Regards
> > Mustafa
> >
>
___

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

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

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

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


Drag-Move the Transparent windowed app over the screen

2009-11-12 Thread Symadept
Hi,

My app's window is a BorderLess Window because of which I will not have the
Titlebar (Ref: RoundTransparentWindow of Apple examples).

Because of which I can't drag and move over the screen. Any pointers to
solve this.

Regards
symadept
___

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

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

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

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


Re: Close/Minimize the app

2009-11-12 Thread Symadept
Hi,

I have fixed my problem of miniaturizing the window. It was quite cool.

NSApplication *application = [NSApplication sharedApplication];
NSWindow *keyWindow = [application keyWindow];
[keyWindow miniaturize:keyWindow];

My app has KeyWindow but not MainWindow, because my app's window is
NSBorderlessWindowMask.

Thanks alot all of you for great effort.

Regards
Mustafa

On Thu, Nov 12, 2009 at 1:23 PM, kirankumar wrote:

>  hi,
>
>
> this will help you
> keep this 3lines of code in awakeFromNib, and mpwindow is you are window
> name.
>
>
>  id closeButton = [mpWindow standardWindowButton:NSWindowCloseButton ];
>  [closeButton setAction:@selector(closeapp:)];
>  [closeButton setTarget:self];
>
>
>
>  - (IBAction)closeapp:(id)sender
>   {
>exit(0);
>   }
>
>  Regards,
> kiran
>  On Nov 12, 2009, at 10:18 AM, Symadept wrote:
>
>  Actually I wanted to hide the app when close button is closed such that
> it
>  shall be active still. Which I was doing. I was basically facing the
> problem
>  with Minimize the app. I don't know why the NSApp
>  miniaturizeAll:self;
>  is not functioning as expected.
>
>  Regards
>  Symadept
>
>
>  On Thu, Nov 12, 2009 at 12:27 PM, Nick Zitzmann 
> wrote:
>
>
>  On Nov 11, 2009, at 8:50 PM, Symadept wrote:
>
>   How to close/minimize the app programmatically.
>
>
>  To close the app, call -[NSApplication terminate:].
>
>   I tried the following way
>  but no luck.
>
> [[NSApp mainWindow] performMiniaturize:nil];
>
>
>  This will only miniaturize the main window, and it won't work if
>  -mainWindow returns nil (e.g. the app is in the background).
>
>[OR]
> [NSApp miniaturizeAll:self];
>
>
>  Now that should minimize all of the windows, unless you somehow
>  circumvented loading NSApplication.
>
>   And close should not terminate my app, it should place an icon in the
>
>  Dock,
>
>  I hope it would be the same. And I know to give Dock Menu items.
>
>  From that menuitem, if I click on Open, it shall be able to launch my
>
>  app.
>
>  If an app is in the Dock, it is there because the app is running, or
>  because the user wants to keep it in the Dock when it is not running.
> Please
>  do not programmatically add inactive applications to the Dock. Even if
> there
>  was an official way of doing this, Mac OS X has a long tradition of making
>  this choice opt-in instead of opt-out like on Windows.
>
>  Nick Zitzmann
>  
>
>
>
>
>   ___
>
>  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
>  Please do not post admin requests or moderator comments to the list.
>  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
>  Help/Unsubscribe/Update your Subscription:
>
> http://lists.apple.com/mailman/options/cocoa-dev/kiran.koduri%40moschip.com
>
>  This email sent to kiran.kod...@moschip.com
>
>
>
> --
> The information contained in this email and any attachments is confidential
> and may be subject to copyright or other intellectual property protection.
> If you are not the intended recipient, you are not authorized to use or
> disclose this information, and we request that you notify us by reply mail
> or telephone and delete the original message from your mail system.
>
___

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

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

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

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