rewriting observed keyPath

2011-02-15 Thread Remco Poelstra
Hi,

I've a "PresetsController" which holds a dictionary containing preset settings 
for my application. The presets contain trees (Mutable Dictionaries) of keys.
To save the GUI code from bothering with tracking the current preset, I want to 
give my PresetController the option to replace a keyPath like 
@"current.parameter.subparameter.value" to 
@"preset2.parameter.subparameter.value".
I implemented it with a valueForUndefinedKey:
- (id) valueForUndefinedKey:(NSString *)key {
if ([key isEqual:@"current"])
return [presets valueForKey:currentPreset]; //presets is a 
NSMutableDicitonary, currentPreset a NSString
else
return [presets valueForKey:key];
}

, returning the dictionary belonging to the current preset. This works for 
setting and reading using keyPaths. It does not work for observing a keyPath 
like @"current.parameter.subparameter.value". How should I implement that? I 
tried monitoring all keyPaths in the dictionaries, and than calling [self 
will/didChange] like:
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object 
change:(NSDictionary *)change context:(void *)context {
NSString *newKeyPath=[keyPath 
stringByReplacingOccurrencesOfString:currentPreset withString:@"current"];

if ([keyPath hasPrefix:currentPreset]) {
if ([[change 
valueForKey:NSKeyValueChangeNotificationIsPriorKey] boolValue])
[self willChangeValueForKey:newKeyPath];
else
[self didChangeValueForKey:newKeyPath];
}
}

but this doesn't trigger anything. If I replace newKeyPath with @"current" than 
all observers will get a trigger, independent of any (sub)parameters.
What would be the correct way to trigger the observers?

Kind regards,

Remco Poelstra

___

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

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

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

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


converting app to a document based app

2011-02-15 Thread Nick Rogers
Hi,
Googled a lot but didn't find anything.
Can some one send definitive steps for converting a non-document based app to a 
document based app.

In my app, there is a MainMenu.nib and an AppController class.
I'd also want to convert the nib to a xib.

I'd really appreciate any help on this.

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


Community Suggestions on Encryption

