Re: Displaying a view modally (iPhone)

2009-10-21 Thread Alexander Spohr

Mike,

you need a view that has the size of the window to cover it  
completely. Otherwise touches will go down the responder chain and  
reach other views.


What happens while you show the spinner?
If you load data from the net show the UIApps spinner at the top.

atze



Am 21.10.2009 um 02:26 schrieb Mike Manzano:


Hi,

I'd like to display a busy indicator view (HUD) regardless of  
whatever view is currently at the top of the view stack. I'd also  
like this view to display modally so that the user interface beneath  
it is dead to touch events. This is like Tweetie 2's HUD that  
appears when you've successfully posted something to Instapaper,  
with the difference that the UI underneath it wouldn't accept events  
as they do in Tweetie 2. I'd also like to have some control over  
animating the HUD onto and off of the screen.


My current thinking is to find the topmost view controller somehow  
and send it presentModalViewController:animated:. However, I don't  
know how much control over animation I'd get with that method as the  
built-in animation styles sort of assume a full screen view. Also,  
I've never tried to use this method with a view that's smaller than  
the screen size.


Another thought is to just add the view to the root view and bring  
it to the top (this however won't make the view modal as the views  
below will still respond to touch events).


Can anyone tell me if I'm thinking along the right directions? I'd  
like to have some confirmation before I invest a bunch of time only  
to find out it's the wrong method.


Thanks,

Mike Manzano
mike (at) instantvoodoomagic (dot) com
http://instantvoodoomagic.com
@instantvoodoo

Oh BTW, the first reply that gets me closer to a solution gets a  
free promo code for Newsie (http://instantvoodoomagic.com/newsie),  
the Google Reader client for iPhone/iPod touch that I just released ;)




___

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

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

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

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


Re: Hiding tab view items

2009-10-21 Thread BareFeet
This seems like a common requirement, so I keep thinking I must be  
missing something simple.


For an example of similar functionality, look at Disk Utility. The  
user can navigate through a tree of nested disks and partition nodes  
in the left view. The right view shows a tab view that changes its tab  
items depending on what tree node is selected on the left. For  
instance, if you select a disk, you see the tab view items: First Aid,  
Erase, Partition, RAID and Restore. But if you select a partition, the  
"Partition" tab view item disappears.


Since there is no hidden/visible property for tab view items, it seems  
that I have to dynamically delete and create tab view items, which is  
prohibitively complicated since those tab view items also contain  
other objects which must therefore also be dynamically created and  
deleted.


At the moment, I've set up my tab view as tabless (ie the actual tabs  
don't show). Instead of tabs, I've created several segmented controls,  
one showing each desired set of segments. I've created a small second  
tabless tab view where each tab just contains one of the segmented  
controls. When the user selects a tree node (in the left pane),  
bindings switches to the tab containing the desired segmented control.  
When the user clicks on a segment, bindings then switches to the tab  
view corresponding to that segment.


user selects tree node
 -> bindings selects small tab view item which contains just the  
desired segmented control

user selects segment in segmented control
 -> bindings selects large tab view item which contains all the  
necessary objects


This works and requires almost no code (just bindings), so it's  
relatively neat. But it seems silly to have to create a second tab  
view just to switch between different segment controls.


Any other insights?

Thanks,
Tom
BareFeet

___

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

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

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

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


Beach balling on mach_msg_trap

2009-10-21 Thread Nathan Day
I am getting a beach balling in an application I am working on, I  
would of investigated more but I have noticed that some other apps on  
my computer seem to be doing the same thing.


If I move my applications window it free up the block allowing an  
event to be processed), but the instantly freezes on the next event,  
this is why I think other applications have the same problem because  
they exhibit the same behaviour, this includes the Applications Safari  
when playing a movie, Quick Time Player but the sound keeps playing  
and a Third party app called Opacity. s this a known issues.


It doesn't affect my MacBook Pro only my iMac and the issue occurred  
in 10.5 and 10.6, I am using an NSOperationQue which may have  
something to do with it.


One thing that is different between my MacBook Pro and iMac is that my  
iMac is nearly always doing something in the background, without may  
app running there is about 15% to 20% cpu usage and about 500 thread,  
another difference between my iMac and my MacBook Pro is that my iMac  
has only 37% of 1TB hard disk space, I have heard there can be some  
issues with disk fragmentation at 30% or less hard disk space.


(gdb) where
#0  0x00010011ad7a in mach_msg_trap ()
#1  0x00010011b3ed in mach_msg ()
#2  0x00010047fce2 in __CFRunLoopRun ()
#3  0x00010047f03f in CFRunLoopRunSpecific ()
#4  0x00010242ac4e in RunCurrentEventLoopInMode ()
#5  0x00010242aa53 in ReceiveNextEventCommon ()
#6  0x00010242a90c in BlockUntilNextEventMatchingListInMode ()
#7  0x000100fc1520 in _DPSNextEvent ()
#8  0x000100fc0e89 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#9  0x000100f86a7d in -[NSApplication run] ()
#10 0x000100f7f798 in NSApplicationMain ()
#11 0x000134ba in main (argc=1, argv=0x7fff5fbff3c8) at  
XX


Nathan Day
Software Engineer
mobile: +61 (0)4 3863 2407
home page:  http://homepage.mac.com/nathan_day/







___

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

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

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

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


NSInputStream / Eventqueue / run in Background

2009-10-21 Thread co...@weblooks.ch
Hello

I'm trying to run a bonjour service in background because my eventque is somehow
blocked when I try to press any button on my mac-app.

It's blocking while I'm transferring some data from an iPhone to the mac via
bonjour and press some button in the front... 

How can I run all the bonjour-stuff in another runloop ...?

Thank you!

Gabe
___

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

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

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

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


Re: Hiding tab view items

2009-10-21 Thread Kyle Sluder
On Wed, Oct 21, 2009 at 12:02 AM, BareFeet  wrote:
> This seems like a common requirement, so I keep thinking I must be missing
> something simple.

Nope.  You're going to need to write code.  The "hardest" part is
replacing the tab view items; this really isn't that difficult:

// Typed in Mail
- (void)updateTabView:(NSTabView *)tabView withItems:(NSArray *)newItems;
{
  NSArray *oldItems = [tabView tabViewItems];
  NSInteger newLocation = 0;
  for (NSTabViewItem *newItem in newItems) {
NSInteger existingLocation = [tabView indexOfTabViewItem:newItem];
if (existingLocation != NSNotFound)
  [tabView removeTabItem:newItem];
[tabView insertTabViewItem:newItem atIndex:newLocation++];
  }

  for (NSTabViewItem *oldItem in oldItems)
if (![newItems containsObject:oldItem])
  [tabView removeTabViewItem:oldItem]
}

--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: Hiding tab view items

2009-10-21 Thread Nathan Day
In general hiding bit of you interface depending on the state/ 
selection of you app is considered bad because it can confuse the  
user, if you disable elements then you are tell the user that the  
element is not available for the current state/selection etc., if you  
you hide elements then the user may think they have forgotten how to  
get to a particular feature and become frustrated as they try to find  
it. Also hiding elements can in some cases cause the remaining  
elements to move around which can allow confuse users (menu items for  
example), I am not saying you are wrong to do this in your case, only  
you can decided that.


On 13/10/2009, at 1:53 AM, BareFeet wrote:

I have a hierarchical list of objects, like the typical iTunes or  
XCode left pane. When the user selects a node in this hierarchy, I  
display detail of that node in the pane on the right. This right  
pane is divided into tab view items. Only some of the tab view items  
are relevant to each type of node, so I'd like to hide the tab view  
items that are not relevant. How can I do this?


Nathan Day
http://homepage.mac.com/nathan_day/

___

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

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

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

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


info gc-roots interpretation

2009-10-21 Thread Nick Rogers

Hi,
I have an ivar in AppController, a pointer to the class Volume.
When running info gc-roots on it before setting it nil, the results are:

(gdb) info gc-roots 0x2004f9340
Number of roots: 40
Root:
   0 Kind: bytes   rc:   1  Address: 0x000200543b40  Offset:  
0x0008

   1 Kind: object  rc:   0  Address: 0x0002004f9340  Class: Volume
Root:
   0 Kind: stack   rc:   0  Address: 0x7fff5fbfeab0  Frame level:  
1  Symbol: 
   1 Kind: object  rc:   0  Address: 0x00020015d000  Class:  
AppController  ivar: selectedPTVolume

   2 Kind: object  rc:   0  Address: 0x0002004f9340  Class: Volume
.
.
.
and 38 more, most with rc: 0.

When I set this ivar to nil. the results are:

(gdb) info gc-roots 0x2004f9340
Number of roots: 1
Root:
   0 Kind: bytes   rc:   1  Address: 0x000200543b40  Offset:  
0x0008

   1 Kind: object  rc:   0  Address: 0x0002004f9340  Class: Volume

When I try to run info gc-roots on the first entry, the results are:

(gdb) info gc-roots 0x000200543b40
Number of roots: 1
Root:
   0 Kind: bytes   rc:   1  Address: 0x000200543b40

Is there a retain cycle problem.
The memory gathered by this ivar is not freed, as per Obj-Alloc  
Instrument.


What shall I make out of these results and how can they lead to  
refinement (so that all the memory referenced by this ivar is freed)?


Wishes,
Nick

___

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

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

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

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


Re: info gc-roots interpretation

2009-10-21 Thread Quincey Morris

On Oct 21, 2009, at 01:39, Nick Rogers wrote:


When I set this ivar to nil. the results are:

(gdb) info gc-roots 0x2004f9340
Number of roots: 1
Root:
  0 Kind: bytes   rc:   1  Address: 0x000200543b40  Offset:  
0x0008

  1 Kind: object  rc:   0  Address: 0x0002004f9340  Class: Volume


So there's still a live pointer to your Volume instance in a block of  
(GC-controlled) memory at 200543b40+8. That block appears to be alive  
because it has a non-zero reference count.


Note that non-Cocoa frameworks such as Core Foundation can return  
objects/memory with a non-zero reference count, even under GC.  
CFRetain and CFRelease (and the related CFMakeCollectable and  
NSMakeCollectable) manipulate these reference counts, even under GC.  
Thus, for example, if you create a CFArray under GC you still need to  
CFRelease it before it can actually be garbage collected.


I don't see enough information here to find out why your object is  
still referenced. Your problem may be as simple as putting your Volume  
instance in a leaked CFArray or CFDictionary. Or, something in your  
code or in the frameworks may genuinely still be using your Volume  
instance.


In the absence of further information, the simple-minded approach to  
solving this would be to use the debugger to watch what happens to  
your Volume instance from its creation, and find out when the extra  
reference appears. Knowing when might tell you why.



___

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

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

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

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


Re: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]

2009-10-21 Thread Motti Shneor
Hello Steve, and thanks a lot. Your category is exactly what I needed. Although 
I already figured out myself the use of
[NSApp runModalForWindow:] for blocking and the [NSApp:stopModal] to release 
the block, I still enjoyed the way of doing this seamlessly via a category. In 
my case I need 2 categories  for NSSavePanel and NSOpenPanel, and some more 
implementation details.

However... I still have a few questions about your implementation, another 
about another implementation I found in an Apple sample, AND this code has 
TERRIBLY WEIRD and unstable behavior, when attaching these NSSavePanel sheets 
to a (Cocoa-wrapper of) Carbon Window.

So. First, I'd like to know, why you call on [NSApp endSheet:self]; after the 
modal loop is ended? If I'm not wrong, the "sheetDidEnd" selector is only 
called AFTER the sheet has been dismissed, closed, and released. I tried 
without calling this, and could see no difference in behavior. Isn't there a 
problem in calling this when no sheet is open?

Second. In another Apple Sample, which does almost the same, using a newer 
NSSavePanel 10.6 API's , there's something like

NSSavePanel *navPanel = [NSSavePanel savePanel];
[navPanel beginSheetModalForWindow: [sender window]
completionHandler:^(NSInteger result)
{
NSLog(@"Save panel dismissed - callback block reached.");
if (result == NSOKButton) {
[navPanel orderOut:self]; // close panel before we might present an error // 
[self application:NSApp openFile:[openPanel filename]];
}
[NSApp stopModal]; // end modal mode
}]; // this call exists immediately, but I need to block here, so...
[NSApp runModalForWindow: [sender window]];
}

Here, as you can see, there is another call .[navpanel orderout:self]; Again, 
isn't the conclusion block called AFTER the sheet was dismissed, closed and 
released? (my NSSavePanels are configured to "releaseWhenClosed"]. Also, what 
exactly is "orderout" ? could'nt figure out from the documentation.

Last (and most important) - Supposedly I use your nice category like this:

WindowRef frontWin = ::FrontWindow();  // get Carbon application front window. 
Actually, any carbon window.
NSWindow *cocoaFromCarbonWin = [[NSWindow alloc] initWithWindowRef:frontWin];
NSSavePanel *navPanel = [NSSavePanel savePanel];
[navPanel runModalForDirectory:nil file:nil types:nil relativeToWindow: 
cocoaFromCarbonWin];

Then I'm seeing a host of strange and bogus behaviors.

1. The most severe is that the sheet opens BEHIND the application window, BUT 
is still the key window. So, the application is dead --- I can't click on the 
sheet (it's not front, and not active, does not respond to clicks). However, 
the main application window is blocked for events too! (I have blocked it via 
runModalForWindow!). so, I'm dead. User must force-quit the application.

2. The sheet opens in the wrong place -- just somewhere on the screen - not 
always the same place, but "favorably" when a centered dialog would appear. If 
then I try to drag the parent carbon window by its title, the sheet would "jump 
into place" and be dragged right. Events seem to be OK.

3. The sheet is invisible --- Although I get no errors from the application. 
However, the debugger console would (sometimes!) contain lines like this:

[Session started at 2009-10-21 11:01:52 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC 2009)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398] : 
kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1835
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398] : 
kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they 
are logged.
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398] : 
kCGErrorIllegalArgument: CGSOrderWindowListWithGroups: invalid window ID (1835)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398] : 
kCGErrorIllegalArgument: CGSOrderWindowList: NULL list pointer or empty list
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398] : 
kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1836
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398] : 
kCGErrorIllegalArgument: CGSOrderWindowListWithGroups: invalid window ID (1836)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398] : 
kCGErrorIllegalArgument: CGSOrderWindowList: NULL list pointer or empty list