2011-02-15 Thread Brad Stone
I've been doing a lot of hunting to find a simple way for me to encrypt an 
NSString and NSData.  I've found a bunch of useful blogs like Cocoa Nut 
(http://cocoa-nut.de/?tag=encryption, Deusty:Using OpenSSL in Cocoa 
(http://deusty.blogspot.com/2007/01/using-openssl-in-cocoa.html) and the 
SSCrypto site (http://septicus.com/products/opensource/).  The thing is however 
that these, among others I've found (like "cocoa-ae"s from 2009), are dated.  
The SSCrypto files haven't been updated since 2006 and these blogs are of 
similar age.

My question is simple: can I get this done without having to dive deep into the 
world of OpenSSL?  If so, how?

I have about four NSString iVars and one NSData iVar I want to encrypt.  I 
wrote my own test code to encrypt/decrypt an NSString on the fly and have it 
work with core data transparently to the user.  I'm at the point now where I 
need to replace that test code with something real.  From all I've read, 
OpenSSL is the way to go but I've also read it's very difficult to implement.  
I know nothing about it.  What initially attracted me to SSCrypto is that it's 
simple (i.e. NSData *decryptedText = [crypto decrypt:@"aes256"]) but I'm 
worried about using something relatively old and using a third party framework.

What suggestions does the community have on the best approach?

Thanks
Brad___

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

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

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

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


Nib not awoken

2011-02-15 Thread Bruce Cresanta
Hello,

I am using an NSDocument based application and I'm having trouble with 
the following code:

-(void) analyzePressed
{
NSString * raw = [[[NSString alloc]  initWithBytes:[pageData bytes] 
length:[pageData length] encoding: NSUTF8StringEncoding] retain];
id analyzerdocument = [[NSDocumentController sharedDocumentController] 
openUntitledDocumentOfType:@"AnalyzerType" display:YES];
   
[analyzerdocument setSourceTextView:raw];
   

}

When I create the document off the sharedDocument controller, the nib hasn't 
fully awoken until after the setSourceTextView selector is called.   My File's 
Owner is set correctly with references to a text view.  The setSourceTextView 
is just a wrapper to [sourceTextView setString:string].   How do I make sure 
the nib is loaded before calling my set routine?

Thanks,

Bruce
___

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

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

Help/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: Community Suggestions on Encryption

2011-02-15 Thread Jean-Daniel Dupas

Le 15 févr. 2011 à 16:35, Brad Stone a écrit :

> I've been doing a lot of hunting to find a simple way for me to encrypt an 
> NSString and NSData.  I've found a bunch of useful blogs like Cocoa Nut 
> (http://cocoa-nut.de/?tag=encryption, Deusty:Using OpenSSL in Cocoa 
> (http://deusty.blogspot.com/2007/01/using-openssl-in-cocoa.html) and the 
> SSCrypto site (http://septicus.com/products/opensource/).  The thing is 
> however that these, among others I've found (like "cocoa-ae"s from 2009), are 
> dated.  The SSCrypto files haven't been updated since 2006 and these blogs 
> are of similar age.
> 
> My question is simple: can I get this done without having to dive deep into 
> the world of OpenSSL?  If so, how?
> 
> I have about four NSString iVars and one NSData iVar I want to encrypt.  I 
> wrote my own test code to encrypt/decrypt an NSString on the fly and have it 
> work with core data transparently to the user.  I'm at the point now where I 
> need to replace that test code with something real.  From all I've read, 
> OpenSSL is the way to go but I've also read it's very difficult to implement. 
>  I know nothing about it.  What initially attracted me to SSCrypto is that 
> it's simple (i.e. NSData *decryptedText = [crypto decrypt:@"aes256"]) but I'm 
> worried about using something relatively old and using a third party 
> framework.
> 

For AES (and SHA, and HMAC), use CommonCrypto API which is part of libSystem.

man CCCryptor for details. (or search in Xcode doc).

-- Jean-Daniel




___

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

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

Help/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 NSTerminateLater with a Status Item

2011-02-15 Thread Jeff Johnson

On Feb 14, 2011, at 3:25 PM, jonat...@mugginsoft.com wrote:

> On 14 Feb 2011, at 19:29, Olivier Lance wrote:
> 
>> Hi Jeff,
>> 
>> Well that's what I was afraid to learn...
>> Gotta find a workaround then!
>> 
> I don't know if this would fly or not but...
> 
> Rather than conventionally returning NSTerminateLater you could try, assuming 
> your async driver calls are run loop sources, run the run loop as required 
> within - applicationShouldTerminate.  
> 
> This should allow you the opportunity to get a window on screen (though not 
> necessarily using NSRunAlertPanel), process the user response, await the 
> async callbacks and exit when your cleanup is done.

No, if your app does not return from applicationShouldTerminate: within a 
certain number of seconds, your process will simply be killed.

-Jeff

___

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

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

Help/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: Re: Sharing a model

2011-02-15 Thread Marc Respass
> I had not designed my program as a document-based application because I did 
> not think that I would save and open data files.  However, I have changed my 
> viewpoint.  It might also make implementing your suggestions easier.
> 
Keep in mind that in an NSDocument-based application, your NSDocument subclass 
*is* the model. You can have multiple windows all looking at the same model. 
You can get the document from the window's controller and the window from any 
view in the window. If your custom view is controlled by an NSViewController 
then from the view controller,

id model = [(MyDocument *)self view] window] windowController] document] 
model];

Although I don't recommend that in regular use, there is a connection. The 
default project for an NSDocument-based app hides the fact that the document is 
the model and the window is simply a view into the model. Setting up to use 
more than one window exposes it but it's a really cool feature. You might want 
your graphic view in another window or in a floating window and it'll all be 
tied in to the same underlying model.

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: Nib not awoken

2011-02-15 Thread Ross Carter
On Feb 15, 2011, at 10:49 AM, Bruce Cresanta wrote:

>   I am using an NSDocument based application and I'm having trouble with 
> the following code:
> 
> -(void) analyzePressed
> {
>   NSString * raw = [[[NSString alloc]  initWithBytes:[pageData bytes] 
> length:[pageData length] encoding: NSUTF8StringEncoding] retain];
>   id analyzerdocument = [[NSDocumentController sharedDocumentController] 
> openUntitledDocumentOfType:@"AnalyzerType" display:YES];
>  
>   [analyzerdocument setSourceTextView:raw];
>  
> 
> }
> 
> When I create the document off the sharedDocument controller, the nib hasn't 
> fully awoken until after the setSourceTextView selector is called.   My 
> File's Owner is set correctly with references to a text view.  The 
> setSourceTextView is just a wrapper to [sourceTextView setString:string].   
> How do I make sure the nib is loaded before calling my set routine?

A few things stand out.

First, openUntitledDocumentOfType:display: was deprecated in 10.4. You probably 
want openUntitledDocumentAndDisplay:error:.

Second, I think you wrote "retain" when you meant "autorelease," although that 
has nothing to do with your problem.

Third, I think the place to put code to initialize a new document is in your 
NSDocument subclass. For a new, untitled document, you can override 
initWithType:error:.

Finally, I don't follow how your nib is set up. The File's Owner of a nib is a 
NSTextView? It sounds to me (and forgive me if I am wrong) that your project 
suggests a misunderstanding of the relationship among the document, the window 
controller, the window, and nib that cannot be determined from the information 
provided.

Ross
___

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

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

Help/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: Sharing a model

2011-02-15 Thread Kyle Sluder
On Feb 15, 2011, at 8:50 AM, Marc Respass  wrote:

> Keep in mind that in an NSDocument-based application, your NSDocument 
> subclass *is* the model. You can have multiple windows all looking at the 
> same model. You can get the document from the window's controller and the 
> window from any view in the window. If your custom view is controlled by an 
> NSViewController then from the view controller,

Apple's documentation makes reference to NSDocument as a "model controller." 
Its purpose is to encapsulate your document's model objects, read and write 
them from disk/pasteboard/storage, and manage the view/window controllers that 
dictate te behavior of your UI.

Your actual model objects are conceptually referenced by the NSDocument 
subclass. For a simple document, this might be an NSArray of NSDictionaries, or 
a single NSTextStorage. Most applications will have custom NSObject subclasses 
for their model objects, like Books or Employees.

But if you think about it this way, NSDocument's role becomes a bit clearer. It 
is the place that all the view and window controllers go to in order to get at 
the set of model objects. That description fits the definition of a controller 
quite well, so it's fair to say that NSDocument is a controller. It just sits 
on the other side of a logical division between "model stuff" and "view stuff."

--Kyle Sluder


> 
> id model = [(MyDocument *)self view] window] windowController] document] 
> model];
> 
> Although I don't recommend that in regular use, there is a connection. The 
> default project for an NSDocument-based app hides the fact that the document 
> is the model and the window is simply a view into the model. Setting up to 
> use more than one window exposes it but it's a really cool feature. You might 
> want your graphic view in another window or in a floating window and it'll 
> all be tied in to the same underlying model.
> 
> 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/kyle.sluder%40gmail.com
> 
> This email sent to kyle.slu...@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: rewriting observed keyPath

2011-02-15 Thread Quincey Morris
On Feb 15, 2011, at 05:11, Remco Poelstra wrote:

> I've a "PresetsController" which holds a dictionary containing preset 
> settings for my application. The presets contain trees (Mutable Dictionaries) 
> of keys.
> To save the GUI code from bothering with tracking the current preset, I want 
> to give my PresetController the option to replace a keyPath like 
> @"current.parameter.subparameter.value" to 
> @"preset2.parameter.subparameter.value".
> I implemented it with a valueForUndefinedKey:
> - (id) valueForUndefinedKey:(NSString *)key {
>   if ([key isEqual:@"current"])
>   return [presets valueForKey:currentPreset]; //presets is a 
> NSMutableDicitonary, currentPreset a NSString
>   else
>   return [presets valueForKey:key];
> }
> 
> , returning the dictionary belonging to the current preset. This works for 
> setting and reading using keyPaths. It does not work for observing a keyPath 
> like @"current.parameter.subparameter.value". How should I implement that?