Any ideas? something I forgot to do? What in general is the state of opening 
cocoa-sheets over Carbon-windows? When do I need to release this NSWindow? I 
don't wish to close the Carbon window, as it is coming from my host application!

Thanks a lot again!

Motti Shneor
--
Senior Software Engineer
Waves Audio ltd.


On 15/10/2009, at 21:40, Steve Christensen wrote:

I had written this NSOpenPanel category to work in a plugin
environment, and I think it should do the right thing. Just set up
the NSOpenPanel as you like then call -
runModalForDirectory:file:types:relativeToWindow: 

iPhone: View with "layer" type fading?

2009-10-21 Thread Eric E. Dolecki
I have a view controller I am loading and displaying - using an alpha fade.
However, the elements are all fading at different rates as the whole view
fades in/out. Is there a way to have all the elements fade together (in
Flash we can set an object to have a "layer" blending mode to do the same
kind of thing).
For instance, I have a background image in a UIView, on top of that a
UIWebView, etc. and you can see the individual elements' bounding boxes,
etc. instead of just having the whole thing fade in at once.

Thanks,
Eric
___

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

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

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

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


Re: Hiding tab view items

2009-10-21 Thread BareFeet

Thanks for the reply, Kyle.


 [tabView removeTabViewItem:oldItem]


But isn't that going to destroy the tab item, the view it contains,  
and everything in that view? Can I get it back when that tab view item  
is valid again, or do I have to programmatically create all the objects?


Thanks,
Tom
BareFeet

___

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

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

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

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


Re: Hiding tab view items

2009-10-21 Thread I. Savant

On Oct 21, 2009, at 9:03 AM, BareFeet wrote:


[tabView removeTabViewItem:oldItem]


But isn't that going to destroy the tab item, the view it contains,  
and everything in that view? Can I get it back when that tab view  
item is valid again, or do I have to programmatically create all the  
objects?


  Not if you retain it and assign it to an ivar to keep it around.

--
I.S.


___

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

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

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

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


GC Re: Questions about Nib Object Retention

2009-10-21 Thread Fritz Anderson
All this leads me to the paragraph about top-level objects under  
garbage collection:


===
Mac OS X - garbage collected memory model
Most objects in the graph are kept in memory through strong references  
between the objects. Only the top-level objects in the nib file do not  
have strong references initially. Thus, your code must create strong  
references to these objects to prevent the object graph from being  
released.

===

Does this mean that there's a race between the NIB loader's need to  
create a strong reference and the GC thread's imperative to collect  
the object before it is referenced?


— F

___

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

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

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

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


Re: info gc-roots interpretation

2009-10-21 Thread Joar Wingfors


On 21 okt 2009, at 02.18, Quincey Morris wrote:


When I set this ivar to nil. the results are:

(gdb) info gc-roots 0x2004f9340
Number of roots: 1
Root:
 0 Kind: bytes   rc:   1  Address: 0x000200543b40  Offset:  
0x0008

 1 Kind: object  rc:   0  Address: 0x0002004f9340  Class: Volume


So there's still a live pointer to your Volume instance in a block  
of (GC-controlled) memory at 200543b40+8. That block appears to be  
alive because it has a non-zero reference count.



Quincey is correct, and you can most likely figure out the last piece  
of this puzzle by using MallocStackLogging. In your executable in  
Xcode, or in the shell that launches your app, enable it by setting:


MallocStackLogging=1

Then, once you've run "info gc-roots" to find the rooting reference,  
run malloc_history in a Terminal window (or in GDB using the "shell"  
command):


malloc_history  

...where you replace PID and ADR with the pid of the app and the  
address of the rooting reference respectively.


The last entry in the output of malloc_history will be the allocation  
event for the rooting reference, typically allowing you to understand  
what's going on.


j o a r


___

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

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

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

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


Re: GC Re: Questions about Nib Object Retention

2009-10-21 Thread Bill Bumgarner

On Oct 21, 2009, at 7:45 AM, Fritz Anderson wrote:

> Does this mean that there's a race between the NIB loader's need to create a 
> strong reference and the GC thread's imperative to collect the object before 
> it is referenced?

No;  the objects are strongly referenced by stack or by the de-archival 
mechanism through until well after the reference on your object has been set.

b.bum

___

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

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

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

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


Re: info gc-roots interpretation

2009-10-21 Thread Bill Bumgarner

On Oct 21, 2009, at 1:39 AM, Nick Rogers wrote:

> (gdb) info gc-roots 0x2004f9340
> Number of roots: 1
> Root:
>   0 Kind: bytes   rc:   1  Address: 0x000200543b40  Offset: 
> 0x0008
>   1 Kind: object  rc:   0  Address: 0x0002004f9340  Class: Volume
> 
> Is there a retain cycle problem.
> The memory gathered by this ivar is not freed, as per Obj-Alloc Instrument.
> 
> What shall I make out of these results and how can they lead to refinement 
> (so that all the memory referenced by this ivar is freed)?

"rc: 1" means that the object has been CFRetain'd by something.  That is, 
something somewhere decided that it was going to bypass the collector and has 
failed to call CFRelease when done.

Use the ObjectAlloc instrument in Instruments to track it down. You can also:

set env MallocStackLoggingNoCompact 1
set env AUTO_REFERENCE_COUNT_LOGGING 1

And then use 'info malloc 0x2004f9340'. It'll typically show all 
CFRetain/CFRelease events.  (But not always -- there is a bug that prevents it 
from showing all of 'em.  However, ObjectAlloc works around it.)

b.bum

___

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

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

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

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


Re: GC Re: Questions about Nib Object Retention

2009-10-21 Thread Clark S. Cox III
No, there is no race. While the nib is being loaded, there are plenty  
of references to the objects therein on the stack and in registers.  
These references will keep these objects alive during loading.


If you don't keep a strong reference to these objects during loading  
they will become garbage after nib loading is finished.


Sent from my iPhone

On Oct 21, 2009, at 7:45, Fritz Anderson   
wrote:


All this leads me to the paragraph about top-level objects under  
garbage collection:


===
Mac OS X - garbage collected memory model
Most objects in the graph are kept in memory through strong  
references between the objects. Only the top-level objects in the  
nib file do not have strong references initially. Thus, your code  
must create strong references to these objects to prevent the object  
graph from being released.

===

Does this mean that there's a race between the NIB loader's need to  
create a strong reference and the GC thread's imperative to collect  
the object before it is referenced?


   ― F

___

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

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

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

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

___

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

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

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

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


becomeFirstResponder and keyDown

2009-10-21 Thread gMail.com
Hi,
I would like to detect whether the 'e' key is pressed every time I click on
an NSView. If the view is already the firstResponder, I can quite memorize
that key pressed when keyDown and reuse it when mouseDown. Then I erase it
when keyUp.
But if the user presses the 'e' key when the firstResponder is on another
view, then he clicks on my view, I cannot detect that the 'e' is still
pressed. I have been trying to detect the key already pressed subclassing
becomeFirstResponder but I get nothing. Any idea?

- (BOOL)becomeFirstResponder
{
unsigned inteventMask = NSKeyDownMask;
NSEvent  *theEvent = [[self window]
nextEventMatchingMask:eventMask untilDate:nil
inMode:NSEventTrackingRunLoopMode dequeue:YES];

NSEventTypeeventType = [theEvent type];
if(eventType == NSKeyDown){
mCharCurrentlyPressed = [[theEvent charactersIgnoringModifiers]
   characterAtIndex:0];
NSLog(@"becomeFirstResponder %c", mCharCurrentlyPressed );
}

return YES;
}


Best Regards
-- 
LL


___

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

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

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

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


Sending a Selector to another Class.

2009-10-21 Thread Joshua Garnham
How would I send a Selector to another class?
I know to send it to a selector in the same file you do 
[self performSelector:@selector(doSomething)];

and for sending it to another class I've tried 
[otherClass performSelector:@selector(doSomethingElse)];

But I just get an error in the Debugger saying
+[otherClass doSomethingElse]: unrecognized selector sent to class 0xe5c4

What have I done wrong?

Thanks.



___

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

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

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

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


Re: Sending a Selector to another Class.

2009-10-21 Thread I. Savant

On Oct 21, 2009, at 12:23 PM, Joshua Garnham wrote:


How would I send a Selector to another class?
I know to send it to a selector in the same file you do
[self performSelector:@selector(doSomething)];

and for sending it to another class I've tried
[otherClass performSelector:@selector(doSomethingElse)];

But I just get an error in the Debugger saying
+[otherClass doSomethingElse]: unrecognized selector sent to class  
0xe5c4


What have I done wrong?


  You seem to be missing the very basics of Objective-C (and I'd dare  
to say object-oriented programming topics in general). You should (re) 
read the introductory material in the documentation and take advantage  
of places like cocoadevcentral.com (free articles) to get a handle on  
this.


The Objective-C Programming Language
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html

Cocoa Application Tutorial
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjCTutorial/01Introduction/01Introduction.html

CocoaDev Central
http://www.cocoadevcentral.com

--
I.S.


___

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

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

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

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


Re: info gc-roots interpretation

2009-10-21 Thread Nick Rogers

Hi,
Thanks for all the valuable replies.
I tried GC Monitor instrument and this Volume pointer, is referenced  
by (apart from the AppController object) by just 32 bytes (non-object).
Extended detail description shows different non-related objects on  
different runs.

The stack trace in every such run shows a method [Volume setUpTimer].
While a thread is running with target Volume object, I call setUpTimer  
from this thread using [self performSelectorOnMainThread:@selector 
(setUpTimer) withObject:nil waitUntilDone:YES];
So I don't see any direct access to ivars from this thread. The method  
is as follows:


- (void)setUpTimer
{
	timer = [NSTimer timerWithTimeInterval:1.0 target:self  
selector:@selector(myTimerFireMethod:) userInfo:nil repeats:YES];
	[[NSRunLoop currentRunLoop] addTimer:timer  
forMode:NSDefaultRunLoopMode];  //Run loop needs to be running to fire  
the timer

}
Here timer is an ivar in Volume of type NSTimer*. Is setting timer in  
the above method causing the problem?


Here's the myTimerFireMethod:

- (void)myTimerFireMethod:(NSTimer*)theTimer
{
	[self performSelectorOnMainThread:@selector(setUpdateStatus:)  
withObject:[NSNumber numberWithBool:YES] waitUntilDone:NO];

}

Thanks,
Nick

On 21-Oct-2009, at 9:09 PM, Bill Bumgarner wrote:



On Oct 21, 2009, at 1:39 AM, Nick Rogers wrote:


(gdb) info gc-roots 0x2004f9340
Number of roots: 1
Root:
 0 Kind: bytes   rc:   1  Address: 0x000200543b40  Offset:  
0x0008

 1 Kind: object  rc:   0  Address: 0x0002004f9340  Class: Volume

Is there a retain cycle problem.
The memory gathered by this ivar is not freed, as per Obj-Alloc  
Instrument.


What shall I make out of these results and how can they lead to  
refinement (so that all the memory referenced by this ivar is freed)?


"rc: 1" means that the object has been CFRetain'd by something.   
That is, something somewhere decided that it was going to bypass the  
collector and has failed to call CFRelease when done.


Use the ObjectAlloc instrument in Instruments to track it down. You  
can also:


set env MallocStackLoggingNoCompact 1
set env AUTO_REFERENCE_COUNT_LOGGING 1

And then use 'info malloc 0x2004f9340'. It'll typically show all  
CFRetain/CFRelease events.  (But not always -- there is a bug that  
prevents it from showing all of 'em.  However, ObjectAlloc works  
around it.)


b.bum



___

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

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

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

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


Re: Sending a Selector to another Class.

2009-10-21 Thread Shawn Erickson
On Wed, Oct 21, 2009 at 9:23 AM, Joshua Garnham
wrote:

> How would I send a Selector to another class?
> I know to send it to a selector in the same file you do
> [self performSelector:@selector(doSomething)];
>

Why not simply... [self doSomething] ?


> and for sending it to another class I've tried
> [otherClass performSelector:@selector(doSomethingElse)];
>

Why not simply [otherClass doSomethingElse] ?

...aka... Why are you using performSelector in the above?


> But I just get an error in the Debugger saying
> +[otherClass doSomethingElse]: unrecognized selector sent to class 0xe5c4
>
> What have I done wrong?
>

You are sending a message to an object that doesn't respond to that message
(aka no implementation for it). The error message you listed should have
more information about the class of the object you messaged incorrectly,
what does the rest of it say?

Hard to tell what may be going wrong with the limited information you have
posted. I rather not waste time guessing (can think of at least 4 common
things you could be doing wrong).

-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: becomeFirstResponder and keyDown

2009-10-21 Thread Quincey Morris

On Oct 21, 2009, at 09:17, gMail.com wrote:

I would like to detect whether the 'e' key is pressed every time I  
click on
an NSView. If the view is already the firstResponder, I can quite  
memorize
that key pressed when keyDown and reuse it when mouseDown. Then I  
erase it

when keyUp.
But if the user presses the 'e' key when the firstResponder is on  
another

view, then he clicks on my view, I cannot detect that the 'e' is still
pressed. I have been trying to detect the key already pressed  
subclassing

becomeFirstResponder but I get nothing. Any idea?



In other words, you want to use the E key as a modifier key, like  
shift, option, command or control.


There's no really good way to do this, because the problem isn't well- 
defined. If you look at it from one end -- when a key down event  
arrives -- you don't actually know whether there *is* an E key or  
whether *any* key was pressed, because the input system is  
complicated, especially when non-Roman writing systems are involved.  
If you look at it from the other end -- when a particular hardware key  
is pressed -- you're faced with the complexities of deciding which  
hardware key to monitor and how to monitor it.


If you look at it from somewhere in the middle, you can mess around  
with (virtual) key codes, keyboard layout resources, event taps or I  
don't know what else, but the results may still be unreliable.


One basic approach to a good-enough solution is to subclass  
NSApplication and override its sendEvent: method. In the override,  
check for key down and up events, and update a global with the current  
state of the "key", before calling the super implementation. Your  
mouse down method in your custom view can then refer to this global  
state.


However, you'll still have several problems to solve, such as:

-- What if shift-E or option-E is pressed? Simply ignoring modifiers  
is not necessarily an adequate solution, depending on the input method.


-- How does the keyboard event get consumed? For example, if there's  
no responder that handles key down events, you'll get a beep every  
time you press the E key, which probably isn't what you want.


-- Not every event is dispatched via -[NSApplication sendEvent:]. Some  
controls may remove and discard events from the event queue. Some  
controls may handle events in a local modal event loop.



___

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

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

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

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


Re: Sending a Selector to another Class.

2009-10-21 Thread Joshua Garnham
Hi,

That was all that showed up in the debugger, but in the class otherClass there 
is a method called doSomething. 
I have also tried what you suggested - [otherClass doSomethingElse] - but i get 
a warning in xcode, http://cld.ly/7c4la.
(JGManagedObject is what replaces otherClass)

Thanks.




From: Shawn Erickson 
To: Joshua Garnham 
Cc: cocoa-dev@lists.apple.com
Sent: Wednesday, 21 October, 2009 18:02:55
Subject: Re: Sending a Selector to another Class.




On Wed, Oct 21, 2009 at 9:23 AM, Joshua Garnham  
wrote:

>How would I send a Selector to another class?
>>I know to send it to a selector in the same file you do
>>[self performSelector:@selector(doSomething)];
>

Why not simply... [self doSomething] ?
 
>
>and for sending it to another class I've tried
>>[otherClass performSelector:@selector(doSomethingElse)];
>

Why not simply [otherClass doSomethingElse] ?

...aka... Why are you using performSelector in the above?
 
>But I just get an error in the Debugger saying
>>+[otherClass doSomethingElse]: unrecognized selector sent to class 0xe5c4
>
>>What have I done wrong?
>

You are sending a message to an object that doesn't respond to that message 
(aka no implementation for it). The error message you listed should have more 
information about the class of the object you messaged incorrectly, what does 
the rest of it say?

Hard to tell what may be going wrong with the limited information you have 
posted. I rather not waste time guessing (can think of at least 4 common things 
you could be doing wrong).

-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: Sending a Selector to another Class.

2009-10-21 Thread Quincey Morris

On Oct 21, 2009, at 10:02, Shawn Erickson wrote:


But I just get an error in the Debugger saying
+[otherClass doSomethingElse]: unrecognized selector sent to class  
0xe5c4




You are sending a message to an object that doesn't respond to that  
message
(aka no implementation for it). The error message you listed should  
have
more information about the class of the object you messaged  
incorrectly,

what does the rest of it say?


The error message has enough information -- the "+".

The problem is that the OP sent an instance method selector to the  
class object, which obviously doesn't recognize it. That indicated a  
confusion between classes and instances (at a minimum), which drove  
I.S. into the well known demented-schoolmarm-handing-out-homework  
impersonation. :)