I think you're making this too hard. If you need to observe a key path that 
includes the "current" key, then just define a [derived] "current" property for 
the presets controller (assuming that's the class that has the above code). The 
getter would look like this:

- (NSDictionary*) current {
return [presets valueForKey:currentPreset];
}

The only thing you have to do is make sure that "current" is KVO compliant, 
which means that notifications need to be sent out whenever the underlying 
value changes:

[self willChangeValueForKey: @"current"];
currentPreset = ...
[self didChangeValueForKey: @"current"];

wherever you change the current preset. There are other possible variations, 
depending on what's most convenient with your class:

1. Obviously you could vary this by keeping a pointer to the current preset 
dictionary in an instance variable too.

2. If "currentPreset" is itself a KVO compliant property, you don't need to 
generate KVO notifications manually (the second code fragment). Instead, you'd 
use:

+ (NSSet*) keyPathsForValuesAffectingCurrent {
return [NSSet setWithObject: @"currentPreset"];
}

and write:

self.currentPreset = ...


___

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

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

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

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


Contextual menu commands in the Finder

2011-02-15 Thread David Catmull
So I gather that now that the new 64-bit Finder doesn't support the old CM 
plugin API, the only way to add commands to the Finder's contextual menus is 
with the services API. The problem I'm having with doing it as a service is 
that the commands I want to add should only apply to files in certain 
locations, and it looks like I can only filter by file type. Is there no way to 
filter by location too? 

It looks pretty lame to have to let the commands always appear, and then tell 
the user afterwards, "No, sorry, you can't really do this to that file."

-- 
David Catmull
uncom...@uncommonplace.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: converting app to a document based app

2011-02-15 Thread Quincey Morris
On Feb 15, 2011, at 07:30, Nick Rogers wrote:

> Hi,
> Googled a lot but didn't find anything.
> Can some one send definitive steps for converting a non-document based app to 
> a document based app.

1. Create a new project using the document-based app template.

2. Move the code you need from the old project to the new project.

:)

Seriously, I'd suggest you're better starting over with a new project, rather 
than trying to retrofit document behavior to your existing one. (It's not so 
hard conceptually, but it's too easy to leave stuff out that you don't have to 
think about when starting from the template.)

When moving the code, the basic idea is that much of what's in your 
AppController class gets moved into your document subclass or your document 
window controller subclass. Only behavior that applies to the application as a 
whole gets left behind.

> In my app, there is a MainMenu.nib and an AppController class.
> I'd also want to convert the nib to a xib.

Again, I think you're better off recreating your UI in the MainMenu.xib and 
MyDocument.xib files that the template gives you. The main menu xib has preset 
internal wiring for some menu items, and it's safer just to delete what you 
don't want and add only what's really different from the template. For the 
document xib, you could delete the default window and paste in the window from 
your old nib, but I still think it's safer to completely recreate that file 
too. A couple of hours of grunt work in IB isn't so bad if the alternative is a 
couple of hours of debugging to find some subtly mis-configured piece.

(If you have an existing window nib that you really want to reuse, you can open 
it in IB and re-save it as a xib file. The only essential change would be to 
change File's Owner to your document subclass OR your document window 
controller class.)

___

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

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

Help/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: rewriting observed keyPath

2011-02-15 Thread Remco Poelstra

Hi,

Thanks for your reply.
The problem with this solution is that when I do a setValue:object  
forKeyPath:@"preset0.parameter", and @"preset0" is the current preset,  
than no KVO message is sent to observers observing the @"current"  
variant of the keyPath. That would only happen, if they used the  
actual @"current.parameters" keyPath.

Maybe KVO doesn't support this at all, I'm just hope it will :)

Regards,

Remco Poelstra

Op 15 feb 2011, om 19:51 heeft Quincey Morris het volgende geschreven:


On Feb 15, 2011, at 05:11, Remco Poelstra wrote:

I've a "PresetsController" which holds a dictionary containing  
preset settings for my application. The presets contain trees  
(Mutable Dictionaries) of keys.
To save the GUI code from bothering with tracking the current  
preset, I want to give my PresetController the option to replace a  
keyPath like @"current.parameter.subparameter.value" to  
@"preset2.parameter.subparameter.value".

I implemented it with a valueForUndefinedKey:
- (id) valueForUndefinedKey:(NSString *)key {
if ([key isEqual:@"current"])
		return [presets valueForKey:currentPreset]; //presets is a  
NSMutableDicitonary, currentPreset a NSString

else
return [presets valueForKey:key];
}

, returning the dictionary belonging to the current preset. This  
works for setting and reading using keyPaths. It does not work for  
observing a keyPath like @"current.parameter.subparameter.value".  
How should I implement that?


I think you're making this too hard. If you need to observe a key  
path that includes the "current" key, then just define a [derived]  
"current" property for the presets controller (assuming that's the  
class that has the above code). The getter would look like this:


- (NSDictionary*) current {
return [presets valueForKey:currentPreset];
}

The only thing you have to do is make sure that "current" is KVO  
compliant, which means that notifications need to be sent out  
whenever the underlying value changes:


[self willChangeValueForKey: @"current"];
currentPreset = ...
[self didChangeValueForKey: @"current"];

wherever you change the current preset. There are other possible  
variations, depending on what's most convenient with your class:


1. Obviously you could vary this by keeping a pointer to the current  
preset dictionary in an instance variable too.


2. If "currentPreset" is itself a KVO compliant property, you don't  
need to generate KVO notifications manually (the second code  
fragment). Instead, you'd use:


+ (NSSet*) keyPathsForValuesAffectingCurrent {
return [NSSet setWithObject: @"currentPreset"];
}

and write:

self.currentPreset = ...




___

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

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

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

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


Re: iPhone UISearchDisplayController how to handle memory warning

2011-02-15 Thread Matt Neuburg
[Sorry to pick this up a month-and-a-half later, but I've only just gotten 
around to testing.] I can't reproduce the problem. I constructed a test app 
that I believe is what you're describing:

Navigation Controller
Table View
Table View's header view is a Search Bar
 UISearchBarController with this search bar as its search bar

So, I tap in the search bar and the search bar controller takes over the 
screen, with the search bar at the top. I type something into the search bar 
and table view items appear. I tap in a table view item, and in response to 
tableView:didSelectRowAtIndexPath:, I push a new view controller onto the 
navigation controller's stack.

So far so good. And then when I tap the back button to pop the second view 
controller off the stack and return to my root view, everything is fine. It's 
just as it was before; we're still in the search bar controller's interface, 
the search bar is still at the top of the screen, my text is still in it. I've 
put a log on didReceiveMemoryWarning and I'm not receiving one. I've tried 
causing a memory warning manually, and then of course I receive it, but it 
makes no difference; I still come back to the root view just fine afterwards.