___

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

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

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

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


Re: Sending a Selector to another Class.

2009-10-21 Thread Phillip Mills

- Message from joshua.garn...@yahoo.co.uk -


but i get a warning in xcode, http://cld.ly/7c4la.
(JGManagedObject is what replaces otherClass)


That one is usually a case of not importing the JGManagedObject header 
or not declaring the class method in that interface.


___

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

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

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

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


Cocoa Autosizing Control

2009-10-21 Thread Rick Langschultz

Hello everyone,

I am writing an application much like the sketch example. I want to  
include an autosizing-like control found in Interface Builder. Does  
anyone know if such control exists. I was thinking about NSImageView,  
or NSBox to create such a control but neither seems to support what I  
want to do.


Any help would be greatly appreciated. I have googled "Autosizing  
control cocoa" and have even used Google's codesearch to look for  
examples.


Thanks,
Rick Langschultz
___

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

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

Help/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 prevent NSURLDownload from changing my file's name

2009-10-21 Thread Marc Respass

Hi All,

I have searched and can't find an answer to this. I am using  
NSURLDownload in an internal application. I connect to a server and  
download some files. Many times, the file name gets changed. I  
download file.xslt but the download system turns it into  
"file.xslt.xml" and then my app can't find it. Is there any way of  
preventing that?


I modified my download delegate to check for known file types and fix  
the name but new types are showing up so that's not a good solution.  
What I am doing now is,  in  
download:decideDestinationWithSuggestedFilename:, to keep checking for  
an  extension and then put the last one back on so I can keep the  
original filename. That seems kind of hackish but I don't know another  
way to do it.


Thanks a lot
Marc
___

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

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

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

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


Re: Cocoa Autosizing Control

2009-10-21 Thread Kyle Sluder
On Wed, Oct 21, 2009 at 10:49 AM, Rick Langschultz
 wrote:
> I am writing an application much like the sketch example. I want to include
> an autosizing-like control found in Interface Builder. Does anyone know if
> such control exists. I was thinking about NSImageView, or NSBox to create
> such a control but neither seems to support what I want to do.

What do you mean by "autosizing-like control"?  Are you referring to
the autoresize mask editor in IB's size inspector?

Please explain what functionality you're trying to implement
(something like "the user needs to be able to specify the color of the
widget", _not_ "I want to put an NSColorWell on a drawer on a sheet on
a panel").

--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: How to prevent NSURLDownload from changing my file's name

2009-10-21 Thread Jeff Johnson

Hi Marc.

Unfortunately, this is an Apple bug.

What Content-Type does the server return, and can you control that? If  
so, then you can work around the bug by returning a custom Content- 
Type that isn't recognized by other applications.


-Jeff


On Oct 21, 2009, at 1:17 PM, Marc Respass wrote:


Hi All,

I have searched and can't find an answer to this. I am using  
NSURLDownload in an internal application. I connect to a server and  
download some files. Many times, the file name gets changed. I  
download file.xslt but the download system turns it into  
"file.xslt.xml" and then my app can't find it. Is there any way of  
preventing that?


I modified my download delegate to check for known file types and  
fix the name but new types are showing up so that's not a good  
solution. What I am doing now is,  in  
download:decideDestinationWithSuggestedFilename:, to keep checking  
for an  extension and then put the last one back on so I can keep  
the original filename. That seems kind of hackish but I don't know  
another way to do it.


Thanks a lot
Marc


___

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

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

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

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


Re: How to prevent NSURLDownload from changing my file's name

2009-10-21 Thread Marc Respass

Jeff,

Thanks for the response. That is not an acceptable solution for us. I  
had already implemented one hack where I check for a .plist extension  
because one of my users installed Yahoo Chat which took over plist  
files that I was downloading and NSURLDownload was turning them  
into .plist.ychat files. Here is my solution


NSString *extension = [name pathExtension];
NSString *newName = [name stringByDeletingPathExtension];
while(!IsEmpty([newName pathExtension]))
{
extension = [newName pathExtension];
newName = [newName stringByDeletingPathExtension];
}

newName = [newName stringByAppendingPathExtension:extension];
// set downloadPath here
[download setDestination:downloadPath allowOverwrite:YES];

That works fine. What is really needed is some switch to turn off the  
filename modification.


Thanks
Marc

El Oct 21, 2009, a las 2:48 PM, Jeff Johnson escribió:


Hi Marc.

Unfortunately, this is an Apple bug.

What Content-Type does the server return, and can you control that?  
If so, then you can work around the bug by returning a custom  
Content-Type that isn't recognized by other applications.


-Jeff


On Oct 21, 2009, at 1:17 PM, Marc Respass wrote:


Hi All,

I have searched and can't find an answer to this. I am using  
NSURLDownload in an internal application. I connect to a server and  
download some files. Many times, the file name gets changed. I  
download file.xslt but the download system turns it into  
"file.xslt.xml" and then my app can't find it. Is there any way of  
preventing that?


I modified my download delegate to check for known file types and  
fix the name but new types are showing up so that's not a good  
solution. What I am doing now is,  in  
download:decideDestinationWithSuggestedFilename:, to keep checking  
for an  extension and then put the last one back on so I can keep  
the original filename. That seems kind of hackish but I don't know  
another way to do it.


Thanks a lot
Marc




___

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

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

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

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


UINavigationBar tintColor property

2009-10-21 Thread Bob Barnes

hi all,

  I'm using the UINavigationBar tintColor property to modify the  
color of navigation bars and that works fine except that the backItem  
doesn't change color until it's touched (even if the touch doesn't  
result in a tap) or I navigate back. Anyone have any suggestions on  
what to 'poke' to get the back button to redraw?


Bob
___

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

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

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

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


Re: NSSpellChecker -learnWord: how to specify LocalDictionary

2009-10-21 Thread Ross Carter

On Oct 17, 2009, at 6:06 PM, Ross Carter wrote:

In 10.6, there is a spell checking dictionary named LocalDictionary  
that contains words learned outside the context of a particular  
language.


How does one use NSSpellChecker -learnWord: and -unlearnWord: so  
that those methods write to LocalDictionary?


For other language dictionaries, one can send setLanguage: before  
sending learnWord:. But for LocalDictionary, there does not appear  
to be any language string associated with LocalDictionary.


I've tried sending nil, @"", and @"LocalDictionary" to setLanguage:,  
but -learnWord: still writes to my en dictionary.


The use case is for terms such as "developer.apple.com" that should  
be deemed correct in any language.



Evidently, there is no API for programmatically modifying the contents  
of LocalDictionary. I filed a bug.

___

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

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

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

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


Re: UINavigationBar tintColor property

2009-10-21 Thread Luke the Hiesterman
Sadly, this is a known bug. I can't seem to find the bug right now to  
suggest a good work-around. You might have luck forcing the  
navigationBar to layoutSubviews.


Luke

On Oct 21, 2009, at 12:18 PM, Bob Barnes wrote:


hi all,

 I'm using the UINavigationBar tintColor property to modify the  
color of navigation bars and that works fine except that the  
backItem doesn't change color until it's touched (even if the touch  
doesn't result in a tap) or I navigate back. Anyone have any  
suggestions on what to 'poke' to get the back button to redraw?


Bob
___

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

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

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

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


___

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

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

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

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


Re: Cocoa Autosizing Control

2009-10-21 Thread Rick Langschultz


I am sorry, I thought I had explained. Perhaps a little more detail is  
required in my posting.


I am writing an application which can insert objects into a canvas.  
The application has an inspector like Dashcode or Interface Builder.  
Under the ruler view of Interface Builder 3.X there is an autosizing  
control with "springs" that a user can set to make an object expand  
when a window / view resizes, or have the control stay to the left,  
top, right, bottom.


I would like my application to make some use of the same type of  
control. The user would use the inspector and the sizing control to  
set constraints on where the image / other object would remain on the  
screen when the document's window is resized.


Thanks for the heads up on detail, i certainly appreciate it.

Rick

On Oct 21, 2009, at 1:35 PM, Kyle Sluder wrote:


On Wed, Oct 21, 2009 at 10:49 AM, Rick Langschultz
 wrote:
I am writing an application much like the sketch example. I want to  
include
an autosizing-like control found in Interface Builder. Does anyone  
know if
such control exists. I was thinking about NSImageView, or NSBox to  
create

such a control but neither seems to support what I want to do.


What do you mean by "autosizing-like control"?  Are you referring to
the autoresize mask editor in IB's size inspector?

Please explain what functionality you're trying to implement
(something like "the user needs to be able to specify the color of the
widget", _not_ "I want to put an NSColorWell on a drawer on a sheet on
a panel").

--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: Cocoa Autosizing Control

2009-10-21 Thread Jens Alfke


On Oct 21, 2009, at 12:29 PM, Rick Langschultz wrote:

I am writing an application which can insert objects into a canvas.  
The application has an inspector like Dashcode or Interface Builder.  
Under the ruler view of Interface Builder 3.X there is an autosizing  
control with "springs" that a user can set to make an object expand  
when a window / view resizes, or have the control stay to the left,  
top, right, bottom.
I would like my application to make some use of the same type of  
control. The user would use the inspector and the sizing control to  
set constraints on where the image / other object would remain on  
the screen when the document's window is resized.


That's not much like any standard control type. You'd have to  
implement such a control from scratch, i.e. by implementing drawRect,  
mouseDown, etc. I've never heard of a 3rd party implementation.


—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


Webkit and SSL

2009-10-21 Thread Lemon Obrien
I've been making an application using webkit and it doesn't want to work with 
SSL certificates.
I use cocoa and nothing happens, the url is just not navigated to; when i fire 
up the carbon samples using webkit, "CarbonWeb", an alert is popped up saying 
the certificate is bad; but, hey, it works in sakari, IE, etc.
the certificate is generated using java/apache/tomcat; when i navigate to the 
site on the internet, using a certificate generated by goDaddy, purchased, it 
works fine.
as you may know, "localhost" and "www.apple.com" are different; so, is there a 
way to make webkit behave so i can develop the site and the desktop app?
thanks
also, i'm new to apple development; anyone know of really good resources for 
webkit?
thanks in advance
You don't get no juice unless you squeeze

Lemon Obrien, the Third.



http://umakeitcool.com



http://www.tamago.us
___

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

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

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

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


Reading NSInputStream

2009-10-21 Thread Ashley Perrien
I'm writing a small application to get info from a mail server and  
having lots of problems with reading from NSInputStream.  After  
initiating a connection (getStreamsToHost) I don't get an event that  
the input stream has bytes available, if I check it, it returns NO but  
if I go ahead and read it anyway, I get the usual banner. I'm also  
unable to get the buffers working.


So 1) I can't get this working at all:

uint8_t *readBuffer;
unsigned int bufferLength;
BOOL gotBuffer = [readStream getBuffer: &readBuffer length:  
&bufferLength];


The last line always says arguments 1 and/or 2 are incompatible  
pointer type. I've tried every combination of * and &, no luck.


If instead I go with NSData:

if ([readStream hasBytesAvailable])
NSLog(@"Has Bytes");
else
NSLog(@"No Bytes");

NSMutableData *returnMessage = [NSMutableData dataWithLength: 300];
[readStream read: [returnMessage mutableBytes] maxLength: 300];
NSString *readData = [[NSString alloc] initWithBytes: [returnMessage  
bytes] length: 300 encoding: NSUTF8StringEncoding];

NSLog(@"Read: %@", readData);

I get:
No Bytes
Read: 220 mx.google.com ESMTP...

So, how do you go about finding out if there's something available,  
getting a buffer and reading into it? I've searched the archives and  
google, copy and pasted the code and it still returns errors or gets  
results that don't make sense (no bytes available but they read in  
fine).



Ashley Perrien

P.S. I know there are other mail frameworks out there, I'm not looking  
to actually send and receive anything substantial,  just want to  
reliably connect to the server, send ehlo or .capability and capture  
the result, that's all. I've been beating my head against a wall for a  
while now trying to get it to work without knowing if there's actually  
data to be read and how best to do it.

___

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

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

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

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


Re: Cocoa Autosizing Control

2009-10-21 Thread Rick Langschultz

Thanks Jens,

If I implement a good working copy I will certainly put it into github  
or an SVN repo so others can use it. Of course a pre-built view would  
have been nice, I checked out the sproing example on the developer  
sample code.


On Oct 21, 2009, at 2:57 PM, Jens Alfke wrote:



On Oct 21, 2009, at 12:29 PM, Rick Langschultz wrote:

I am writing an application which can insert objects into a canvas.  
The application has an inspector like Dashcode or Interface  
Builder. Under the ruler view of Interface Builder 3.X there is an  
autosizing control with "springs" that a user can set to make an  
object expand when a window / view resizes, or have the control  
stay to the left, top, right, bottom.
I would like my application to make some use of the same type of  
control. The user would use the inspector and the sizing control to  
set constraints on where the image / other object would remain on  
the screen when the document's window is resized.


That's not much like any standard control type. You'd have to  
implement such a control from scratch, i.e. by implementing  
drawRect, mouseDown, etc. I've never heard of a 3rd party  
implementation.


—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: Webkit and SSL

2009-10-21 Thread Jens Alfke


On Oct 21, 2009, at 12:57 PM, Lemon Obrien wrote:

I've been making an application using webkit and it doesn't want to  
work with SSL certificates.

I use cocoa and nothing happens, the url is just not navigated to


It sounds like you didn't implement the WebFrameLoadDelegate or  
WebResourceLoadDelegate methods that inform you of loading errors.


—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: Reading NSInputStream

2009-10-21 Thread Jens Alfke


On Oct 21, 2009, at 1:04 PM, Ashley Perrien wrote:

 After initiating a connection (getStreamsToHost) I don't get an  
event that the input stream has bytes available, if I check it, it  
returns NO but if I go ahead and read it anyway, I get the usual  
banner.


It sounds like you didn't call -scheduleInRunLoop:forMode: ?


uint8_t *readBuffer;
unsigned int bufferLength;
BOOL gotBuffer = [readStream getBuffer: &readBuffer length:  
&bufferLength];
The last line always says arguments 1 and/or 2 are incompatible  
pointer type. I've tried every combination of * and &, no luck.


Try declaring bufferLength as NSUInteger, as it's declared in the docs  
and header.
If that doesn't work you'll have to actually show us the exact error  
message you got.


—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


NSURLDownload and file quarantine

2009-10-21 Thread Wim Lewis
Is there any useful documentation on what the behavior of  
NSURLDownload is supposed to be w.r.t. file quarantine? I'm having a  
hard time getting consistent behavior out of it. I have a program with  
LSFileQuarantineEnabled turned on which downloads a file. The sequence  
of events I see is:
  - NSURLDownload creates the destination file, and it is  
automatically quarantined.
  - -download:didCreateDestination: is called. I can see the  
quarantine attributes on the file.
  - NSURLDownload then *removes* the quarantine information (I can  
see this in the debugger; it's happening in  
URLDownload::updateQuarantineProperties(), called from the  
URLConnectionClient run loop callback).
  - The download continues and finishes, leaving an un-quarantined  
file.


More maddeningly, if I try to add (more accurate) quarantine  
information in -download:didCreateDestination:, it gets obliterated  
later by NSURLDownload.


This seems like buggy behavior, but since the documentation on file  
quarantine is so skimpy, who knows? Perhaps this is intended behavior.  
Anyone know?



___

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

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

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

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


Re: Beach balling on mach_msg_trap

2009-10-21 Thread Ken Thomases

On Oct 21, 2009, at 2:17 AM, Nathan Day wrote:

I am getting a beach balling in an application I am working on, I  
would of investigated more but I have noticed that some other apps  
on my computer seem to be doing the same thing.


If I move my applications window it free up the block allowing an  
event to be processed), but the instantly freezes on the next event,  
this is why I think other applications have the same problem because  
they exhibit the same behaviour, this includes the Applications  
Safari when playing a movie, Quick Time Player but the sound keeps  
playing and a Third party app called Opacity. s this a known issues.


It doesn't affect my MacBook Pro only my iMac and the issue occurred  
in 10.5 and 10.6, I am using an NSOperationQue which may have  
something to do with it.


One thing that is different between my MacBook Pro and iMac is that  
my iMac is nearly always doing something in the background, without  
may app running there is about 15% to 20% cpu usage and about 500  
thread, another difference between my iMac and my MacBook Pro is  
that my iMac has only 37% of 1TB hard disk space, I have heard there  
can be some issues with disk fragmentation at 30% or less hard disk  
space.


(gdb) where
#0  0x00010011ad7a in mach_msg_trap ()
#1  0x00010011b3ed in mach_msg ()
#2  0x00010047fce2 in __CFRunLoopRun ()
#3  0x00010047f03f in CFRunLoopRunSpecific ()
#4  0x00010242ac4e in RunCurrentEventLoopInMode ()
#5  0x00010242aa53 in ReceiveNextEventCommon ()
#6  0x00010242a90c in BlockUntilNextEventMatchingListInMode ()
#7  0x000100fc1520 in _DPSNextEvent ()
#8  0x000100fc0e89 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#9  0x000100f86a7d in -[NSApplication run] ()
#10 0x000100f7f798 in NSApplicationMain ()
#11 0x000134ba in main (argc=1, argv=0x7fff5fbff3c8) at  
XX


This stack trace does not indicate an app that is stuck.  It indicates  
the normal state of an app which is waiting for (and should be  
responsive to) events.


I doubt NSOperationQueue has anything to do with the symptoms you're  
seeing.


The fact that several applications are showing similar symptoms  
suggests there's something wrong with your Mac or your user account.   
I would try creating a new user account and seeing if the problem  
persists there.  Remove or disable any third-party kernel extensions,  
input managers, contextual menu plug-ins, haxies, etc.  Repair and  
Repair Permissions on your boot volume.  If necessary, reapply the  
most recent Combo update to the OS, or even do an Archive and Install  
(although 10.6 eliminated this option).


Unfortunately, if none of this helps, you should take this to a  
general diagnostics discussion forum.  I don't think it has anything  
to do with Cocoa development.


Good luck,
Ken

___

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

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

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

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


Re: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]

2009-10-21 Thread Steve Christensen

On Oct 21, 2009, at 4:11 AM, Motti Shneor wrote:

Hello Steve, and thanks a lot. Your category is exactly what I  
needed. Although I already figured out myself the use of
[NSApp runModalForWindow:] for blocking and the [NSApp:stopModal]  
to release the block, I still enjoyed the way of doing this  
seamlessly via a category. In my case I need 2 categories  for  
NSSavePanel and NSOpenPanel, and some more implementation details.


However... I still have a few questions about your implementation,  
another about another implementation I found in an Apple sample,  
AND this code has TERRIBLY WEIRD and unstable behavior, when  
attaching these NSSavePanel sheets to a (Cocoa-wrapper of) Carbon  
Window.


So. First, I'd like to know, why you call on [NSApp endSheet:self];  
after the modal loop is ended? If I'm not wrong, the "sheetDidEnd"  
selector is only called AFTER the sheet has been dismissed, closed,  
and released. I tried without calling this, and could see no  
difference in behavior. Isn't there a problem in calling this when  
no sheet is open?


In the docs for -[NSSavePanel   
beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector: 
contextInfo:], it says that the selector "method is invoked [...]  
after the modal session has ended, but before dismissing the Save  
panel. didEndSelector may dismiss the Save panel itself; otherwise it  
will be dismissed on return from the method," so the sheet hasn't  
actually been dismissed at that point. I believe I included it in  
case [NSApp runModalForWindow:self] failed for some reason to make  
sure the sheet was always removed.


Second. In another Apple Sample, which does almost the same, using  
a newer NSSavePanel 10.6 API's , there's something like


NSSavePanel *navPanel = [NSSavePanel savePanel];
[navPanel beginSheetModalForWindow: [sender window]
completionHandler:^(NSInteger result)
{
NSLog(@"Save panel dismissed - callback block reached.");
if (result == NSOKButton) {
[navPanel orderOut:self]; // close panel before we might present an  
error // [self application:NSApp openFile:[openPanel filename]];

}
[NSApp stopModal]; // end modal mode
}]; // this call exists immediately, but I need to block here, so...
[NSApp runModalForWindow: [sender window]];
}

Here, as you can see, there is another call .[navpanel  
orderout:self]; Again, isn't the conclusion block called AFTER the  
sheet was dismissed, closed and released? (my NSSavePanels are  
configured to "releaseWhenClosed"]. Also, what exactly is  
"orderout" ? could'nt figure out from the documentation.


-[NSWindow orderOut:]

Last (and most important) - Supposedly I use your nice category  
like this:


WindowRef frontWin = ::FrontWindow();  // get Carbon application  
front window. Actually, any carbon window.
NSWindow *cocoaFromCarbonWin = [[NSWindow alloc]  
initWithWindowRef:frontWin];

NSSavePanel *navPanel = [NSSavePanel savePanel];
[navPanel runModalForDirectory:nil file:nil types:nil  
relativeToWindow: cocoaFromCarbonWin];


Then I'm seeing a host of strange and bogus behaviors.

1. The most severe is that the sheet opens BEHIND the application  
window, BUT is still the key window. So, the application is dead  
--- I can't click on the sheet (it's not front, and not active,  
does not respond to clicks). However, the main application window  
is blocked for events too! (I have blocked it via  
runModalForWindow!). so, I'm dead. User must force-quit the  
application.


2. The sheet opens in the wrong place -- just somewhere on the  
screen - not always the same place, but "favorably" when a centered  
dialog would appear. If then I try to drag the parent carbon window  
by its title, the sheet would "jump into place" and be dragged  
right. Events seem to be OK.


3. The sheet is invisible --- Although I get no errors from the  
application. However, the debugger console would (sometimes!)  
contain lines like this:


[Session started at 2009-10-21 11:01:52 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18  
20:40:51 UTC 2009)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]  
: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1835
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]  
: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to  
catch errors as they are logged.
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]  
: kCGErrorIllegalArgument: CGSOrderWindowListWithGroups:  
invalid window ID (1835)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]  
: kCGErrorIllegalArgument: CGSOrderWindowList: NULL list  
pointer or empty list
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]  
: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1836
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]  
: kCGErrorIllegalArgument: CGSOrderWindowListWithGroups:  
invalid window ID (1836)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]  
: kC

NSColor for darker hightlight color

2009-10-21 Thread Eric Gorr
If, in the Appearance settings, I set my highlight color to blue and  
then select an item in the finder, the blue color used is darker then  
the color shown in the Appearance Settings.


Is there a NSColor method which will return this darker shade to me?

Is it alternateSelectedControlTextColor?

Now, the one other aspect is whether or not this documentation  
continues to be accurate:


Accessing System Colors
NSColor has a number of methods that return system colors: colors  
controlled by user preferences. These colors—currently only  
selectedControlColor and selectedTextBackgroundColor—should be used by  
developers who want to create custom controls or subclass existing  
controls while honoring the user's color preferences.


If so, then it may not be appropriate for me to use  
alternateSelectedControlTextColor (for example) - however, neither  
selectedControlColor nor selectedTextBackgroundColor will return this  
darker shade of blue.___


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

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

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

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


Re: How to run a panel that customizes a new NSDocument

2009-10-21 Thread Ben Haller

On 21-Oct-09, at 12:57 AM, Graham Cox wrote:


On 21/10/2009, at 3:43 PM, Ben Haller wrote:


There must be a good, clean way to do this.  Anyone?


Well, the expected way is to have different types for your  
documents. You can still map them all to the same class, and  
discriminate in the -initWithType:error: method to set up the  
appropriate model.


However, if you really can't or don't want to do that, I think what  
you've done is right. Because you have a special designated  
initializer, you have no option but to manually make the controllers  
and add the document to the controller.


  OK, I've switched over to an NSDocumentController and using  