So I'm led to suspect that there's something else odd about the configuration 
in your app, something omitted from the description. m.

On Jan 3, 2011, at 11:24 AM, Donald Largen wrote:

> Thanks for the reply.  I actually had the same idea to start with something 
> simple to recreate the problem.  One of those ideas that come to you .5 secs 
> after you hit the send key.  I eventually resolved the issue.  I did indeed 
> need to handle the memory warning in the ViewController that managed 
> UISeachDisplayController.   When this occurs I need to save off the current 
> search text, release the current instance of UISearchDisplayController, and 
> create a new instance.  Releasing and recreating was the only way I could get 
> the views to behave properly.  Then in the ViewDidLoad set the saved off 
> search text on UISearchBar.  This actually performs the search as if the user 
> typed in the text.
> 
> 
> On Jan 2, 2011, at 3:20 PM, Matt Neuburg wrote:
> 
>> On Sat, 01 Jan 2011 10:36:01 -0600, Donald Largen  said:
>>> Here is my situation.  I have UIViewController, call it ViewControllerA, 
>>> that contains an UITableView and UISearchDisplayController.  
>>> ViewControllerA is the root view controller in a UINavigationController.  
>>> Things seem to work OK, that is I can preform a search, display the 
>>> results, and select a row and push a detail view controller onto the stack, 
>>> call it ViewControllerB.  
>>> 
>>> The problem I am having is when ViewControllerB is displayed I am getting a 
>>> memory warning.  When I navigate back to ViewControllerA the 
>>> UISearchDisplayController did something in response to the memory warning.  
>>> The search bar is gone, the search results table view is gone, the 
>>> navigation bar is gone, and the "source table view" is displayed but has 
>>> been scrolled to the top of the screen.  
>>> 
>>> I am thinking I need to handle this memory warning by recreating the 
>>> UISearchDisplayController but I am not sure.  I have a feeling though I am 
>>> not doing something right in my setup of the UISearchDisplayController.
>> 
>> That's certainly possible, but since you don't show how you set up the 
>> UISearchDisplayController, it's impossible to say more. However, in your 
>> position here's what I would do: create a completely new minimal project 
>> consisting of nothing but a UINavigationController with two 
>> UIViewControllers, the first of which has the UISearchBar controlled by the 
>> UISearchDisplayController. Now convince yourself that this minimal project 
>> does / does not have the problem you describe. If it doesn't, you know it's 
>> due to something else you're doing differently in the real project. m.
>> 
>> --
>> matt neuburg, phd = m...@tidbits.com, 
>> A fool + a tool + an autorelease pool = cool!
>> AppleScript: the Definitive Guide - Second Edition!
>> http://www.apeth.net/matt/default.html#applescriptthings
> 

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


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/op

Re: rewriting observed keyPath

2011-02-15 Thread Kyle Sluder
On Tue, Feb 15, 2011 at 11:09 AM, Remco Poelstra  wrote:
> Thanks for your reply.
> The problem with this solution is that when I do a setValue:object
> forKeyPath:@"preset0.parameter", and @"preset0" is the current preset, than
> no KVO message is sent to observers observing the @"current" variant of the
> keyPath. That would only happen, if they used the actual
> @"current.parameters" keyPath.
> Maybe KVO doesn't support this at all, I'm just hope it will :)

As long as -current and -preset0 return the same object, and that
object is KVO-compliant for @"parameters", then observing
@"current.parameters" and @"preset0.parameters" are equivalent.

--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: converting app to a document based app

2011-02-15 Thread Seth Willits
On Feb 15, 2011, at 7:30 AM, Nick Rogers wrote:

> Can some one send definitive steps for converting a non-document based app to 
> a document based app.

Add an NSDocument subclass, add that class to the list of document types in 
Info.plist. (GUI editor in the Properties tab by Get Info on the application's 
target).

That's all there is to it.


> I'd also want to convert the nib to a xib.

Just do a Save As…

--
Seth Willits



___

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

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

Help/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: Sleep Notification

2011-02-15 Thread Matt Neuburg
On Sat, 12 Feb 2011 13:01:28 -0600, Gordon Apple  said:
>If it exists, could somebody point me to notifiers for sleep/wake in iOS?
>
>I have a comm link that goes down with sleep.  I would like to bring it up
>again on wake (in case the user forgot to disable sleep).  I'm already doing
>this for applicationWillEnterForeground, but that doesn't work for sleep.

What is "sleep" in iOS? The user can lock the screen, but that might or might 
not cause the device to sleep, depending on a zillion other factors. Many 
things can continue happening in the background. The whole concept is a shaky 
one.