different types for my different models.  That turned out to be a  
forced move, because NSApplication's delegate method - 
applicationOpenUntitledFile: does not get called when the user chooses  
New from the File menu; that seems to go right to  
NSDocumentController.  -applicationOpenUntitledFile: only seems to get  
called for the new document created when an app is launched or brought  
front without an open document.  I could have started changing the  
actions for menu items and so forth, but I decided that since my app  
is document-based, I ought to go with the document architecture.  So I  
now have an NSDocumentController subclass, and I override  
openUntitledDocumentAndDisplay:error:.  That seems to be in the code  
path for all kinds of new documents.
  However, I still find this architecture quite unsatisfying.  My - 
openUntitledDocumentAndDisplay:error: subclass still needs to do way  
too much work:


- (id)openUntitledDocumentAndDisplay:(BOOL)displayDocument error: 
(NSError **)outError

{
NSString *chosenModelName = [AKNewModelController runNewModelPanel];

if (chosenModelName)
{
NSError *error = nil;
		AKDocument *document = [self  
makeUntitledDocumentOfType:chosenModelName error:&error];


if (error)
{
if (outError)
*outError = error;
return nil;
}

[self addDocument:document];

if (displayDocument)
{
[document makeWindowControllers];
[document showWindows];
}

return document;
}

return nil;
}

  The sequence of -makeUntitledDocumentOfType:error:, then  
makeWindowControllers, then showWindows, is already in super, but I  
don't have any way to make super do it.  So I have to duplicate that  
sequence in my own code, which makes my code vulnerable to  
architectural changes in NSDocument.  I gather this sequence has  
already changed at least once in the past, so it is clearly fragile.
  There really must be a better way to do this; I feel like I'm  
running at counter purposes to the design of the framework.  Anyone  
have any better suggestions?
  I'm curious as to why -makeUntitledDocumentOfType:error: doesn't do  
the work of adding the document, setting up its windowController,s and  
showing the windows.  That would seem like the natural design to me,  
rather than making everyone that calls that method do that work  
themselves.  Is there a reason for this design?


Ben Haller
Stick Software

___

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

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

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

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


Services keep activating themselves?

2009-10-21 Thread Nick Zitzmann

I searched around, and couldn't find anything about this...

I noticed that, whenever a service is handled by a non- 
LSBackgroundOnly application in Snow Leopard, the private  
NSServiceHandler class always calls -[NSApp  
activateIgnoringOtherApps:] and makes the application activate.


How do I get it to stop this? I don't want this to happen, and I  
suppose I can resort to hackery to stop this, but I'm hoping there's a  
better way. And making this LSUIElement app into an LSBackgroundOnly  
app is not an option here.


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 to run a panel that customizes a new NSDocument

2009-10-21 Thread Ben Haller

On 21-Oct-09, at 6:55 PM, Ben Haller wrote:

 OK, I've switched over to an NSDocumentController and using  
different types for my different models.  That turned out to be a  
forced move, because NSApplication's delegate method - 
applicationOpenUntitledFile: does not get called when the user  
chooses New from the File menu; that seems to go right to  
NSDocumentController.  -applicationOpenUntitledFile: only seems to  
get called for the new document created when an app is launched or  
brought front without an open document.  I could have started  
changing the actions for menu items and so forth, but I decided that  
since my app is document-based, I ought to go with the document  
architecture.  So I now have an NSDocumentController subclass, and I  
override openUntitledDocumentAndDisplay:error:.  That seems to be in  
the code path for all kinds of new documents.
 However, I still find this architecture quite unsatisfying.  My - 
openUntitledDocumentAndDisplay:error: subclass still needs to do way  
too much work:


  Furthermore, the way I have it coded now does not even work.   
Clicking cancel in my "choose a model" window returns a nil string to  
my NSDocumentController subclass - 
openUntitledDocumentAndDisplay:error:, and I see that nil and  
immediately return nil myself, since the user has cancelled.  That  
results in a raise from the Kit:


#0  0x964ef688 in objc_msgSend ()
#1  0x93d7e9e6 in -[NSDocumentController(NSInternal)  
_fixedFailureReasonFromError:] ()

#2  0x93d7c2fd in -[NSDocumentController _willPresentCreationError:] ()
#3  0x9393d2d4 in -[NSDocumentController(NSInternal) _openUntitled] ()
#4  0x9393d109 in -[NSApplication _doOpenUntitled] ()
#5  0x9393c7ed in -[NSApplication(NSAppleEventHandling)  
_handleAEOpen:] ()


  Apparently if -openUntitledDocumentAndDisplay:error: is called, it  
*must* create a new document, otherwise it is a raise-worthy error.   
So my whole design is once again invalid.  I'm not even sure how I  
might fix it.  Overriding -newDocument instead doesn't seem to be an  
option, because it doesn't have any way to pass on the type chosen to  
the rest of the call chain.  The docs for -newDocument say this:


It invokes openUntitledDocumentAndDisplay:error: with the document  
type (first argument) being the first one specified in the  
CFBundleDocumentTypes property (defined in Info.plist); the document  
type determines the NSDocument subclass used to instantiate the  
document object.


  But that seems to be obsolete; the document type is not passed to - 
openUntitledDocumentAndDisplay:error: at all.  I wish it were; then  
overriding -newDocument would clearly be the right architecture.


  This is driving me crazy.  Tons of apps want to do this (run a  
panel on a new document request, and make a new document configured  
based on the results of that panel).  There must be an easy way to do  
it in the NSDocument architecture; I'm just trying to tap in at the  
wrong point, somehow.  Help!


Ben Haller
Stick Software

___

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

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

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

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


Re: How to run a panel that customizes a new NSDocument

2009-10-21 Thread Quincey Morris

On Oct 21, 2009, at 15:55, Ben Haller wrote:

 OK, I've switched over to an NSDocumentController and using  
different types for my different models.  That turned out to be a  
forced move, because NSApplication's delegate method - 
applicationOpenUntitledFile: does not get called when the user  
chooses New from the File menu; that seems to go right to  
NSDocumentController.  -applicationOpenUntitledFile: only seems to  
get called for the new document created when an app is launched or  
brought front without an open document.  I could have started  
changing the actions for menu items and so forth, but I decided that  
since my app is document-based, I ought to go with the document  
architecture.  So I now have an NSDocumentController subclass, and I  
override openUntitledDocumentAndDisplay:error:. That seems to be in  
the code path for all kinds of new documents.
 However, I still find this architecture quite unsatisfying.  My - 
openUntitledDocumentAndDisplay:error: subclass still needs to do way  
too much work:


- (id)openUntitledDocumentAndDisplay:(BOOL)displayDocument error: 
(NSError **)outError

{
[...]
}

 The sequence of -makeUntitledDocumentOfType:error:, then  
makeWindowControllers, then showWindows, is already in super, but I  
don't have any way to make super do it.  So I have to duplicate that  
sequence in my own code, which makes my code vulnerable to  
architectural changes in NSDocument.  I gather this sequence has  
already changed at least once in the past, so it is clearly fragile.
 There really must be a better way to do this; I feel like I'm  
running at counter purposes to the design of the framework.  Anyone  
have any better suggestions?
 I'm curious as to why -makeUntitledDocumentOfType:error: doesn't do  
the work of adding the document, setting up its windowController,s  
and showing the windows.  That would seem like the natural design to  
me, rather than making everyone that calls that method do that work  
themselves.  Is there a reason for this design?


I don't understand why you think you can't invoke [super  
openUntitledDocumentAndDisplay: displayDocument error: outError]  
immediately after displaying your initial-state-choosing dialog.  
Because of the need to pass a customized type string? In that case,  
stash the type in a subclass instance variable and override  
defaultType to return it. Alternately, put the initial state in a  
global variable and consult that variable in your NSDocument subclass  
initWithType: -- that's a bit ugly, but it's safe enough because this  
all needs to be done on the main thread anyway.


On Oct 21, 2009, at 16:16, Ben Haller wrote:

Clicking cancel in my "choose a model" window returns a nil string  
to my NSDocumentController subclass - 
openUntitledDocumentAndDisplay:error:, and I see that nil and  
immediately return nil myself, since the user has cancelled. That  
results in a raise from the Kit:


If you're using the code you posted earlier (snipped out above), then  
you're not returning an error object when you return nil at the end of  
the method.



___

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

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

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

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


Re: NSColor for darker hightlight color

2009-10-21 Thread Graham Cox


On 22/10/2009, at 9:25 AM, Eric Gorr wrote:

If so, then it may not be appropriate for me to use  
alternateSelectedControlTextColor (for example) - however, neither  
selectedControlColor nor selectedTextBackgroundColor will return  
this darker shade of  
blue.___



One easy way to help you find and choose colours is to use the  
'Developer' colour picker, which shows up in the colour panel. It  
lists all these colours by name and shows you the colour, so it's easy  
to see at a glance which one is which. I'm not sure if this picker  
gets installed automatically by one of the dev tools (maybe IB?) but  
it's been in my colour panel forever.


--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: Reading NSInputStream

2009-10-21 Thread Ashley Perrien
After initiating a connection (getStreamsToHost) I don't get an  
event that the input stream has bytes available, if I check it, it  
returns NO but if I go ahead and read it anyway, I get the usual  
banner.


It sounds like you didn't call -scheduleInRunLoop:forMode: ?


Covered. See below for full code.


uint8_t *readBuffer;
unsigned int bufferLength;
BOOL gotBuffer = [readStream getBuffer: &readBuffer length:  
&bufferLength];
The last line always says arguments 1 and/or 2 are incompatible  
pointer type. I've tried every combination of * and &, no luck.


Try declaring bufferLength as NSUInteger, as it's declared in the  
docs and header.


D'oh, thanks, that fixed that problem. Still getting strange issues  
though with this code:


[NSStream getStreamsToHost: mailHost port: mailPortNumber inputStream:  
&readStream outputStream: &writeStream];


mailHost and mailPortNumber are imap.gmail.com and 587 if that matters  

Both streams are retained, setDelegate: self, scheduleInRunLoop and  
open.


if ([readStream hasBytesAvailable])
NSLog(@"Has Bytes");
else
NSLog(@"No Bytes");

This always returns No Bytes

uint8_t *readBuffer;
NSUInteger bufferLength;
	BOOL gotBuffer = [readStream getBuffer: &readBuffer length:  
&bufferLength];


gotBuffer always == NO and bufferLength of 0.

int len = [readStream read: readBuffer maxLength: 300];

len always == 0 and the buffer is empty.

NSMutableData *returnMessage = [NSMutableData dataWithLength: 300];
[readStream read: [returnMessage mutableBytes] maxLength: 300];
	NSMutableString *readData = [[[NSMutableString alloc] initWithBytes:  
[returnMessage bytes] length: 300 encoding: NSUTF8StringEncoding]  
autorelease];

NSLog(@"Read: %@", readData);
return readData;

This will always work as expected:
Read: 220 mx.google.com ESMTP...
But only if I don't read from the stream twice. If all of the above  
code is run, it fails with "Program received signal:   
“EXC_BAD_ACCESS”." If I comment out the int len = [readStream...  
section, the NSMutableData section reads fine and gets data.


It's almost is if the NSMutableData is making it up but the docs say  
dataWithLength returns a zeroed out object.




___

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

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

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

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


Re: NSColor for darker hightlight color

2009-10-21 Thread Eric Gorr


On Oct 21, 2009, at 7:34 PM, Graham Cox wrote:



On 22/10/2009, at 9:25 AM, Eric Gorr wrote:

If so, then it may not be appropriate for me to use  
alternateSelectedControlTextColor (for example) - however, neither  
selectedControlColor nor selectedTextBackgroundColor will return  
this darker shade of  
blue.___



One easy way to help you find and choose colours is to use the  
'Developer' colour picker, which shows up in the colour panel. It  
lists all these colours by name and shows you the colour, so it's  
easy to see at a glance which one is which. I'm not sure if this  
picker gets installed automatically by one of the dev tools (maybe  
IB?) but it's been in my colour panel forever.


Interesting. I've looked a little, but cannot seem to find this color  
picker. Anyone know where it can be found?


___

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

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

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

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


Re: NSColor for darker hightlight color

2009-10-21 Thread Kyle Sluder
On Wed, Oct 21, 2009 at 4:51 PM, Eric Gorr  wrote:
> Interesting. I've looked a little, but cannot seem to find this color
> picker. Anyone know where it can be found?

Google for "developer color picker" --> http://www.panic.com/~wade/picker/

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


Developer Color Picker ( was Re: NSColor for darker hightlight color )

2009-10-21 Thread Eric Gorr


On Oct 21, 2009, at 8:00 PM, Kyle Sluder wrote:

On Wed, Oct 21, 2009 at 4:51 PM, Eric Gorr   
wrote:

Interesting. I've looked a little, but cannot seem to find this color
picker. Anyone know where it can be found?


Google for "developer color picker" --> http://www.panic.com/~wade/picker/


Well, in my own defense, I did...but used http://bit.ly/macdev

But, I agree, I should have used the entire google search engine.

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: info gc-roots interpretation

2009-10-21 Thread Joar Wingfors


On 21 okt 2009, at 09.44, Nick Rogers wrote:

Here timer is an ivar in Volume of type NSTimer*. Is setting timer  
in the above method causing the problem?



Timers retain (RC) / strongly reference (GC) their targets. In general  
you should keep a reference to the timer so that you can invalidate it  
when you don't need it any more - This is in particular important for  
repeating timers.


j o a r


___

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

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

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

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


Re: correctly Controlling Garbage Collection

2009-10-21 Thread Sean McBride
On 10/16/09 2:17 AM, WareTo Development said:

>So we thought the best thing would be to force a garbage collection
>operation at a time of our choosing.  Normally, this occurs at Mouse
>up, after the user has finished his drawing. A split second of garbage
>collection then would be barely noticeable by the user.
>
>So, we looked for a call, and thanks to this list we found
>objc_collect (OBJC_EXHAUSTIVE_COLLECTION | OBJC_WAIT_UNTIL_DONE);
>.
>Unfortunately, this does not solve our problem. That call does not
>insure a garbage collection operation synchronously, nor shortly after
>one returns to the main event loops. It does seem to cause one a short
>time later, but by then the user might be drawing with the pen again.
>
>We saw that a couple other people complained about this call not doing
>what they expected, but this was a while back, and we have not seen
>any new discussions about it

In my experience, this has not changed in 10.6.1.
OBJC_EXHAUSTIVE_COLLECTION | OBJC_WAIT_UNTIL_DONE does not do what its
name implies.  Which is a real shame because it would be useful for debugging.

--

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


___

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

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

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

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


Re: Reading NSInputStream

2009-10-21 Thread Greg Guerin

Ashley Perrien wrote:


uint8_t *readBuffer;


At this point, readBuffer is an uninitialized local variable.


NSUInteger bufferLength;
BOOL gotBuffer = [readStream getBuffer: &readBuffer length:  
&bufferLength];


This use of readBuffer is safe, because it's passed by reference, and  
the caller expects it to be filled in.  However, it will only be  
filled in if YES is returned.



int len = [readStream read: readBuffer maxLength: 300];


This use of readBuffer is unsafe.  If readBuffer is not initialized  
before this point, then you are reading using a garbage pointer.  If  
the getBuffer:length: method was invoked first, and returned YES,  
then you may have a buffer overrun instead of a garbage pointer  
dereference.  If it was invoked and returned NO, then readBuffer may  
contain anything.


Or maybe readBuffer is safe, because you neglected to post the code  
that initializes it to point to an actual memory buffer of suitable  
length.


Really can't tell, because you're only posting isolated code  
fragments, instead of complete and self-contained fragments that show  
the entire context.




[readStream read: [returnMessage mutableBytes] maxLength: 300];


You're neglecting the return value, which indicates the actual number  
of bytes read.  You're probably lucking out that the mutableBytes  
have been zeroed, so any data less than 300 bytes ends up with a  
terminating nul character.


  -- GG

___

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

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

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

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


Re: NSColor for darker hightlight color

2009-10-21 Thread Jonathan Hendry
There's a 'Developer' color list in the color list pane of the  
standard color picker.


- Jon

On Oct 21, 2009, at 19:51 PM, Eric Gorr wrote:



On Oct 21, 2009, at 7:34 PM, Graham Cox wrote:



On 22/10/2009, at 9:25 AM, Eric Gorr wrote:

If so, then it may not be appropriate for me to use  
alternateSelectedControlTextColor (for example) - however, neither  
selectedControlColor nor selectedTextBackgroundColor will return  
this darker shade of  
blue.___



One easy way to help you find and choose colours is to use the  
'Developer' colour picker, which shows up in the colour panel. It  
lists all these colours by name and shows you the colour, so it's  
easy to see at a glance which one is which. I'm not sure if this  
picker gets installed automatically by one of the dev tools (maybe  
IB?) but it's been in my colour panel forever.


Interesting. I've looked a little, but cannot seem to find this  
color picker. Anyone know where it can be found?


___

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

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

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

This email sent to jonhen...@mac.com


___

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

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

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

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


Using dealloc method in a class that have only class methods

2009-10-21 Thread Tharindu Madushanka
Hi

I have created a class with only class methods in it and a single static
instance variable allocated only one with a class method. Do I need to add a
-(void) dealloc: method to this class. Could someone kindly explain.

Thank you,

Tharindu Madushanka
tharindufit.wordpress.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: NSColor for darker hightlight color

2009-10-21 Thread Rob Keniger

On 22/10/2009, at 10:26 AM, Jonathan Hendry wrote:

> There's a 'Developer' color list in the color list pane of the standard color 
> picker.


Yes, and I believe this is the picker that Graham was referring to. It shows 
all the NSColor named colors that reflect the current appearance. To see it, 
open the standard color picker, go to the third tab "Color Palettes" and select 
"Developer" from the Palette popup to get this list of colors.

The "developer color picker" linked by Kyle is totally different, it allows you 
to sample colors from the screen and get an NSColor/CGColorRef definition. 
Useful, but not what the OP requires.

--
Rob Keniger



___

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

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

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

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


Re: Using dealloc method in a class that have only class methods

2009-10-21 Thread Nick Zitzmann


On Oct 21, 2009, at 6:41 PM, Tharindu Madushanka wrote:

I have created a class with only class methods in it and a single  
static
instance variable allocated only one with a class method. Do I need  
to add a

-(void) dealloc: method to this class. Could someone kindly explain.


No. You only need to implement -dealloc if you create instances of a  
class that retain certain objects or register as observers of  
something. If you create a class method-only class, then there will be  
no instances of that class, so there's nothing to deallocate.


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 to run a panel that customizes a new NSDocument

2009-10-21 Thread Ben Haller

On 21-Oct-09, at 7:23 PM, Quincey Morris wrote:


On Oct 21, 2009, at 15:55, Ben Haller wrote:

OK, I've switched over to an NSDocumentController and using  
different types for my different models.  That turned out to be a  
forced move, because NSApplication's delegate method - 
applicationOpenUntitledFile: does not get called when the user  
chooses New from the File menu; that seems to go right to  
NSDocumentController.  -applicationOpenUntitledFile: only seems to  
get called for the new document created when an app is launched or  
brought front without an open document.  I could have started  
changing the actions for menu items and so forth, but I decided  
that since my app is document-based, I ought to go with the  
document architecture.  So I now have an NSDocumentController  
subclass, and I override openUntitledDocumentAndDisplay:error:.  
That seems to be in the code path for all kinds of new documents.
However, I still find this architecture quite unsatisfying.  My - 
openUntitledDocumentAndDisplay:error: subclass still needs to do  
way too much work:


- (id)openUntitledDocumentAndDisplay:(BOOL)displayDocument error: 
(NSError **)outError

{
[...]
}

The sequence of -makeUntitledDocumentOfType:error:, then  
makeWindowControllers, then showWindows, is already in super, but I  
don't have any way to make super do it.  So I have to duplicate  
that sequence in my own code, which makes my code vulnerable to  
architectural changes in NSDocument.  I gather this sequence has  
already changed at least once in the past, so it is clearly fragile.
There really must be a better way to do this; I feel like I'm  
running at counter purposes to the design of the framework.  Anyone  
have any better suggestions?
I'm curious as to why -makeUntitledDocumentOfType:error: doesn't do  
the work of adding the document, setting up its windowController,s  
and showing the windows.  That would seem like the natural design  
to me, rather than making everyone that calls that method do that  
work themselves.  Is there a reason for this design?


I don't understand why you think you can't invoke [super  
openUntitledDocumentAndDisplay: displayDocument error: outError]  
immediately after displaying your initial-state-choosing dialog.  
Because of the need to pass a customized type string? In that case,  
stash the type in a subclass instance variable and override  
defaultType to return it. Alternately, put the initial state in a  
global variable and consult that variable in your NSDocument  
subclass initWithType: -- that's a bit ugly, but it's safe enough  
because this all needs to be done on the main thread anyway.


  Both of those options seem more than a little bit ugly to me.  They  
depend quite intimately on the behavior of the NSDocument  
architecture, and the ordering of events.  If, for example,  
NSDocumentController decided to make a different new document in the  
middle of this process, for whatever reason (and processing multiple  
documents for opening or printing makes that seem not implausible),  
both of these workarounds could backfire.


Clicking cancel in my "choose a model" window returns a nil string  
to my NSDocumentController subclass - 
openUntitledDocumentAndDisplay:error:, and I see that nil and  
immediately return nil myself, since the user has cancelled. That  
results in a raise from the Kit:


If you're using the code you posted earlier (snipped out above),  
then you're not returning an error object when you return nil at the  
end of the method.


  Well, two points in response to that.  One, the NSError  
documentation says:


In general, a method should signal an error condition by—for example— 
returning NO or nil rather than by the simple presence of an error  
object. The method can then optionally return an NSError object by  
reference, in order to further describe the error.


  So if the NSError is required, that seems questionable.
  More importantly, however, if I do make an NSError object and pass  
it back, then the NSDocument architecture displays an error panel to  
the user that says "No document could be created"!  Since the user has  
just clicked Cancel, that is obviously wrong.  If I select New in  
Interface Builder, then cancel out of it, I don't get a panel warning  
me that a new document could not be created.


  Is anybody at Apple reading this thread?  I'd really like to get  
advice from somebody who knows how this architecture was intended to  
be used.  I can't imagine that such a simple, common usage pattern  
falls through cracks in the design.  I must simply be using the  
framework incorrectly.  Anyone who has actually implemented a document  
like this care to comment?


Ben Haller
Stick Software

___

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

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


Re: Within UITableViewCell: capturing UISegmentedControl event & Row number?

2009-10-21 Thread Frederick C. Lee
I figured it out.Yes.  That's how it's done.
Thanks for reply!

Ric.

On Mon, Oct 19, 2009 at 1:17 AM, Alexander Spohr  wrote:

> Frederick,
> just an idea - from UIView’s documentation:
>
> tag
> The receiver’s tag, an integer that you can use to identify view objects in
> your application.
> @property(nonatomic) NSInteger tag
>
> Set the tag of each segmented view to the row before you hand it out to the
> table view.
>
>atze
>
>
>
> Am 19.10.2009 um 02:37 schrieb Frederick C.Lee:
>
>  The Environment:
>>  (1) iPhone SDK 3.2.1
>>
>> The Setup:
>>  (1) UITableViewCell is defined within its own XIB...
>>   Interface Builder (XIB):
>>   File's Owner:  View Controller.
>>
>>  (2) UISegmentController's Action Method is defined within the 
>> View Controller; along side
>>   with: UITableViewDataSource & UITableViewDelegate methods.
>>
>>  (3) Elements of the UITableViewCell XIB are linked with the File's Owner:
>>  View Controller.
>>
>> ---
>> The Scenario:
>> I have a UITableView of Cells, each containing one UILabel and one
>> UISegmentedControl.
>> I need to capture BOTH the UISegmentedControl segment index  (via ACTION
>> method)
>> AND the respective table-row number.
>>
>> ---
>> My Problem:
>>  a)  I can  capture the UISegmentControl's index via its respective Action
>> Method
>>   within the  View Controller; but I can not...
>>  b) capture the ROW number.
>>
>> However, I can capture ROW identifier IF I click (press) on the background
>> UIView; but I'm
>> hindered by the UISegmentedControl.
>>
>> ---
>> Question:
>>  What is the best way to do BOTH?
>>
>> (a) Forwarding the event up the responder chain from within the action
>> method doesn't appear to work.
>>Perhaps it's too late.
>>
>> (b) Making a subclass of the UITableViewCell and handling the event
>> manually could work, but I'll
>>loose the benefit of the UISegmentedControl's action method to
>> determine the index.
>>
>> Any ideas?
>>
>> Ric.
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/atze%40freeport.de
>>
>> This email sent to a...@freeport.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: How to run a panel that customizes a new NSDocument

2009-10-21 Thread Adam R. Maxwell

On Oct 21, 2009, at 6:38 PM, Ben Haller wrote:

> On 21-Oct-09, at 7:23 PM, Quincey Morris wrote:
> 
>> On Oct 21, 2009, at 15:55, Ben Haller wrote:
>> 
>>> Clicking cancel in my "choose a model" window returns a nil string to my 
>>> NSDocumentController subclass -openUntitledDocumentAndDisplay:error:, and I 
>>> see that nil and immediately return nil myself, since the user has 
>>> cancelled. That results in a raise from the Kit:
>> 
>> If you're using the code you posted earlier (snipped out above), then you're 
>> not returning an error object when you return nil at the end of the method.
> 
>  Well, two points in response to that.  One, the NSError documentation says:
> 
> In general, a method should signal an error condition by—for 
> example—returning NO or nil rather than by the simple presence of an error 
> object. The method can then optionally return an NSError object by reference, 
> in order to further describe the error.
> 
>  So if the NSError is required, that seems questionable.

No.  If you return nil and the caller passed in an NSError reference, you need 
to return a valid NSError or at least set *outError = nil.  That should fix the 
crash you showed.

In addition, your code must check the return value of [self 
makeUntitledDocumentOfType:error:] like this:

NSError *error;
AKDocument *document = [self makeUntitledDocumentOfType:chosenModelName 
error:&error];
if (nil == document) {
if (outError) *outError = error;
return nil;
}

Checking if (error) is wrong.

>  More importantly, however, if I do make an NSError object and pass it back, 
> then the NSDocument architecture displays an error panel to the user that 
> says "No document could be created"!  Since the user has just clicked Cancel, 
> that is obviously wrong.  If I select New in Interface Builder, then cancel 
> out of it, I don't get a panel warning me that a new document could not be 
> created.

Search for NSUserCancelledError on this page:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Documents/Articles/ErrorHandling.html




smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: How to run a panel that customizes a new NSDocument

2009-10-21 Thread Ben Haller

On 21-Oct-09, at 10:13 PM, Adam R. Maxwell wrote:

No.  If you return nil and the caller passed in an NSError  
reference, you need to return a valid NSError or at least set  
*outError = nil.  That should fix the crash you showed.


In addition, your code must check the return value of [self  
makeUntitledDocumentOfType:error:] like this:


...

Search for NSUserCancelledError on this page:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Documents/Articles/ErrorHandling.html


  Ah, great.  That explains that.  Thanks!

  Any tips on the other half of my question -- of how to correctly  
create the document in the first place, i.e. how to get the user- 
chosen data in to the document object without duplicating code that  
belongs in NSDocumentController?


Ben Haller
Stick Software

___

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

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

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

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


Re: Cocoa-dev Digest, Vol 6, Issue 1522