If your app is backgrounded, you'll be suspended (freeze-dried) and all your 
code will come to a complete stop, unless you take certain special measure that 
qualify you for prevention of this (e.g. you're producing background audio). In 
that case you'll get applicationWillEnterForeground when coming back to the 
front.

If the screen is locked and your app was in the background, it was already 
suspended and you're covered.

If the question is "How can I cover the case where the screen was locked and is 
now being unlocked and my app is *frontmost*", that is your app becoming 
*active*. Basically for long continuous activities you should pause when the 
app becomes inactive and resume when the app becomes active again. Indeed, you 
will also get the active notification when entering the foreground, so it is a 
very good all-around place to cover resuming from interruptions of any kind. m.

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

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

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

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

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


Re: awakeFromNib on main thread?

2011-02-15 Thread Matt Neuburg
On Mon, 14 Feb 2011 16:57:02 -0800 (PST), Jon Sigman  said:
>I did a search of the docs but didn't find this question addressed...
>During the object instantiation phase of app startup, is every -awakeFromNib 
>method guaranteed to be called on the app's main thread?

If this is a serious concern, just put an assert that the current thread *is* 
the main thread into your awakeFromNib implementation. m.

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

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

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

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

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


Re: converting app to a document based app

2011-02-15 Thread Matt Neuburg
On Tue, 15 Feb 2011 21:00:42 +0530, Nick Rogers  said:
>Hi,
>Googled a lot but didn't find anything.
>Can some one send definitive steps for converting a non-document based app to 
>a document based app.
>

Simply start all over with a fresh document-based app project. (I see now that 
Quincey Morris has said this too.) If this is problematic, your code needed 
refactoring anyway! m.

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

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

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

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

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


Tracking a EXC_BAD_ACCESS when zombies don't work

2011-02-15 Thread Keith Blount
Hello,

I'm trying to debug an EXC_BAD_ACCESS crash in my application and am tearing my 
hair out trying to find the cause. I have NSZombieEnabled set to YES, but this 
isn't providing me with any information (using NSZombieEnabled is always one of 
the first things I try with crashes like this one, and usually it leads to the 
culprit after a bit of work). I've read that zombies don't always help find 
EXC_BAD_ACCESS (for instance if a variable hasn't been initialised or if it's a 
CF type, although I'm not sure if the latter is still true), so presumably this 
is why it's returning nothing for me.

So, all I have to go on is an EXC_BAD_ACCESS, and a backtrace that seems to be 
different every time and usually contains none of my own methods. For instance:


#0  0x9685eed7 in objc_msgSend
#1  0x2601ee00 in ??
#2  0x98d33c6d in _CFAutoreleasePoolPop
#3  0x9867d0aa in NSPopAutoreleasePool
#4  0x9867cfd2 in -[NSAutoreleasePool drain]
#5  0x986c4596 in _NSAppleEventManagerGenericHandler
#6  0x91450f58 in aeDispatchAppleEvent
#7  0x91450e57 in dispatchEventAndSendReply
#8  0x91450d61 in aeProcessAppleEvent
#9  0x9519d389 in AEProcessAppleEvent
#10 0x93b9a9ca in _DPSNextEvent
#11 0x93b99fce in -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:]
#12 0x93b5c247 in -[NSApplication run]
#13 0x93b542d9 in NSApplicationMain
#14 0x3271 in _start
#15 0x31a0 in start

I do at least have a rough idea of the trigger - the trigger is in my page 
layout code. But I've been through the code and everything is initialised and 
I'm not over-releasing anything in that class. I've looked at the places it's 
called from too. (I have a sneaking suspicion it may have something to do with 
init'ing a text view using -initWithFrame:textContainer: which causes the text 
storage to own the text system, but the text storage gets swapped in and out... 
However my app has thousands of people using it, and only a handful have 
experienced these crashes - the trigger seems to be related to tables getting 
laid out too - and it's only today that someone has been able to provide me 
with a file that usually causes this crash when opened.)

If anyone has any suggestions about what I could try next to find the cause, 
I'd be very grateful. I've tried running with ObjectAlloc and Zombies in 
Instruments, but have so far come up blank.

Many thanks and all the best,
Keith


 

Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/
___

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

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

Help/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: Tracking a EXC_BAD_ACCESS when zombies don't work

2011-02-15 Thread Sean McBride
On Tue, 15 Feb 2011 12:41:51 -0800, Keith Blount said:

>I'm trying to debug an EXC_BAD_ACCESS crash in my application and am
>tearing my hair out trying to find the cause. I have NSZombieEnabled set
>to YES, but this isn't providing me with any information (using
>NSZombieEnabled is always one of the first things I try with crashes
>like this one, and usually it leads to the culprit after a bit of work).
>I've read that zombies don't always help find EXC_BAD_ACCESS (for
>instance if a variable hasn't been initialised or if it's a CF type,
>although I'm not sure if the latter is still true), so presumably this
>is why it's returning nothing for me.
>
>So, all I have to go on is an EXC_BAD_ACCESS, and a backtrace that seems
>to be different every time and usually contains none of my own methods.
>For instance:

Have you read:


specifically the CFZombie stuff?

and



Might help...

--

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: Sleep Notification

2011-02-15 Thread Gordon Apple
In accordance with the rules, I suspend timers (I have my own suspendable
timer wrapper class for NSTimer) and I terminate comm links when in the
background.  No problem.  It works.  I get notifications when it
re-activates and can re-establish comm.  Unfortunately, when the iPad screen
goes down, so does the comm link, but there is no notification when it comes
back up to allow re-initialzing the comm link, Bonjour, etc., and be able to
reconnect from the other side.

Currently, my instructions to the users, in such case, is to switch out the
app, then switch back.  That works, because then I get notification.

Someone had a suggestion that I run a repeating 1 sec. timer and store
current time.  If it ever shows being more than, say 2 sec. behind, then
that means it woke up, so reset the comm link.  That might work.


On 2/15/11 2:25 PM, "Matt Neuburg"  wrote:

> On Sat, 12 Feb 2011 13:01:28 -0600, Gordon Apple  said:
>> If it exists, could somebody point me to notifiers for sleep/wake in iOS?
>> 
>> I have a comm link that goes down with sleep.  I would like to bring it up
>> again on wake (in case the user forgot to disable sleep).  I'm already doing
>> this for applicationWillEnterForeground, but that doesn't work for sleep.
> 
> What is "sleep" in iOS? The user can lock the screen, but that might or might
> not cause the device to sleep, depending on a zillion other factors. Many
> things can continue happening in the background. The whole concept is a shaky
> one.
> 
> If your app is backgrounded, you'll be suspended (freeze-dried) and all your
> code will come to a complete stop, unless you take certain special measure
> that qualify you for prevention of this (e.g. you're producing background
> audio). In that case you'll get applicationWillEnterForeground when coming
> back to the front.
> 
> If the screen is locked and your app was in the background, it was already
> suspended and you're covered.
> 
> If the question is "How can I cover the case where the screen was locked and
> is now being unlocked and my app is *frontmost*", that is your app becoming
> *active*. Basically for long continuous activities you should pause when the
> app becomes inactive and resume when the app becomes active again. Indeed, you
> will also get the active notification when entering the foreground, so it is a
> very good all-around place to cover resuming from interruptions of any kind.
> m.
> 
> --
> matt neuburg, phd = m...@tidbits.com, 
> A fool + a tool + an autorelease pool = cool!
> AppleScript: the Definitive Guide - Second Edition!
> http://www.apeth.net/matt/default.html#applescriptthings



___

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

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

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

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


Re: rewriting observed keyPath

2011-02-15 Thread Quincey Morris
On Feb 15, 2011, at 11:27, Kyle Sluder wrote:

> As long as -current and -preset0 return the same object, and that
> object is KVO-compliant for @"parameters", then observing
> @"current.parameters" and @"preset0.parameters" are equivalent.

Kyle beat me to the punch on this part of the answer, but there's one 
additional point -- the preferences controller *also* needs to be KVO compliant 
with "current", otherwise changing "current" will leave observers of 
"current.parameters" out of date. The OP's originally posted attempt at an 
implementation of the "current" property wasn't KVO compliant, but the version 
I suggested was.

___

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

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

Help/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: Sleep Notification

2011-02-15 Thread Laurent Daudelin
Gordon,

I use performSelector:withObject:afterDelay: (not exactly NSTimer but close, I 
would guess), but maybe they don't work exactly the same. I download from the 
Internet on a regular basis. I thought about those cases when the app is put to 
the background to sleep and all other situations depending on the user. I did 
some testing and, so far, I don't have to really make any exception when one of 
those situation occurs. If my app is put to the background and suspended, 
obviously, my performSelector:withObject:afterDelay: obviously don't fire. When 
the app is brought back to the foreground, they will fire if the delay I gave 
has elapsed. I haven't seen any problem so far. So, maybe your handling in your 
timer wrapper class of NSTimer is causing unnecessary problems? Just a wild 
guess. I have no idea what kind of comm links you keep opened, so I could be 
wrong...

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.com

On Feb 15, 2011, at 14:31, Gordon Apple wrote:

> In accordance with the rules, I suspend timers (I have my own suspendable
> timer wrapper class for NSTimer) and I terminate comm links when in the
> background.  No problem.  It works.  I get notifications when it
> re-activates and can re-establish comm.  Unfortunately, when the iPad screen
> goes down, so does the comm link, but there is no notification when it comes
> back up to allow re-initialzing the comm link, Bonjour, etc., and be able to
> reconnect from the other side.
> 
> Currently, my instructions to the users, in such case, is to switch out the
> app, then switch back.  That works, because then I get notification.
> 
> Someone had a suggestion that I run a repeating 1 sec. timer and store
> current time.  If it ever shows being more than, say 2 sec. behind, then
> that means it woke up, so reset the comm link.  That might work.
> 
> 
> On 2/15/11 2:25 PM, "Matt Neuburg"  wrote:
> 
>> On Sat, 12 Feb 2011 13:01:28 -0600, Gordon Apple  said:
>>> If it exists, could somebody point me to notifiers for sleep/wake in iOS?
>>> 
>>> I have a comm link that goes down with sleep.  I would like to bring it up
>>> again on wake (in case the user forgot to disable sleep).  I'm already doing
>>> this for applicationWillEnterForeground, but that doesn't work for sleep.
>> 
>> What is "sleep" in iOS? The user can lock the screen, but that might or might
>> not cause the device to sleep, depending on a zillion other factors. Many
>> things can continue happening in the background. The whole concept is a shaky
>> one.
>> 
>> If your app is backgrounded, you'll be suspended (freeze-dried) and all your
>> code will come to a complete stop, unless you take certain special measure
>> that qualify you for prevention of this (e.g. you're producing background
>> audio). In that case you'll get applicationWillEnterForeground when coming
>> back to the front.
>> 
>> If the screen is locked and your app was in the background, it was already
>> suspended and you're covered.
>> 
>> If the question is "How can I cover the case where the screen was locked and
>> is now being unlocked and my app is *frontmost*", that is your app becoming
>> *active*. Basically for long continuous activities you should pause when the
>> app becomes inactive and resume when the app becomes active again. Indeed, 
>> you
>> will also get the active notification when entering the foreground, so it is 
>> a
>> very good all-around place to cover resuming from interruptions of any kind.
>> m.
>> 
>> --
>> matt neuburg, phd = m...@tidbits.com, 
>> A fool + a tool + an autorelease pool = cool!
>> AppleScript: the Definitive Guide - Second Edition!
>> http://www.apeth.net/matt/default.html#applescriptthings
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/laurent%40nemesys-soft.com
> 
> This email sent to laur...@nemesys-soft.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


Key equivalents for non-menu items

2011-02-15 Thread Randy Widell
I am trying to wrap my mind around something and the Apple docs are just 
not helping.  I am not sure if I am looking in the wrong places or what, 
but I am just not getting it.


Binding a menu item to First Responder and setting a key equivalent for 
the menu item is trivial.


However, what if I want a key equivalent for a command that is not in a 
menu?


I am approaching this from years of Windows experience (which is 
probably part of the problem), so I am looking for something similar to 
an accelerator table.  I essentially duplicated this idea by overriding 
performKeyEquivalent: in a view, iterating through a table looking for a 
key code and modifier flag match, then performing that action.


This "works", but I would have to duplicate this in every view that 
handles that command.


I tried creating a hidden menu with sub-menu items bound to First 
Responder, but this did not work.


Any guidance would be appreciated.
___

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

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

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

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


Re: Key equivalents for non-menu items

2011-02-15 Thread Kyle Sluder
On Tue, Feb 15, 2011 at 5:40 PM, Randy Widell  wrote:
> I am trying to wrap my mind around something and the Apple docs are just not
> helping.  I am not sure if I am looking in the wrong places or what, but I
> am just not getting it.
>
> Binding a menu item to First Responder and setting a key equivalent for the
> menu item is trivial.
>
> However, what if I want a key equivalent for a command that is not in a
> menu?

The canonical answer is, "You make a menu item for it."

> I am approaching this from years of Windows experience (which is probably
> part of the problem), so I am looking for something similar to an
> accelerator table.  I essentially duplicated this idea by overriding
> performKeyEquivalent: in a view, iterating through a table looking for a key
> code and modifier flag match, then performing that action.
>
> This "works", but I would have to duplicate this in every view that handles
> that command.

Would you mind elaborating on the action you're trying to provide a
shortcut for?

--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: Key equivalents for non-menu items

2011-02-15 Thread Randy Widell

On 2/15/11 6:11 PM, Kyle Sluder wrote:

On Tue, Feb 15, 2011 at 5:40 PM, Randy Widell  wrote:

I am trying to wrap my mind around something and the Apple docs are just not
helping.  I am not sure if I am looking in the wrong places or what, but I
am just not getting it.

Binding a menu item to First Responder and setting a key equivalent for the
menu item is trivial.

However, what if I want a key equivalent for a command that is not in a
menu?

The canonical answer is, "You make a menu item for it."


I am approaching this from years of Windows experience (which is probably
part of the problem), so I am looking for something similar to an
accelerator table.  I essentially duplicated this idea by overriding
performKeyEquivalent: in a view, iterating through a table looking for a key
code and modifier flag match, then performing that action.

This "works", but I would have to duplicate this in every view that handles
that command.

Would you mind elaborating on the action you're trying to provide a
shortcut for?

I have a view displaying waveforms.  I would like to have a keyboard 
shortcut that tags a location on the waveforms at the location of the 
mouse cursor.  These commands do not make any sense in the main 
menu...they could go there, but they would be clutter.


I just tried adding a context menu to the view's XIB, assigning the key 
equivalents, and assigning the context menu to the view's menu outlet.  
The commands work if you use them via the menu, but the key equivalents 
did not work.  Using a context menu is too slow for the number of tags 
that generally need to be added anyway.


___

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

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

Help/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: Key equivalents for non-menu items

2011-02-15 Thread Graham Cox

On 16/02/2011, at 2:36 PM, Randy Widell wrote:

> I have a view displaying waveforms.  I would like to have a keyboard shortcut 
> that tags a location on the waveforms at the location of the mouse cursor.  
> These commands do not make any sense in the main menu...they could go there, 
> but they would be clutter.


Just override -keyDown: in your view and do whatever you want. Note though that 
your key equivalents can't be command- because they are processed as 
menu equivalents separately.

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


Animation doesn't reach end value

2011-02-15 Thread Florian Ebeling
Hi,

I try to create a view which creates an effect that is similar to the
Find Indicator in NSTextView. To achieve that there is a view with
text which is animated using CAAnimation objects registered via
setAnimations:. The animated properties are frameSize, frameOrigin and
animatedFontSize, but the triggering property is the "hidden"
property. The whole effect works and looks almost as I imagined it,
but there is one problem: the properties do not reach the final value
(original value in this case, autoreverses is set to YES) after the
animation finishes. When the CABasicAnimation is started with
fromValue 16 and toValue 28, it increases to the toValue, starts to
decrease again, but stops somewhere between 15.6 and 18.0. According
to delegate notification, the animation does finish completely.

The frame properties are animated using CAKeyframeAnimation objects
and show similar problems. They are supposed to run in a
CAAnimationGroup, but for debugging I run only the basic animation of
the font size.

My view is not layer-backed, but after Bill Dudney's book that is
possible. (CAAnimation et. al documentation sounds different on this
point, though.)

Is this fundamentally the right approach? Is it possible that a basic
animation (an autoreversing one) does not reach the final value?

Cheers,
Florian


-- 
Florian Ebeling
florian.ebel...@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


Processing mouse clicks using Quartz events

2011-02-15 Thread Tomáš Znamenáček
Hello!

I have a CGEventTap and I would like to catch mouse click events. Detecting a 
mouse click event is easy, but I don’t want some of the clicks to get processed 
by the rest of the system. And I can’t figure out how.

The system only sends low-level events like mouseUp, mouseDown, mouseDragged 
and so on. When I receive a mouseDown event, I don’t know if it’s a part of a 
mouse click yet, could be a drag event. I have to wait for the following event 
– if it’s a mouseUp, I have a click. But if I want to process the click myself 
and keep it from going down the rest of the event queue, I can’t simply steal 
the mouseUp event, as the previous mouseDown was already sent.

I thought I could delay the mouseDown event and only send it later after 
receiving the corresponding mouseUp, but that feels wrong, I don’t want to 
delay all system mouseDown events just because of my application. Am I missing 
something?

Thank you,
Tomáš Znamenáček 
___

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

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

Help/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: Key equivalents for non-menu items

2011-02-15 Thread mlist0...@gmail.com
On Feb 15, 2011, at 7:36 PM, Randy Widell wrote:

> I would like to have a keyboard shortcut that tags a location on the 
> waveforms at the location of the mouse cursor.  These commands do not make 
> any sense in the main menu...they could go there, but they would be clutter.

Why do you think they wouldn't make sense in the main menu? That's where we put 
them in SoundEdit 16.

A design point: you should not have any operations that can't be invoked using 
a mouse. So you should have a button or menu for these commands of yours.

_murat___

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

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

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

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


Re: Key equivalents for non-menu items

2011-02-15 Thread Randy Widell

On 2/15/11 7:49 PM, Graham Cox wrote:

On 16/02/2011, at 2:36 PM, Randy Widell wrote:


I have a view displaying waveforms.  I would like to have a keyboard shortcut 
that tags a location on the waveforms at the location of the mouse cursor.  
These commands do not make any sense in the main menu...they could go there, 
but they would be clutter.


Just override -keyDown: in your view and do whatever you want. Note though that your 
key equivalents can't be command-  because they are processed as menu 
equivalents separately.

That was essentially what I did first; I was hoping for a better way.  
Thanks, though, I'll keep rolling down that path then.

___

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

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

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

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


Binding to an NSMutableArray

2011-02-15 Thread Lorenzo Thurman
I have an object, Student, that contains firstName and lastName as instance
variables. Student also contains an NSMutableArray of infraction objects
that contains NSString's for the infraction name, location, punishment and
an NSDate. I want to bind these infraction objects to the columns of an
NSTableView. What I've done to make this work is copy the infraction object
to another NSArray when the Student is loaded and binding the table columns
to the NSArrayController associated with this new array. Obviously, this is
suboptimal. It seems to me that I should be able to bind directly to the
infraction as it resides in the Student object, but I just can figure out
how to bind to a particular index within the NSMutableArray within the
Student object. I've looked at some examples here:
http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

but I didn't find anything quite like what I'm doing. I've gone back through
the KVC/KVO documents to see if I'm missing something. Does anyone have any
pointers on how I can go about this? If its possible at all.
TIA
___

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

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

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

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


Re: Processing mouse clicks using Quartz events

2011-02-15 Thread Graham Cox

On 16/02/2011, at 3:53 AM, Tomáš Znamenáček wrote:

> Am I missing something?


I don't know, but we all are. What are you actually trying to do? If you just 
want to process mouse clicks this is surely not the way to go about it.

--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: Binding to an NSMutableArray

2011-02-15 Thread Stephen J. Butler
On Tue, Feb 15, 2011 at 10:37 PM, Lorenzo Thurman  wrote:
> I have an object, Student, that contains firstName and lastName as instance
> variables. Student also contains an NSMutableArray of infraction objects
> that contains NSString's for the infraction name, location, punishment and
> an NSDate. I want to bind these infraction objects to the columns of an
> NSTableView. What I've done to make this work is copy the infraction object
> to another NSArray when the Student is loaded and binding the table columns
> to the NSArrayController associated with this new array. Obviously, this is
> suboptimal. It seems to me that I should be able to bind directly to the
> infraction as it resides in the Student object, but I just can figure out
> how to bind to a particular index within the NSMutableArray within the
> Student object. I've looked at some examples here:
> http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
>
> but I didn't find anything quite like what I'm doing. I've gone back through
> the KVC/KVO documents to see if I'm missing something. Does anyone have any
> pointers on how I can go about this? If its possible at all.

Assuming that your Students are in an NSArray themselves, and that
there exists a Students Array Controller, did you try binding the
Infractions Array Controller to the Students Array
Controller.selection.infractions?
___

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

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

Help/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: Key equivalents for non-menu items

2011-02-15 Thread Randy Widell

On 2/15/11 8:20 PM, mlist0...@gmail.com wrote:

On Feb 15, 2011, at 7:36 PM, Randy Widell wrote:


I would like to have a keyboard shortcut that tags a location on the waveforms 
at the location of the mouse cursor.  These commands do not make any sense in 
the main menu...they could go there, but they would be clutter.

Why do you think they wouldn't make sense in the main menu? That's where we put 
them in SoundEdit 16.

A design point: you should not have any operations that can't be invoked using 
a mouse. So you should have a button or menu for these commands of yours.

_murat
Given the number of tags users add over several hundred pages, it is 
much faster to just point with the mouse, hit a key, and have the 
software enter a tag with a default length that can be modified later if 
need be.  If all the keyboard shortcuts for adding/deleting tags and 
paging are single letters/numbers grouped for one hand, that leaves the 
other hand free to point.


They'll go into context menus for sure, but no one would use them in the 
main menu.

___

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

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

Help/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: Binding to an NSMutableArray

2011-02-15 Thread Lorenzo Thurman




On Feb 15, 2011, at 10:42 PM, "Stephen J. Butler"  
wrote:

> On Tue, Feb 15, 2011 at 10:37 PM, Lorenzo Thurman  
> wrote:
>> I have an object, Student, that contains firstName and lastName as instance
>> variables. Student also contains an NSMutableArray of infraction objects
>> that contains NSString's for the infraction name, location, punishment and
>> an NSDate. I want to bind these infraction objects to the columns of an
>> NSTableView. What I've done to make this work is copy the infraction object
>> to another NSArray when the Student is loaded and binding the table columns
>> to the NSArrayController associated with this new array. Obviously, this is
>> suboptimal. It seems to me that I should be able to bind directly to the
>> infraction as it resides in the Student object, but I just can figure out
>> how to bind to a particular index within the NSMutableArray within the
>> Student object. I've looked at some examples here:
>> http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
>> 
>> but I didn't find anything quite like what I'm doing. I've gone back through
>> the KVC/KVO documents to see if I'm missing something. Does anyone have any
>> pointers on how I can go about this? If its possible at all.
> 
> Assuming that your Students are in an NSArray themselves, and that
> there exists a Students Array Controller, did you try binding the
> Infractions Array Controller to the Students Array
> Controller.selection.infractions?

Yes, the Student objects are in an array themselves managed by an array 
controller. I did try the keypath you suggest above, but the app crashes on 
startup with "...not key value compliant..." errors. I've tried various 
combinations of controller .selectedIndex.infractions, controller 
selectedIbject.infractions,  but nothing works. 

I should add that there are 2 tables side by side in the app. On the left, 3 
columns, fname, lname bound directly to Student object as 
controller.fname/lname and the count of infractions in the third column using 
infractions.@count 
On the right, when a student from the left is highlighted, I want to display 
the infraction name and description for each infraction in the array. So, if it 
were possible, I would expect the keypath to look something like this:
Controller.selection.infractions.@index.infractionName/description
But clearly that can't be done. ___

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

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

Help/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: Binding to an NSMutableArray

2011-02-15 Thread Stephen J. Butler
On Tue, Feb 15, 2011 at 11:08 PM, Lorenzo Thurman  wrote:
> I should add that there are 2 tables side by side in the app. On the left, 3 
> columns, fname, lname bound directly to Student object as 
> controller.fname/lname and the count of infractions in the third column using 
> infractions.@count
> On the right, when a student from the left is highlighted, I want to display 
> the infraction name and description for each infraction in the array. So, if 
> it were possible, I would expect the keypath to look something like this:
> Controller.selection.infractions.@index.infractionName/description
> But clearly that can't be done.

You need two NSArrayControllers: StudentController and
InfractionController. Then these bindings:

- InfractionController: content array bound to StudentController ->
selection -> infractions
- Left table view: StudentController -> arrangedObjects
- Right table view: InfractionController -> arrangedObjects

It works, I just wrote up an example. But unfortunately my
universities file storage is crapping out and I can't share it at the
moment.
___

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

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

Help/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: Binding to an NSMutableArray

2011-02-15 Thread Stephen J. Butler
On Wed, Feb 16, 2011 at 12:05 AM, Stephen J. Butler
 wrote:
> It works, I just wrote up an example. But unfortunately my
> universities file storage is crapping out and I can't share it at the
> moment.

Ahh ha, figured it out. Here's my example:

https://netfiles.uiuc.edu/xythoswfs/webui/_xy-40162946_2-t_hawvqdYX
___

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

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

Help/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: Processing mouse clicks using Quartz events

2011-02-15 Thread Tomáš Znamenáček
> I don't know, but we all are. What are you actually trying to do? If you
> just want to process mouse clicks this is surely not the way to go about it.

I have a system utility application that needs to be triggered by a mouse click 
on certain UI elements. In all applications, not just mine. When the 
application notices the right kind of a mouse click, I want to “steal” the 
event to prevent it from being processed by the system and do something of my 
own.

I looked into NSEvent global monitoring, but that does not allow me to modify 
the events. Is there another way to monitor and change the system mouse events?

T. 
___

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

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

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

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