2009-10-21 Thread Ashley Perrien
Really can't tell, because you're only posting isolated code  
fragments, instead of complete and self-contained fragments that  
show the entire context.


So here's the unadulterated method I'm trying to get working (not very  
useful at this point but if I can get the reading right):


-(void) openConnection {
// next 4 lines are actually set up elsewhere
NSHost *mailHost = [NSHost hostWithName: @"mail.me.com"];
int mailPortNumber = 143;
NSInputStream *readStream;
NSOutputStream *writeStream;

	[NSStream getStreamsToHost: mailHost port: mailPortNumber  
inputStream: &readStream outputStream: &writeStream];


[readStream retain];
[readStream setDelegate: self];
	[readStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:  
NSDefaultRunLoopMode];

[readStream open];

[writeStream retain];
[writeStream setDelegate: self];
	[writeStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:  
NSDefaultRunLoopMode];

[writeStream open];

BOOL youWantThisToWork = YES;

if (youWantThisToWork) {
NSMutableData *returnMessage = [NSMutableData dataWithLength: 
300];
		int bytesRead = [readStream read: [returnMessage mutableBytes]  
maxLength: 300];
		NSMutableString *readData = [[[NSMutableString alloc] initWithBytes:  
[returnMessage bytes] length: 300 encoding: NSUTF8StringEncoding]  
autorelease];

NSLog(@"Read: %d bytes\n%@", bytesRead, readData);
}
// Output: Read: 300 bytes \n * OK [CAPABILITY mmp0841 IMAP4.

else {

if ([readStream hasBytesAvailable])
NSLog(@"Has Bytes");
else
NSLog(@"No Bytes");

uint8_t *readBuffer;
NSUInteger bufferLength;
		BOOL gotBuffer = [readStream getBuffer: &readBuffer length:  
&bufferLength];


if (gotBuffer) {
int len = [readStream read: readBuffer maxLength: 
bufferLength];
if (len <= 0)
NSLog(@"nothing read");
else
NSLog(@"Read: %@", [[[NSString alloc] initWithBytes: readBuffer  
length: bufferLength encoding:NSUTF8StringEncoding] autorelease]);

}
else {
NSLog(@"Did not get a buffer");
}
}
// Output: No Bytes , Did not get a buffer
	// This second section is what I'd like to get working So I can  
actually have some error checking in the code rather than just reading  
and hoping something comes in and it doesn't hang.

}



[readStream read: [returnMessage mutableBytes] maxLength: 300];


You're neglecting the return value, which indicates the actual  
number of bytes read.  You're probably lucking out that the  
mutableBytes have been zeroed, so any data less than 300 bytes ends  
up with a terminating nul character.


I'm not entirely sure why you mention the null character. Even if I  
change the above code to only read 10 bytes the output is:

Read: 10 bytes
* OK [CAPA
So even if all 10 bytes are actually data, it reads it fine. My  
question is, when there obviously is data there to be read  
hasBytesAvailable returns no and so does getBuffer. But if I just grab  
the stream and push it into a data object, it works fine until there  
actually isn't data available and then it just hangs.


I really appreciate any help with this. I'm fairly comfortable with  
cocoa but VERY new to trying the networking side of it. I assume I'm  
missing something small, I just can't figure out what it is.


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: Reading NSInputStream

2009-10-21 Thread Jens Alfke


On Oct 21, 2009, at 4:48 PM, Ashley Perrien wrote:


NSMutableData *returnMessage = [NSMutableData dataWithLength: 300];
[readStream read: [returnMessage mutableBytes] maxLength: 300];
	NSMutableString *readData = [[[NSMutableString alloc]  
initWithBytes: [returnMessage bytes] length: 300 encoding:  
NSUTF8StringEncoding] autorelease];

NSLog(@"Read: %@", readData);
return readData;

This will always work as expected:
Read: 220 mx.google.com ESMTP...


IIRC, the read: method will block until there is data available, even  
if the stream's scheduled with a runloop. So this call is working for  
you, but at the expense of blocking your thread indefinitely until the  
server responds. You should wait for the delegate calls instead to  
notify you that data is available.


But only if I don't read from the stream twice. If all of the above  
code is run, it fails with "Program received signal:   
“EXC_BAD_ACCESS”." If I comment out the int len = [readStream...  
section, the NSMutableData section reads fine and gets data.


Well, from your code it looks like you get the buffer pointer from  
getBuffer: and then try to reuse that pointer when calling read:.  
That's a bad idea — you're telling the stream to copy data into its  
own internal buffer, which is likely to cause confusion or worse. You  
should treat the buffer returned from getBuffer: as read-only.


Have you read the "Stream Programming Guide For Cocoa"?

—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


Interface Builder 3.2 Release Notes

2009-10-21 Thread Kevin Cathey
I would recommend everyone read the Interface Builder 3.2 Release Notes. These 
highlight the new features in Interface Builder 3.2 on Snow Leopard, as well 
some of the issues we've addressed.

I think these might clear up many of the confusions I've seen cropping up on 
the mailing lists.

http://developer.apple.com/mac/library/releasenotes/DeveloperTools/RN-InterfaceBuilder/index.html#//apple_ref/doc/uid/TP40001016-SW17

Enjoy!

Kevin___

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

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

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

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


Re: Cocoa-dev Digest, Vol 6, Issue 1522

2009-10-21 Thread Jens Alfke
OK, the reason reading data doesn't work is because you aren't waiting  
for the delegate calls to tell you that data is available; you're just  
opening the stream and then immediately trying to read. It takes time  
to open a socket and receive data over it.


You should really read the conceptual overview docs for Cocoa streams  
before going any further. They include snippets showing how the  
delegate calls work. Also, the sample code CocoaEcho shows how to  
write a TCP client app that connects to a server and receives data.


—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: NSInputStream / Eventqueue / run in Background

2009-10-21 Thread Jens Alfke


On Oct 21, 2009, at 12:22 AM, co...@weblooks.ch wrote:

It's blocking while I'm transferring some data from an iPhone to the  
mac via

bonjour and press some button in the front...


Bonjour doesn't transfer data. It's only for discovering what services  
are available, not for connecting to them. It sounds as though you're  
using some other API to make a TCP connection, like CFSocket or  
NSStream, and are doing blocking I/O with it instead of waiting for  
notification of data. That's what you should fix instead.


—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


Core data design related question

2009-10-21 Thread Marc Rink

Heyas,

I am quite new to Objective-C (and to some extend to OO concepts as  
well), so please be gentle with me :)


I have a core data based document application that purpose is to  
access a mysql database (i am using the MCP Kit).
The documents in my context are Views that contain different aspects  
of the database (small portions consisting of some tables related to  
each other).

One document contains the connection parameters for the database.

I am switching the views according to Aaron Hillegass' example using a  
view controller (the downloadable examples are http://www.bignerdranch.com/solutions/Cocoa-3rd.tgz) 
.


I want to achive the following:
Upon application start the first view "ConfigViewController" is shown.  
It contains all connection related parameters (such as host, port,  
user, password and database) and a "Connect" button.
Upon clicking the "Connect" button, the connection to the database is  
established. The result is a connection object, that i wanted to pass  
around the different Views.


First approach was to pass the resulting connection to the superclass  
of the view's (all my view's are derived from a custom superclass  
which extends NSViewController). For reasons i dont know, i didnt get  
this to work. The resulting object was invalid (nil) in the other  
view's.


Second approch (and better one imho) is to add a core data entity  
"DBConfiguration" holding all connection parameters (persistent, so  
you dont have to enter the stuff every time) and a transient property  
for the connection object (of type undefined).
I added a Object Controller to my documents xib file, set the mode to  
"Entity" and the entity name to "DBConfiguration".
My Problem now is: The view containing the textfields and the  
"connect" button are in a different xib file (ConfigView.xib, whose  
Files Owner is of Type "ConfigViewController". I dont know how to bind  
the ConfigView's text fields to the Object Controller in MyDocument.xib.


I am still new to the different frameworks and unsure about whether my  
design is acceptable or if i am on a completely wrong way.


Any help would be appriciated!

Thanks
Marc
___

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

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

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

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


Search on Core data Table issue?

2009-10-21 Thread Damien Cooke

Hi All,
Not sure if this is the right place (I am sure someone will let me  
know if it is not)  I have a iPhone application that has a UITable  
view that is backed by core data.  I want to perform a reducing search  
so that only the items starting with the characters entered into the  
search bar are shown.  This is normally done with delegate - (void) 
searchBar:(UISearchBar *)searchBar textDidChange:(NSString *) 
searchText no problem.  I am a little confused as I am new to Core  
Data how to do this.  One of the big problems as I see it is going to  
be updating the interface to let it know what to present.  I assume an  
alternative NSFetchedResultsController needs to be sent to the  
UITableView.


So here are my issues:
1) I assume I need to create a  NSFetchedResultsController with only  
the correct items in it then tell the UITableView to use this as the  
dataSource and reload the table?
2) is there a better way than executing a full sorted fetch and  
removing those objects that do not conform.  ie is there a way of  
doing a select where type fetch?


Thanks in advance and sorry if this is a dumb question.

Regards
Damien




___

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

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

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

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


NSTokenField with both non-editable and editable tokens

2009-10-21 Thread Wouter Schouten
I'd like to be able to type in text and drag readonly elements (tokens) into
a NSTokenField to create a custumizable string format. Like in Apple iWorks
Numers' customize cell format. The user can drag readonly NSTokenCells into
a NSTokenTextField (remaining NSRoundedTokenStyle) and type in plain text
(remaining NSPlainTextTokenStyle). I Subclassed NSTokenFieldCell to a claas
FormatToken so that I can filter out plain text tokens and my FormatToken by
using isKindOfClass: [FormatToken class] (see code below). I'm able to add
my predefined token showing up as a RoundedTokens and add plan text showing
up as PlainTextTokens. The problem is that when I double click the
FormatToken token, NSTokenField jumps to the editing mode and makes it a
normal plain text string. My FormatToken is being replaced by a
NSTokenFieldCell and remains displayed as NSPlainTextTokenStyle. I did set
the setEditable:NO for my FormatToken but it seems when the NSTokenField is
editable, all the Cell are forced editable. Does anyone know how to fix this
problem?


AppDelegate.m

- (void)applicationDidFinishLaunching: (NSNotification *)notification

{

[tokens setTokenStyle: NSPlainTextTokenStyle];

}

- (NSString *)tokenField:(NSTokenField *)tokenField
editingStringForRepresentedObject:(id)representedObject{

NSString* string;

if ([representedObject isKindOfClass: [FormatToken class]]) {

FormatToken* token = representedObject;

string = [token text];

}

else

string = representedObject;

return string;

}



- (NSArray *)tokenField:(NSTokenField *)tokenField
shouldAddObjects:(NSArray*)_tokens atIndex:(
unsigned)index

{

NSEnumerator* enumerator = [_tokens objectEnumerator];

id anObject;

while (anObject = [enumerator nextObject]) {

NSLog (@"%@", [anObject description]);

}

return _tokens;

}



- (NSString *)tokenField:(NSTokenField *)tokenField
displayStringForRepresentedObject:(id)representedObject

{

NSString* string;

if ([representedObject isKindOfClass: [FormatToken class]]) {

FormatToken* token = representedObject;

string = [token text];

}

else

string = representedObject;

return string;

}

- (NSTokenStyle)tokenField:(NSTokenField *)tokenField
styleForRepresentedObject:(id)representedObject

{

if ([representedObject isKindOfClass: [FormatToken class]])

return NSRoundedTokenStyle;

else

return NSPlainTextTokenStyle;

}

- (IBAction)addReadOnlyFromatToken: (id)sender;

{

NSMutableArray* array = [NSMutableArray arrayWithArray:[tokens objectValue
]];

FormatToken* token = [[FormatToken alloc] init];

[token setText: @"Readonly Token"];

[token setEditable: NO]

[array addObject:token];

[tokens setObjectValue: array];

}



FormatToken.m

@implementation FormatToken

- (void)encodeWithCoder:(NSCoder *)encoder

{

[encoder encodeObject:name];

}

- (id)initWithCoder:(NSCoder *)decoder

{

name = [[decoder decodeObject] retain];

return self;

}

- (void)setText:(NSString *)text

{

name = [[NSString alloc] initWithString: text];

}

- (NSString *)text

{

return 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


Applying a Core Image filter to a PDFView, WebView or any view

2009-10-21 Thread Uwe Dauernheim

Hej,

I tried to apply the following CIFilter to a pdfview, webview and/or a  
simple view. I don't get any compiling errors, but it just nothing  
happens. Am I missing a certain initialization part?


#import 
#import 
#import 
...
{
NSArray *filters = nil;
CIFilter *filter = [CIFilter filterWithName:@"CIPointillize"];
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:4.0] forKey:@"inputRadius"];
filters = [NSArray arrayWithObject:filter];

[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:1.5];
[[webView animator] setContentFilters:filters]; // (a)
[[pdfView animator] setContentFilters:filters]; // (b)
[[view animator] setContentFilters:filters]; // (c)
[NSAnimationContext endGrouping];
}

\\\Uwe

___

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

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

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

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


Re: Sending a Selector to another Class.

2009-10-21 Thread Jim Kang
That selector is a unique index that points to a method of a specific class.
Methods themselves belong to a specific class and can't operate outside of
their classes. (They compile down to regular C functions that accept an
additional object parameter.)
So, it doesn't make sense to use one class's selector on another class.
Maybe these two classes should inherit from a common parent that has the
method you want to share.

On Wed, Oct 21, 2009 at 12:23 PM, Joshua Garnham  wrote:

> How would I send a Selector to another class?
> I know to send it to a selector in the same file you do
> [self performSelector:@selector(doSomething)];
>
> and for sending it to another class I've tried
> [otherClass performSelector:@selector(doSomethingElse)];
>
> But I just get an error in the Debugger saying
> +[otherClass doSomethingElse]: unrecognized selector sent to class 0xe5c4
>
> What have I done wrong?
>
> Thanks.
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/jimkang%40gmail.com
>
> This email sent to jimk...@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: Displaying a view modally

2009-10-21 Thread Saurabh Sharan
Check out SFHudView by Buzz Andersen (
http://github.com/ldandersen/scifihifi-iphone/blob/master/UI/SFHFHUDView.h)
Saurabh

On Tue, Oct 20, 2009 at 5:26 PM, Mike Manzano
wrote:

> Hi,
>
> I'd like to display a busy indicator view (HUD) regardless of whatever view
> is currently at the top of the view stack. I'd also like this view to
> display modally so that the user interface beneath it is dead to touch
> events. This is like Tweetie 2's HUD that appears when you've successfully
> posted something to Instapaper, with the difference that the UI underneath
> it wouldn't accept events as they do in Tweetie 2. I'd also like to have
> some control over animating the HUD onto and off of the screen.
>
> My current thinking is to find the topmost view controller somehow and send
> it presentModalViewController:animated:. However, I don't know how much
> control over animation I'd get with that method as the built-in animation
> styles sort of assume a full screen view. Also, I've never tried to use this
> method with a view that's smaller than the screen size.
>
> Another thought is to just add the view to the root view and bring it to
> the top (this however won't make the view modal as the views below will
> still respond to touch events).
>
> Can anyone tell me if I'm thinking along the right directions? I'd like to
> have some confirmation before I invest a bunch of time only to find out it's
> the wrong method.
>
> Thanks,
>
> Mike Manzano
> mike (at) instantvoodoomagic (dot) com
> http://instantvoodoomagic.com
> @instantvoodoo
>
> Oh BTW, the first reply that gets me closer to a solution gets a free promo
> code for Newsie (http://instantvoodoomagic.com/newsie), the Google Reader
> client for iPhone/iPod touch that I just released ;)
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> http://lists.apple.com/mailman/options/cocoa-dev/saurabh.sharan%40isharan.com
>
> This email sent to saurabh.sha...@isharan.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: Sending a Selector to another Class.

2009-10-21 Thread Jens Alfke


On Oct 21, 2009, at 9:43 AM, Jim Kang wrote:

That selector is a unique index that points to a method of a  
specific class.


No, that's not true of Objective-C (although it is of C++ method- 
pointers.) A selector is, basically, just a unique string: it defines  
a message, not a method, to use the old Smalltalk OOP terminology. Any  
class that implements a method with that name uses the same selector  
for it, regardless of inheritance.


To be specific, if I create two unrelated classes A and B, each of  
which implements a -foo method, the selector @selector(foo) is used  
for both.


Joshua's problem was, apparently, that he was trying to send an  
message to a class object instead of an instance, but the  
corresponding method was defined on instances, not the class.


—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


NSTokenField with both non-editable and editable tokens

2009-10-21 Thread Wouter Schouten
I'd like to be able to type in text and drag readonly elements  
(tokens) into a NSTokenField to create a custumizable string format.  
Like in Apple iWorks Numers' customize cell format. The user can drag  
readonly NSTokenCells into a NSTokenTextField (remaining  
NSRoundedTokenStyle) and type in plain text (remaining  
NSPlainTextTokenStyle). I Subclassed NSTokenFieldCell to a claas  
FormatToken so that I can filter out plain text tokens and my  
FormatToken by using isKindOfClass: [FormatToken class] (see code  
below).  I'm able to add my predefined token showing up as a  
RoundedTokens and add plan text showing up as PlainTextTokens. The  
problem is that when I double click the FormatToken token,  
NSTokenField jumps to the editing mode and makes it a normal plain  
text string. My FormatToken is being replaced by a NSTokenFieldCell  
and remains displayed as NSPlainTextTokenStyle. I did set the  
setEditable:NO for my FormatToken but it seems when the NSTokenField  
is editable, all the Cell are forced editable. Does anyone know how to  
fix this problem?


- (NSString *)tokenField:(NSTokenField *)tokenField  
displayStringForRepresentedObject:(id)representedObject{


NSString * string;

if ([representedObject isKindOfClass: [FormatToken class]]) {

FormatToken * token = representedObject;

string = [token text];

} else

string = representedObject;

return string;

}


- (NSTokenStyle)tokenField:(NSTokenField *)tokenField  
styleForRepresentedObject:(id)representedObject{


if ([representedObject isKindOfClass: [FormatToken class]])

return NSRoundedTokenStyle;

else return NSPlainTextTokenStyle;

}


- (IBAction)addReadOnlyFromatToken: (id)sender;{

	SMutableArray * array = [NSMutableArray arrayWithArray:[tokens  
objectValue]];


FormatToken * token = [[FormatToken alloc] init];
[token setText: @"Readonly Token"];

[token setEditable: NO]

[array addObject:token];

[tokens setObjectValue: array];

}
___

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

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

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

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


Re: Sending a Selector to another Class.

2009-10-21 Thread Joshua Garnham
Ah, I see. so I need to send it to an instance of the class not the class it 
self.
How would I do that?


Thanks,
Josh.



From: Jens Alfke 
To: Jim Kang 
Cc: Joshua Garnham ; cocoa-dev@lists.apple.com
Sent: Thursday, 22 October, 2009 6:21:29
Subject: Re: Sending a Selector to another Class.



On Oct 21, 2009, at 9:43 AM, Jim Kang wrote:

That selector is a unique index that points to a method of a specific class.
>

No, that's not true of Objective-C (although it is of C++ method-pointers.) A 
selector is, basically, just a unique string: it defines a message, not a 
method, to use the old Smalltalk OOP terminology. Any class that implements a 
method with that name uses the same selector for it, regardless of inheritance.

To be specific, if I create two unrelated classes A and B, each of which 
implements a -foo method, the selector @selector(foo) is used for both.

Joshua's problem was, apparently, that he was trying to send an message to a 
class object instead of an instance, but the corresponding method was defined 
on instances, not the class.

—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


"Sticky" Event tracking

2009-10-21 Thread Francisco Tolmasky
I'd like to do some event tracking that is similar to NSMenu's  
"sticky" mode, that is, I'm tracking when the mouse *isn't* down until  
the mouse *does* go down. This is working fine in my code except when  
the user clicks outside my application, into another application's  
window/finder etc. Is there a standard way of handling this case? I've  
searched for some sort of "deactivated" event mask to send to my  
nextEventMatchingMask: call, but couldn't find anything like it.


Thanks,

Francisco
___

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

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

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

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


Re: Sending a Selector to another Class.

2009-10-21 Thread Rob Keniger

On 22/10/2009, at 3:52 PM, Joshua Garnham wrote:

> Ah, I see. so I need to send it to an instance of the class not the class it 
> self.
> How would I do that?


With respect, please understand that your questions are akin to this:

Q. How do I start the car?
A. You turn the key.
Q. How do I drive?
A. ummm

You need to learn the basics of Objective-C, it is very clear that you do not 
understand even the simplest concepts. 

To directly answer your question, you allocate and initialize an instance of 
your class using [[YourClass alloc] init], or using a convenience class method 
or other designated initializer. However, this information is unlikely to help 
you until you invest some time in learning Objective-C.

I personally recommend reading this book:

http://www.amazon.com/Programming-Objective-C-2-0-Stephen-Kochan/dp/0321566157

It's all laid down here though:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/index.html

--
Rob Keniger



___

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

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

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

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


Re: How to run a panel that customizes a new NSDocument

2009-10-21 Thread Quincey Morris

On Oct 21, 2009, at 18:38, Ben Haller wrote:

I don't understand why you think you can't invoke [super  
openUntitledDocumentAndDisplay: displayDocument error: outError]  
immediately after displaying your initial-state-choosing dialog.  
Because of the need to pass a customized type string? In that case,  
stash the type in a subclass instance variable and override  
defaultType to return it. Alternately, put the initial state in a  
global variable and consult that variable in your NSDocument  
subclass initWithType: -- that's a bit ugly, but it's safe enough  
because this all needs to be done on the main thread anyway.


  Both of those options seem more than a little bit ugly to me.   
They depend quite intimately on the behavior of the NSDocument  
architecture, and the ordering of events.  If, for example,  
NSDocumentController decided to make a different new document in the  
middle of this process, for whatever reason (and processing multiple  
documents for opening or printing makes that seem not implausible),  
both of these workarounds could backfire.


1. Yes, there's a defect in the NSDocumentController design which  
makes it awkward to pass an initial state to a new document without  
having to re-implement everything that NSDocumentController does.  
Awkward but not impossible or even difficult. So let's just get over  
it and move on.


2. My second suggestion *in no way* depends on knowing what any method  
of NSDocumentController actually does, except that I consulted the  
documentation for 'newDocument:' to guide me in choosing which method  
to override. If that bugs you, override 'newDocument:' too, to make it  
do what the documentation says it currently does, and you're future- 
proofed until and unless 'openUntitledDocumentAndDisplay:error:' is  
deprecated.


My first suggestion depends on knowing that the type passed to the new  
document instance will be provided by 'defaultType'. It's conceivable  
but extremely unlikely that this is ever going to change, but if that  
bothers you, use the second suggestion.


Your existing code is, in a sense, more dependent on the current  
implementation details of NSDocumentController, because you're trying  
to do what the documentation says that NSDocumentController does.


3. The only ways my second suggestion (and, for all practical  
purposes, my first suggestion) could fail are (a) if documents were  
being created on multiple threads, which can't happen because  
NSDocumentController isn't thread safe, or (b) if  
'openUntitledDocumentAndDisplay:error:' could possibly get called  
recursively, which it doesn't. If you're worried about that, then go  
ahead and use your current implementation, which is perfectly viable  
even if it makes you uncomfortable.


  Well, two points in response to that.  One, the NSError  
documentation says:


In general, a method should signal an error condition by—for example— 
returning NO or nil rather than by the simple presence of an error  
object. The method can then optionally return an NSError object by  
reference, in order to further describe the error.


  So if the NSError is required, that seems questionable.
  More importantly, however, if I do make an NSError object and pass  
it back, then the NSDocument architecture displays an error panel to  
the user that says "No document could be created"!  Since the user  
has just clicked Cancel, that is obviously wrong.  If I select New  
in Interface Builder, then cancel out of it, I don't get a panel  
warning me that a new document could not be created.


  Is anybody at Apple reading this thread?  I'd really like to get  
advice from somebody who knows how this architecture was intended to  
be used.  I can't imagine that such a simple, common usage pattern  
falls through cracks in the design.  I must simply be using the  
framework incorrectly.  Anyone who has actually implemented a  
document like this care to comment?


Huh? You *are* getting advice from somebody who knows how this  
architecture is intended to be used, both from having implemented "a  
document like this", and from having carefully absorbed *extensive*  
discussions on this list of how the NSError** output parameter is  
intended to be used.


Read this:


http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html#//apple_ref/doc/uid/TP40001806-CH204-BAJIIGCC

and note particularly:

Note: Cocoa methods that indirectly return error objects in the  
Cocoa error domain are guaranteed to return such objects if the  
method indicates failure by directly returning nil or NO. With such  
methods, you should always check if the return value is nil or NO  
before attempting to do anything with the NSError object.


NSDocumentController methods play by these specific rules, so your  
overrides must do so too. Returning the "user cancelled" error is a  
special-case refinement of the techn

NSNotificationCentre very slow - normal?

2009-10-21 Thread Graham Cox

Hi all,

I'm profiling some code to find out where it's spending all its time.  
The code is a threaded task that parses a file and turns what it finds  
into a bunch of objects. Some of these files are pretty large,  
generating 25,000+ objects.


Basically after fixing a few slow bits with a useful improvement, I'm  
still looking for more speed. Right now, I find that the code is  
spending 45% of its time in [NSNotificationCenter - 
addObserver:selector:name:object:] which is by far the biggest chunk.  
The call stack leading to this call is taking negligible time, but it  
then spends all its time in here (or specifically, in  
_CFXNotificationRegister which it calls)


My question is, is this a known slow spot? I've never noticed  
NSNotificationCentre being so slow before, and can't think why it  
would be. And of course, what can I do to help it? I've temporarily  
removed the addObserver call in the code and sure enough it goes a lot  
faster. Trouble is, I do need that notification. Any ideas?


--Graham


___

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

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

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

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


Re: NSNotificationCentre very slow - normal?

2009-10-21 Thread Nick Zitzmann


On Oct 22, 2009, at 12:32 AM, Graham Cox wrote:


My question is, is this a known slow spot?


Yes.

I've never noticed NSNotificationCentre being so slow before, and  
can't think why it would be. And of course, what can I do to help  
it? I've temporarily removed the addObserver call in the code and  
sure enough it goes a lot faster. Trouble is, I do need that  
notification. Any ideas?


Don't add thousands of observers. Re-do your design so that one  
observer can process the thousands of objects that need processing  
instead.


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: NSNotificationCentre very slow - normal?

2009-10-21 Thread Kyle Sluder

On Oct 21, 2009, at 11:32 PM, Graham Cox  wrote:

My question is, is this a known slow spot? I've never noticed  
NSNotificationCentre being so slow before, and can't think why it  
would be. And of course, what can I do to help it? I've temporarily  
removed the addObserver call in the code and sure enough it goes a  
lot faster. Trouble is, I do need that notification. Any ideas?


Just dealt with this in a tree controller scenario. In this case, I  
have my tree controller subclass listen for the ItemChanged  
notification unconditionally. It then figures out which node  
represents that item and calls a -noteItemChanged:(NSNotification*) 
aNotification method on it. This is much faster than N different  
observer registrations, because it avoids two bottlenecks: the  
registration side and the dispatch-based-on-notifying-object side.


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