Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Diederik Meijer | Ten Horses
May I add two questions to this enlightening thread?

1. With ARC, do we still have to worry about string1 leaking in the following 
scenario?

@property (nonatomic, copy) NSString *string1;
…..
self.string1 = @"Hello";
string1 = @"Hello hello";
string1 = @"Hello hello hello";


2. How do the strong, copy and weak keywords in the property declaration affect 
this?

Thanks!

Diederik



Op May 28, 2013, om 10:16 PM heeft Jens Alfke  het volgende 
geschreven:

> 
> On May 28, 2013, at 6:39 AM, Alex Zavatone  wrote:
> 
>> NSString *myString;
> 
> You’ve declared myString as a _mutable_ pointer to an _immutable_ object. If 
> you had declared it as
> 
>   NSString* const myString = @“Hi";
> 
> then the variable itself would be immutable, and the compiler would give you 
> an error if you tried to reassign it. (You often see this style used when 
> declaring a string constant in a header file, since it’s supposed to stay 
> constant and no one should reassign it.)
> 
> Working with C++ will beat this concept into your head (for better or worse).
> 
> —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:
> https://lists.apple.com/mailman/options/cocoa-dev/diederik%40tenhorses.com
> 
> This email sent to diede...@tenhorses.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Core Data never seems to be able to auto-update schema

2013-05-28 Thread Rick Mann
Pity Xcode doesn't automatically make a copy of the model when you make a 
change (after each build).

Thanks.

On May 28, 2013, at 21:14 , Dave Fernandes  wrote:

> I think I have gotten away with that for development purposes in the past, 
> but that isn't the way it is supposed to work. And things have definitely 
> been tightened up as Core Data has evolved. If you want to open old 
> persistent stores, you will need to have a copy of the model that goes with 
> it.
> 
> On 2013-05-29, at 12:02 AM, Rick Mann  wrote:
> 
>> 
>> On May 28, 2013, at 20:50 , Dave Fernandes  
>> wrote:
>> 
>>> Forgive the basic question, but do you still have the old version of the 
>>> model present in your versioned model?
>> 
>> That's an excellent question, and no, I don't. But I still thought I've 
>> successfully added properties without actually making different versions. 
>> During development, I'm making lots of such changes, and I never make a new 
>> file until the previous one has been released in the wild.
>> 
>> -- 
>> Rick
>> 
>> 
>> 
> 


-- 
Rick




___

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

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

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

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Oleg Krupnov
> Why not just create NSString wrappers? By using the 
> -initWithBytesNoCopy:length:encoding:freeWhenDone: method you can avoid it 
> copying the actual C string characters, it literally just becomes a thin 
> wrapper.

In my case it's more about extra calls than extra memory but thanks! Didn't 
know about this.

> For the sake of avoiding something you *assume* to be slow, or inefficient, 
> you've taken the discussion in a direction that is vastly more complicated.


The code in question is frequently used in many places so I think it's worth 
optimization. 

This KISS school of thought has brought Microsoft to building the slow and 
inefficient .NET technology, and it's had a hard time persuading everybody and 
his dog that hardware is evolving faster than they right inefficient code, so 
it was "ok", but ultimately this approach failed. 

While I generally agree that premature optimization is evil, I do not 
understand why I cannot or shouldn't always keep in mind the cost of things I 
am using, and consider more efficient approaches, especially when they are 
simple. (This time it has turned out not simple and not even efficient, so I 
changed my mind). 

The profiler is not a panacea; when you have hundreds of small, 
not-so-efficient pieces of code like this, all you see in profiler is a long 
list of small consumers, totaling in heavy use of objc runtime calls. 

On May 29, 2013, at 1:46 AM, Graham Cox  wrote:

> 
> On 28/05/2013, at 3:46 PM, Oleg Krupnov  wrote:
> 
>> I'd like to have a dictionary using C strings as keys (because I
>> already have const char* strings and would like to spare on creating
>> NSString wrappers)
> 
> 
> 
> 
> K.I.S.S.! If you can prove this approach is a problem by actual profiling, 
> then OK, then you can talk about a more complex solution.
> 
> 
> --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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Core Data never seems to be able to auto-update schema

2013-05-28 Thread Dave Fernandes
I think I have gotten away with that for development purposes in the past, but 
that isn't the way it is supposed to work. And things have definitely been 
tightened up as Core Data has evolved. If you want to open old persistent 
stores, you will need to have a copy of the model that goes with it.

On 2013-05-29, at 12:02 AM, Rick Mann  wrote:

> 
> On May 28, 2013, at 20:50 , Dave Fernandes  wrote:
> 
>> Forgive the basic question, but do you still have the old version of the 
>> model present in your versioned model?
> 
> That's an excellent question, and no, I don't. But I still thought I've 
> successfully added properties without actually making different versions. 
> During development, I'm making lots of such changes, and I never make a new 
> file until the previous one has been released in the wild.
> 
> -- 
> Rick
> 
> 
> 


___

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

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

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

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


Re: Core Data never seems to be able to auto-update schema

2013-05-28 Thread Rick Mann

On May 28, 2013, at 20:50 , Dave Fernandes  wrote:

> Forgive the basic question, but do you still have the old version of the 
> model present in your versioned model?

That's an excellent question, and no, I don't. But I still thought I've 
successfully added properties without actually making different versions. 
During development, I'm making lots of such changes, and I never make a new 
file until the previous one has been released in the wild.

-- 
Rick




___

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

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

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

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


Re: Core Data never seems to be able to auto-update schema

2013-05-28 Thread Dave Fernandes
Forgive the basic question, but do you still have the old version of the model 
present in your versioned model?

On 2013-05-28, at 10:18 PM, Rick Mann  wrote:

> In the past, Core Data was able to deal with a simple addition of a property 
> to an Entity. Now, every time I add a property, I get "Can't find model for 
> source store" errors during auto update.
> 
> I'm using the following options when creating the persistent store 
> coordinator:
> 
>   NSDictionary* options = @{ NSMigratePersistentStoresAutomaticallyOption 
> : @true,
>   NSInferMappingModelAutomaticallyOption 
> : @true };
> 
> Am I doing something wrong?
> 
> Thanks,
> 
> -- 
> Rick
> 
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
> 
> This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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


Core Data never seems to be able to auto-update schema

2013-05-28 Thread Rick Mann
In the past, Core Data was able to deal with a simple addition of a property to 
an Entity. Now, every time I add a property, I get "Can't find model for source 
store" errors during auto update.

I'm using the following options when creating the persistent store coordinator:

NSDictionary* options = @{ NSMigratePersistentStoresAutomaticallyOption 
: @true,
NSInferMappingModelAutomaticallyOption 
: @true };

Am I doing something wrong?

Thanks,

-- 
Rick




___

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

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

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

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


Re: NSMatrix used as menu item's view appears wrong

2013-05-28 Thread Steve Mills
On May 28, 2013, at 18:08:55, Uli Kusterer  wrote:

> My guess is this is what's happening in your case: It "selects" an item 
> number beyond your NSMatrix, and scrolls it into view, thus scrolling your 
> matrix off-screen. Could that be it? I admit I would expect a little 
> "continuation" arrow at the bottom of your menu in that case, though.

Good guess. That was it. Thanks! I'll report the bug too, since it shouldn't do 
that when the selected item is hidden, especially if it does it wrong.

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



___

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

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

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

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


Re: Building an MVC based App for Mac OS X - NOT for iOS

2013-05-28 Thread Uli Kusterer
On 28.05.2013, at 19:28, Quincey Morris  
wrote:
> Similarly, a MVC "view" is not necessarily a view. Rather, it's a component 
> of your app design that interacts with the user. It may be implemented as a 
> window, or as a view, or as a window with a hierarchy of views, or something 
> more complex.

Examples of Cocoa/Mac classes that are views in the MVC sense, but not in the 
NSView/UIView sense:

NSWindow
NSMenu
NSMenuItem
NSCell
Pretty much any NSResponder, though Smalltalk purists might disagree.

Cheers,
-- Uli Kusterer
http://stacksmith.org






___

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

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

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

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


Re: Building an MVC based App for Mac OS X - NOT for iOS

2013-05-28 Thread Uli Kusterer
On 28.05.2013, at 19:01, YT  wrote:
> You have to disconnect the Auto generated Delegate from the Outlets 
> Connection in the File's Owner Object in the IB Doc 
> Please correct me if I am wrong about this point.
> 
> All of you discuss the utilities of the following Controllers. 
> NSWindowController
> NSViewController
> UIViewController
> NSController
> 
> From a nubee Apple App programming point of view they all appear to be 
> similar WHICH MEANS I will have to read more about each to be able to make an 
> intelligent choice that fits my intended purpose. 


My recommendation for reading about Mac programming is this book:



It is very good, and walks you through creating a Mac application, explaining 
things along the way.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."




___

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

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

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

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


Re: Building an MVC based App for Mac OS X - NOT for iOS

2013-05-28 Thread Uli Kusterer
On 28.05.2013, at 19:01, YT  wrote:
> I did run a test and created a NEW Project and checked the box "Create a 
> Document-based App"
> AND no Controller files (.h,.m) were automatically generated. 


 "Controller" is a pattern, not a class name. When you create a document-based 
app, it creates a document class for you. This owns an NSWindowController (by 
default). Usually you put all your controller-ish stuff in the document (which 
is a kind of controller), though you can also subclass NSWindowController and 
have it create one of those, which is done especially if a document can consist 
of several windows.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSMatrix used as menu item's view appears wrong

2013-05-28 Thread Uli Kusterer
On 28.05.2013, at 23:50, Steve Mills  wrote:
> I have a popup whose menu contains 1 item that uses a view, followed by a 
> bunch of hidden menu items. The first time I pop up the menu, it looks 
> correct. Every time after that, the view is scrolled way off the top with 
> only a tiny bit still visible. Screenshots at:


Popup buttons are really intended to be used for selecting from various 
options, each of which is a menu item. As such, they select whatever item was 
last selected, and try to scroll it into view.

My guess is this is what's happening in your case: It "selects" an item number 
beyond your NSMatrix, and scrolls it into view, thus scrolling your matrix 
off-screen. Could that be it? I admit I would expect a little "continuation" 
arrow at the bottom of your menu in that case, though.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.lookandfeelcast.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Greg Parker
On May 28, 2013, at 3:39 PM, Michael Hall  wrote:
> On May 28, 2013, at 5:27 PM, Michael Hall wrote:
>> I thought I saw SHA-1 being used as a general purpose hash function 
>> somewhere sort of surprising recently but I'm not remembering exactly where.
> 
> Ah, sorry to reply to my own but maybe this was it…
> 
> https://news.ycombinator.com/item?id=4036878
> SHA-1is still used in applications such as git as a general purpose hash 
> function.
> 
> Not this particular article where I saw it but I recently signed up on git 
> and think I may of seen it's use then.

For this sort of use I expect SHA-1 is chosen in part because it computes a 
bigger value than a typical hash-table hash. (160 bits for SHA-1 and 256+ for 
SHA-2, versus 32 or 64 for a typical hash table.)

git in particular wants an ID that is as globally unique as possible so 64 bits 
is not enough, is computing a small number of hashes so the extra per-hash 
setup time for a cryptographic hash is less important, and is probably I/O 
bound anyway so the extra CPU time of a cryptographic hash is less important.


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



___

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

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

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

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

Re: NSMapTable with C strings as keys

2013-05-28 Thread Jens Alfke

On May 28, 2013, at 3:39 PM, Michael Hall  wrote:

> https://news.ycombinator.com/item?id=4036878
> SHA-1is still used in applications such as git as a general purpose hash 
> function.
> Not this particular article where I saw it but I recently signed up on git 
> and think I may of seen it's use then.

Not exactly. It’s used in many version control systems as a highly reliable 
checksum to produce unique IDs for revisions, particularly IDs that can’t be 
forged. That’s not the same as a hash function, because in an application like 
this, a hash collision would cause serious problems like data loss. (That’s why 
you use something with 160 bits of output not 32!)

I’m sure these Git revision IDs do get used as hash keys at some point in some 
algorithms, but that’s not really their purpose (if you already have a SHA 
digest it’s cheaper to use it directly as a hash code than running its 160 bits 
through an in-memory hash algorithm, but it’s not necessary.)

—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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSMapTable with C strings as keys

2013-05-28 Thread Graham Cox

On 28/05/2013, at 3:46 PM, Oleg Krupnov  wrote:

> I'd like to have a dictionary using C strings as keys (because I
> already have const char* strings and would like to spare on creating
> NSString wrappers)


For the sake of avoiding something you *assume* to be slow, or inefficient, 
you've taken the discussion in a direction that is vastly more complicated.

Why not just create NSString wrappers? By using the 
-initWithBytesNoCopy:length:encoding:freeWhenDone: method you can avoid it 
copying the actual C string characters, it literally just becomes a thin 
wrapper.

K.I.S.S.! If you can prove this approach is a problem by actual profiling, then 
OK, then you can talk about a more complex solution.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Nib image caching

2013-05-28 Thread Nick Zitzmann

On May 28, 2013, at 4:25 PM, James West  wrote:

> Does anyone know if nibs cache images or not inside of UIImageView?

They don't. IIRC early versions of OS X allowed this, but it was taken out 
pretty quickly.

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Michael Hall
On May 28, 2013, at 5:27 PM, Michael Hall wrote:

> I thought I saw SHA-1 being used as a general purpose hash function somewhere 
> sort of surprising recently but I'm not remembering exactly where.


Ah, sorry to reply to my own but maybe this was it…

https://news.ycombinator.com/item?id=4036878
SHA-1is still used in applications such as git as a general purpose hash 
function.

Not this particular article where I saw it but I recently signed up on git and 
think I may of seen it's use then.

Michael Hall

trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz

HalfPipe Java 6/7 shell app http://www195.pair.com/mik3hall/index.html#halfpipe

AppConverter convert Apple jvm to openjdk apps 
http://www195.pair.com/mik3hall/index.html#appconverter





___

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

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

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

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

Re: NSMapTable with C strings as keys

2013-05-28 Thread Michael Hall
On May 28, 2013, at 4:10 PM, Jens Alfke wrote:

> CRC is primarily a checksum, not a hash function. It's good for verifying 
> data integrity, e.g. in a network protocol or file format, but more expensive 
> than you’d like for a hash table. There are much faster hash functions: 
> Wikipedia has a good list[1].

http://en.wikipedia.org/wiki/Hash_function

Hashing with cryptographic hash functions [edit]
Some cryptographic hash functions, such as SHA-1, have even stronger uniformity 
guarantees than checksums or fingerprints, and thus can provide very good 
general-purpose hashing functions.
In ordinary applications, this advantage may be too small to offset their much 
higher cost.[5] However, this method can provide uniformly distributed hashes 
even when the keys are chosen by a malicious agent. This feature may help to 
protect services against denial of service attacks.

I thought I saw SHA-1 being used as a general purpose hash function somewhere 
sort of surprising recently but I'm not remembering exactly where. Maybe if the 
collision resistance or hash value uniformity out weigh the performance 
concerns?

Michael Hall

trz nio.2 for OS X http://www195.pair.com/mik3hall/index.html#trz

HalfPipe Java 6/7 shell app http://www195.pair.com/mik3hall/index.html#halfpipe

AppConverter convert Apple jvm to openjdk apps 
http://www195.pair.com/mik3hall/index.html#appconverter





___

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

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

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

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

Nib image caching

2013-05-28 Thread James West
Does anyone know if nibs cache images or not inside of UIImageView?

In code, one would use - (UIImage *)imageNamed for a cached image, and -
(UIImage *)imageWithContentsOfFile to pull directly from disk. But I'd
like to learn how UIKit unarchives them from nibs.

Cheers,


-- 
  James West
  j...@clvr.im
___

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

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

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

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


NSMatrix used as menu item's view appears wrong

2013-05-28 Thread Steve Mills
I have a popup whose menu contains 1 item that uses a view, followed by a bunch 
of hidden menu items. The first time I pop up the menu, it looks correct. Every 
time after that, the view is scrolled way off the top with only a tiny bit 
still visible. Screenshots at:

https://www.dropbox.com/s/ggzuq19o1ziy8av/menu-item-view-wrong.png

Obviously, the top part is wrong and the top part is how it's supposed to look. 
I can flick my scrollwheel/trackpad and it will correct the placement of the 
view within the menu item.

The view set on the menu item is an NSMatrix containing NSButtonCells. No, this 
is not the only time I see this problem. Another popup has a menu item whose 
view is an NSBrowser, and it too will display off the top of the menu item just 
like the example.

Any ideas?

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



___

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

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

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

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Jens Alfke

On May 27, 2013, at 11:42 PM, Michael Crawford  wrote:

> For purposes of looking up strings in a hash table, a 32 bit CRC
> (Cyclic Redundancy Check) would be quick to calculate with few
> collisions.  It also doesn't require multiprecision arithmetic.

CRC is primarily a checksum, not a hash function. It's good for verifying data 
integrity, e.g. in a network protocol or file format, but more expensive than 
you’d like for a hash table. There are much faster hash functions: Wikipedia 
has a good list[1].

—Jens

[1] 
http://en.wikipedia.org/wiki/List_of_hash_functions#Non-cryptographic_hash_functions
___

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

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

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

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

Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Jens Alfke

On May 28, 2013, at 6:39 AM, Alex Zavatone  wrote:

> NSString *myString;

You’ve declared myString as a _mutable_ pointer to an _immutable_ object. If 
you had declared it as

NSString* const myString = @“Hi";

then the variable itself would be immutable, and the compiler would give you an 
error if you tried to reassign it. (You often see this style used when 
declaring a string constant in a header file, since it’s supposed to stay 
constant and no one should reassign it.)

Working with C++ will beat this concept into your head (for better or worse).

—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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSSlider, NSStepper, and NSTextfield with Bindings: how to display initial value?

2013-05-28 Thread Quincey Morris
On May 28, 2013, at 13:16 , Paul Johnson  wrote:

> I have a slider, a stepper, and a textField that are synchronized using
> bindings. I didn't write any code to do this, just used Xcode with its
> Interface Builder. When the program starts I don't see the slider set to
> the "Current" position I'd like and the textField doesn't show the
> "Current" value either. Is there something I can do within Xcode or do I
> need to add a line of code somewhere (in a -WindowControllerDidLoadNib:
> somewhere, maybe)?

This usually happens because something in the keypath of the binding isn't KVO 
compliant.

For example, if your controls are bound to "model.myValue" of File's Owner, and 
the "model" property doesn't get set until after the nib is loaded and it isn't 
set KVO compliantly, then your controls will see "myValue" as 0.

If you can't spot a property that's obviously non-compliant, it's going to be 
necessary to take the key path apart property by property and verify that each 
is doing the right thing.

Where is the initial value coming from? One of the values you set in the 
slider, stepper or text field in IB, or something else?

___

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

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

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

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


NSSlider, NSStepper, and NSTextfield with Bindings: how to display initial value?

2013-05-28 Thread Paul Johnson
I have a slider, a stepper, and a textField that are synchronized using
bindings. I didn't write any code to do this, just used Xcode with its
Interface Builder. When the program starts I don't see the slider set to
the "Current" position I'd like and the textField doesn't show the
"Current" value either. Is there something I can do within Xcode or do I
need to add a line of code somewhere (in a -WindowControllerDidLoadNib:
somewhere, maybe)?

If at all possible I'd like to do everything in Xcode without writing a
line of code.
___

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

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

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

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Oleg Krupnov
> If you're going to do that, why bother with an NSMapTable at all? Just store 
> your pointers in a C array.

The string pointers can be different, but they can contain identical
string keys, resulting in identical values. I wanted to find values by
in a more efficient way than dumb array iteration, say, like binary
tree search which is probably used in NSDictionary or NSMapTable.

> It's not useful to pursue this line of thinking without benchmarks.

Now I guess you're right. I just didn't know it was going to be that
complicated. I thought it was pure benefit and cheap. I am reverting
to using NSDictionary.
___

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

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

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

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


Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Lee Ann Rucker

On May 28, 2013, at 7:44 AM, Alex Zavatone wrote:

> 
> On May 28, 2013, at 9:46 AM, Steve Mills wrote:
> 
>> On May 28, 2013, at 08:39:21, Alex Zavatone  wrote:
>> 
>>> Though it's clearly defined in the docs when to use NSMubleAnything vs. 
>>> NSAnything (insert Array, Dictionary, String, etc for Anything), there is 
>>> no compiler warning when you perform a simple action such as allocate a 
>>> string and then reassign values to it.
>>> 
>>> With this in mind, what exactly constitutes a mutable action?
>>> 
>>> If we take this:
>>> 
>>> NSString *myString;
>>> myString = @"Hi";
>>> myString = @"Hi there";
>>> 
>>> I'm clearly expecting some type of warning from the compiler when myString 
>>> is redefined, but I don't see one in Xcode 4.6.1.  Is this redefinition not 
>>> a mutable action?  It sure seems like it is.
>> 
>> The example you've given is not changing the string, it's simply pointing 
>> the string pointer to a new string (changing the address it points to). This 
>> would require a mutable string:
>> 
>> [myString appendString:@"Hi there"];
>> 
>> because it's changing the string, but it will leave myString at the same 
>> pointer address.
> 
> Excellent.  This is part of the information that I'm looking for.  

To toss in another complication: the object assigned to an NSString or 
NSMutableString variable might not be an object of that type - unlike C++, ObjC 
doesn't care (it might not even be an NSString at all, but in that case 
something odd probably happened). 

Hence the warnings not to inspect the result of a method returning NSString - 
it might happen to be an NSMutableString but you should not try to mutate it. 
And if you somehow get an NSString object in an NSMutableString variable, the 
compiler will be happy but mutable methods will fail at runtime.
___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Dave Fernandes
Er, that would be NSOperationQueue. Haven't had my coffee yet today.

On 2013-05-28, at 1:17 PM, Kyle Sluder  wrote:

> On May 28, 2013, at 10:12 AM, Dave Fernandes  
> wrote:
> 
>> I use the GCD serial queue approach. On each update from the slider, cancel 
>> all operations in the queue and then add a new operation with the latest 
>> slider value. However, the NSOperation subclass should NOT check whether it 
>> is cancelled once it starts executing. That way, once it starts, it is 
>> assured to complete and you will get periodic updates.
> 
> So which are you using, NSOperationQueue or GCD?
> 
> --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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: rate limiting calls

2013-05-28 Thread Seth Willits

A while ago I was fiddling with various APIs to do rate limited calls. This is 
the simplest one. Morph it as you please. Maybe it'll be useful to someone. 



@interface GCDCoalescent : NSObject
- (void)dispatchOn:(dispatch_queue_t)queue after:(double)seconds 
block:(dispatch_block_t)block;
@end
 
 
@implementation GCDCoalescent
{
uint64_t count;
}
 
- (void)dispatchOn:(dispatch_queue_t)queue after:(double)seconds 
block:(dispatch_block_t)block;
{
uint64_t eventNumber = __sync_add_and_fetch(&count, 1);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, seconds * 
NSEC_PER_SEC), queue, ^{
if (count > eventNumber) return;
block();
});
}
 
@end




--
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Building an MVC based App for Mac OS X - NOT for iOS

2013-05-28 Thread Quincey Morris
On May 28, 2013, at 10:01 , YT  wrote:

> I did run a test and created a NEW Project and checked the box "Create a 
> Document-based App"
> AND no Controller files (.h,.m) were automatically generated. 

Actually, two controllers *were* generated:

1. The app delegate. This object has the role of a controller, even though it 
starts out with nothing to do. Its controller behavior comes from code you add 
to it, as necessary.

2. The NSDocument subclass. These objects are also controllers.

> Which leads to the general mechanical problem of how does one create 
> Controller files (.h,.m)?

A MVC controller is just an object that behaves like a controller. It doesn't 
have to have "controller" in its name to behave like a controller. It can be of 
any class, and the class you choose depends on what it's supposed to do.

Keep in mind that the MVC pattern is a very general pattern. A MVC "controller" 
is not the same as a "view controller". Putting this another way, a view 
controller is a kind of MVC controller, but not the only kind.

Similarly, a MVC "view" is not necessarily a view. Rather, it's a component of 
your app design that interacts with the user. It may be implemented as a 
window, or as a view, or as a window with a hierarchy of views, or something 
more complex.

Translating a MVC design pattern into an implementation is messier on the Mac 
than on iOS. That's because the objects used on the Mac grew up over time. 
iOS's UIViews and UIViewControllers were based on Mac concepts, but tried to 
unify the loose Mac architecture into something more consistent and rational.

___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Kyle Sluder
On May 28, 2013, at 10:12 AM, Dave Fernandes  wrote:

> I use the GCD serial queue approach. On each update from the slider, cancel 
> all operations in the queue and then add a new operation with the latest 
> slider value. However, the NSOperation subclass should NOT check whether it 
> is cancelled once it starts executing. That way, once it starts, it is 
> assured to complete and you will get periodic updates.

So which are you using, NSOperationQueue or GCD?

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: rate limiting calls

2013-05-28 Thread Dave Fernandes
I use the GCD serial queue approach. On each update from the slider, cancel all 
operations in the queue and then add a new operation with the latest slider 
value. However, the NSOperation subclass should NOT check whether it is 
cancelled once it starts executing. That way, once it starts, it is assured to 
complete and you will get periodic updates.

On 2013-05-28, at 12:29 PM, Torsten Curdt  wrote:

>> Hm - this does not seem to work and I cannot see why not.
>> 
>> The cancel and perform selector calls are being called but updateValue
>> is only performed when I release the slider handle.
>> I don't quite get why.
> 
> Would still be eager to know why but a GCD implementation was super
> simple and works.
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca
> 
> This email sent to dave.fernan...@utoronto.ca


___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Kyle Sluder
On May 28, 2013, at 9:03 AM, Torsten Curdt  wrote:

> 
> The cancel and perform selector calls are being called but updateValue
> is only performed when I release the slider handle.
> I don't quite get why.

Well, aside from using performSelector:@selector(updateValue:) when the method 
is actually named -update (which I assume is just a typo), the slider is going 
to run the runloop in event tracking mode while the user is dragging. 
-performSelector:… will schedule the selector for NSDefaultRunLoopMode. You 
need to use the …inModes: variant to get delay-performs to happen while 
mouse-tracking.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: rate limiting calls

2013-05-28 Thread Scott Ribe
On May 28, 2013, at 10:03 AM, Torsten Curdt wrote:

> The cancel and perform selector calls are being called but updateValue
> is only performed when I release the slider handle.
> I don't quite get why.

Oh, because those post into the event loop, and during slider manipulation I 
bet the event loop is in a special tracking mode where it's handling (mostly) 
just the mouse events until the mouse is released. Which means my suggestion re 
NSTimer would not work either.

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





___

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

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

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

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


Re: Building an MVC based App for Mac OS X - NOT for iOS

2013-05-28 Thread YT
In the latest set of responses to my query "Building an MVC based App for Mac 
OS X - NOT iOS"

The question of - am I building a "Document Based App"?  

After reading the Apple Document "Designing a Document-Based Application" I can 
say NO, I don't believe I am building a Document Based App.

I did run a test and created a NEW Project and checked the box "Create a 
Document-based App"
AND no Controller files (.h,.m) were automatically generated. 

Which leads to the general mechanical problem of how does one create Controller 
files (.h,.m)?
You get them auto created when working in iOS
BUT they are not auto created when working in Mac OS X.

Then the latest set of responses discuss which Controller to use once the 
"general mechanical how to create a controller" is answered.

Jens Writes --
Anyway, to answer YT’s original question: To create new controllers you can use 
the New File… command and create a new OS X NSWindowController or 
NSViewController subclass. Xcode will put boilerplate code in the new files and 
even create .xibs. If you’re creating a document-based app you may want to 
create an NSDocument subclass, which is higher-level and abstracts the file I/O 
for you.
-
AND I found that to actually use any controller one creates via NEW File... as 
a Controller
You have to disconnect the Auto generated Delegate from the Outlets Connection 
in the File's Owner Object in the IB Doc 
Please correct me if I am wrong about this point.

All of you discuss the utilities of the following Controllers. 
NSWindowController
NSViewController
UIViewController
NSController

From a nubee Apple App programming point of view they all appear to be similar 
WHICH MEANS I will have to read more about each to be able to make an 
intelligent choice that fits my intended purpose. 

more later...

YT







___

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

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

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

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

Re: rate limiting calls

2013-05-28 Thread Torsten Curdt
> Hm - this does not seem to work and I cannot see why not.
>
> The cancel and perform selector calls are being called but updateValue
> is only performed when I release the slider handle.
> I don't quite get why.

Would still be eager to know why but a GCD implementation was super
simple and works.
___

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

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

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

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


Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Thomas Wetmore
Alex,

Forget what I said about memory management. It is wrong.

Your confusion probably stems from the fact that the pointer named myString is 
allowed to point to any number of string during the execution of your program. 
It is the objects that are immutable, not the pointers to them.

Tom Wetmore

On May 28, 2013, at 12:11 PM, Thomas Wetmore  wrote:

> Alex,
> 
> What your three lines of code do:
> 
>> NSString *myString;
> 
> Compiler allocates space for a pointer on the run time stack.
> 
>> myString = @"Hi";
> 
> Compiler creates an NSString object somewhere in the heap with the value 
> @"Hi" and points the pointer to it.
> 
>> myString = @"Hi there";
> 
> Compiler creates another NSString object somewhere else in the heap with the 
> value @"Hi there" and points the pointer to it. Depending on the type of 
> memory management you are using the first string might leak since there is 
> nothing pointing to it any more. If you are using ARC the compiler will 
> insert a call to release to remove the first string.
> 
> There is nothing in your code that tries to mutate a string. All it does is 
> create two different strings.
> 
> Tom Wetmore
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/ttw4%40verizon.net
> 
> This email sent to t...@verizon.net


___

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

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

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

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


Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Thomas Wetmore
Alex,

What your three lines of code do:

> NSString *myString;

Compiler allocates space for a pointer on the run time stack.

> myString = @"Hi";

Compiler creates an NSString object somewhere in the heap with the value @"Hi" 
and points the pointer to it.

> myString = @"Hi there";

Compiler creates another NSString object somewhere else in the heap with the 
value @"Hi there" and points the pointer to it. Depending on the type of memory 
management you are using the first string might leak since there is nothing 
pointing to it any more. If you are using ARC the compiler will insert a call 
to release to remove the first string.

There is nothing in your code that tries to mutate a string. All it does is 
create two different strings.

Tom Wetmore
___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Torsten Curdt
kSliderDelay = 0.0

> -(void)setValue:(NSObject*)value
> {
> self.value = value;
>
> [NSObject
> cancelPreviousPerformRequestsWithTarget:self
> selector:@selector(updateValue)
> object:nil];
>
> [self performSelector:@selector(updateValue)
> withObject:nil];
> afterDelay:kSliderDelay];
> }
>
> -(void)update
> {
> // slow update from self.value
> }

Hm - this does not seem to work and I cannot see why not.

The cancel and perform selector calls are being called but updateValue
is only performed when I release the slider handle.
I don't quite get why.

cheers,
Torsten
___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Steve Mills
On May 28, 2013, at 10:16:07, Scott Ribe  wrote:

> On May 28, 2013, at 8:41 AM, Torsten Curdt wrote:
> 
>> Any easier or more elegant way you could think of?
> 
> Well, if you don't want to deal with a queue and background thread, use 
> NSTimer. In setValue, cancel the timer if it exists, then create a new one 
> scheduled to run .someting seconds. If a timer ever fires, do your 
> calculation.
> 
> Now if you *want* an occasional intermediate update while the user is 
> dragging, then compare values or current time in setValue...

If you do that last idea, you'll have to make sure you have the final value get 
set on mouseUp, otherwise you might be ignoring it because not enough time has 
passed. If the value this slider is setting takes too much time to process, 
consider letting the calculation process after mouseUp, and let the slider 
change its value naturally.

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157




___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Torsten Curdt
Hey John,

thanks for the pointer. I used a similar pattern before but at that
time it was just a selector without parameter. AFAIU
cancelPreviousPerformRequestsWithTarget:selector:object will match the
object parameter to see what to cancel. (and nil is not a match-all).
Since here the parameter is changing it didn't feel like the right way
to go but...

On the other hand maybe I could just store away the value and the use
the same pattern for updates. Along the lines of

-(void)setValue:(NSObject*)value
{
self.value = value;

[NSObject
cancelPreviousPerformRequestsWithTarget:self
selector:@selector(updateValue)
object:nil];

[self performSelector:@selector(updateValue)
withObject:nil];
afterDelay:kSliderDelay];
}

-(void)update
{
// slow update from self.value
}

cheers,
Torsten
___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Scott Ribe
On May 28, 2013, at 8:41 AM, Torsten Curdt wrote:

> Any easier or more elegant way you could think of?

Well, if you don't want to deal with a queue and background thread, use 
NSTimer. In setValue, cancel the timer if it exists, then create a new one 
scheduled to run .someting seconds. If a timer ever fires, do your calculation.

Now if you *want* an occasional intermediate update while the user is dragging, 
then compare values or current time in setValue...

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





___

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

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

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

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Kyle Sluder
On May 28, 2013, at 12:38 AM, Oleg Krupnov  wrote:

> I just made the following experiment:
> 
> I specified a hash method for my NSMapTable, but it always returns 0.
> This seems to force the NSMapGet to always use key comparison for
> searching for elements, as hash is always "not unique".
> 
> Is this a good idea?

If you're going to do that, why bother with an NSMapTable at all? Just store 
your pointers in a C array.

> 
> Let me think. The keys are quite short strings, like 5-10 chars.

How about making your hash function just return the first character casted to 
int?

> 
> If we take the expense of calculating hash once for each search, then
> comparing hash values is very quick, plus a few string comparisons in
> the end if hash is not unique

It's not useful to pursue this line of thinking without benchmarks.

--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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: rate limiting calls

2013-05-28 Thread John Pannell
Hi Torsten-

You might consider something like the coalescing described in this blog entry:

http://www.takingnotes.co/blog/2013/01/03/coalescing/

In short, you'd be using performSelector:withObject:afterDelay: to make the 
desired method call, and 
cancelPreviousPerformRequestsWithTarget:selector:object: to prevent the calls 
from piling up.

Hope this helps!

John

On May 28, 2013, at 8:41 AM, Torsten Curdt  wrote:

>> Quick question: how often are you calling setValue:? Every time it changes
>> or is it inside an NSTimer/CADisplayLink?
> 
> Every time the user moves the slider.
> 
>> Can you give us more information on this particular flow?
> 
> If I execute the "setValue:" on each value change of the slider the UI
> feels too slow.
> 
> What I currently have in mind is to just store the latest value. Then
> enqueue "update" calls in an async queue and in the update blocks only
> perform the update if the value is different from the previous/current
> one.
> Any easier or more elegant way you could think of?
> 
> cheers,
> Torsten
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/john%40positivespinmedia.com
> 
> This email sent to j...@positivespinmedia.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Alex Zavatone

On May 28, 2013, at 9:46 AM, Steve Mills wrote:

> On May 28, 2013, at 08:39:21, Alex Zavatone  wrote:
> 
>> Though it's clearly defined in the docs when to use NSMubleAnything vs. 
>> NSAnything (insert Array, Dictionary, String, etc for Anything), there is no 
>> compiler warning when you perform a simple action such as allocate a string 
>> and then reassign values to it.
>> 
>> With this in mind, what exactly constitutes a mutable action?
>> 
>> If we take this:
>> 
>> NSString *myString;
>> myString = @"Hi";
>> myString = @"Hi there";
>> 
>> I'm clearly expecting some type of warning from the compiler when myString 
>> is redefined, but I don't see one in Xcode 4.6.1.  Is this redefinition not 
>> a mutable action?  It sure seems like it is.
> 
> The example you've given is not changing the string, it's simply pointing the 
> string pointer to a new string (changing the address it points to). This 
> would require a mutable string:
> 
> [myString appendString:@"Hi there"];
> 
> because it's changing the string, but it will leave myString at the same 
> pointer address.

Excellent.  This is part of the information that I'm looking for.  
___

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

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

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

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


Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Steve Mills
On May 28, 2013, at 08:39:21, Alex Zavatone  wrote:

> Though it's clearly defined in the docs when to use NSMubleAnything vs. 
> NSAnything (insert Array, Dictionary, String, etc for Anything), there is no 
> compiler warning when you perform a simple action such as allocate a string 
> and then reassign values to it.
> 
> With this in mind, what exactly constitutes a mutable action?
> 
> If we take this:
> 
> NSString *myString;
> myString = @"Hi";
> myString = @"Hi there";
> 
> I'm clearly expecting some type of warning from the compiler when myString is 
> redefined, but I don't see one in Xcode 4.6.1.  Is this redefinition not a 
> mutable action?  It sure seems like it is.

The example you've given is not changing the string, it's simply pointing the 
string pointer to a new string (changing the address it points to). This would 
require a mutable string:

[myString appendString:@"Hi there"];

because it's changing the string, but it will leave myString at the same 
pointer address.

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



___

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

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

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

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


Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Alex Zavatone

On May 28, 2013, at 9:50 AM, Roland King wrote:

> 
> On 28 May, 2013, at 9:39 PM, Alex Zavatone  wrote:
> 
>> Though it's clearly defined in the docs when to use NSMubleAnything vs. 
>> NSAnything (insert Array, Dictionary, String, etc for Anything), there is no 
>> compiler warning when you perform a simple action such as allocate a string 
>> and then reassign values to it.
>> 
>> With this in mind, what exactly constitutes a mutable action?
>> 
>> If we take this:
>> 
>> NSString *myString;
>> myString = @"Hi";
>> myString = @"Hi there";
>> 
>> I'm clearly expecting some type of warning from the compiler when myString 
>> is redefined, but I don't see one in Xcode 4.6.1.  Is this redefinition not 
>> a mutable action?  It sure seems like it is.
> 
> 
> myString is a pointer to an NSString (or subclass thereof). It's not const, 
> it's not static so the pointer can point to any NSString (or subclass 
> thereof) and be reassigned at will. There is a huge difference between an 
> NSString, which cannot be mutated and a pointer to an NSString which can. 
> 
> This is pretty basic. 

Yes, it's pretty basic, and this is why I am asking.  To make sure I've got it 
100% right.

Though you stated that myString is a pointer to "an NSString" I'm expecting 
that myString is a pointer not to NSString, but an instance of NSString.  Which 
is correct?

I'm having to explain mutabie vs nonmutable to web devs and am providing 
concrete examples of what constitutes legit/non legit actions, so wanted to 
make sure that I have everything properly understood in my head and am 
interpreting the compiler feedback correctly.

Thanks much.
___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Torsten Curdt
> Quick question: how often are you calling setValue:? Every time it changes
> or is it inside an NSTimer/CADisplayLink?

Every time the user moves the slider.

> Can you give us more information on this particular flow?

If I execute the "setValue:" on each value change of the slider the UI
feels too slow.

What I currently have in mind is to just store the latest value. Then
enqueue "update" calls in an async queue and in the update blocks only
perform the update if the value is different from the previous/current
one.
Any easier or more elegant way you could think of?

cheers,
Torsten
___

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

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

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

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


Re: rate limiting calls

2013-05-28 Thread Igor Elland
Hi,

Quick question: how often are you calling setValue:? Every time it changes or 
is it inside an NSTimer/CADisplayLink?
Can you give us more information on this particular flow?

Cheers,
Igor Ranieri

On May 28, 2013, at 4:28 PM, Torsten Curdt  wrote:

> I am getting a lot of calls to a selector "setValue:" from a slider
> control - but setting this value takes an considerable amount of time.
> 
> In order to keep the UI responsive I need to rate limit the actual
> calls or move the value setting into an async background queue.
> While the queue sounds like the most easiest way around this, queuing
> the calls isn't really what I need either as only the last recent
> value in the queue is of interest.
> 
> Right now I am not sure how to tackle this best yet.
> Any thoughts?
> 
> cheers,
> Torsten
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/igor.elland%40me.com
> 
> This email sent to igor.ell...@me.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


rate limiting calls

2013-05-28 Thread Torsten Curdt
I am getting a lot of calls to a selector "setValue:" from a slider
control - but setting this value takes an considerable amount of time.

In order to keep the UI responsive I need to rate limit the actual
calls or move the value setting into an async background queue.
While the queue sounds like the most easiest way around this, queuing
the calls isn't really what I need either as only the last recent
value in the queue is of interest.

Right now I am not sure how to tackle this best yet.
Any thoughts?

cheers,
Torsten
___

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

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

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

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


Re: What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Roland King

On 28 May, 2013, at 9:39 PM, Alex Zavatone  wrote:

> Though it's clearly defined in the docs when to use NSMubleAnything vs. 
> NSAnything (insert Array, Dictionary, String, etc for Anything), there is no 
> compiler warning when you perform a simple action such as allocate a string 
> and then reassign values to it.
> 
> With this in mind, what exactly constitutes a mutable action?
> 
> If we take this:
> 
> NSString *myString;
> myString = @"Hi";
> myString = @"Hi there";
> 
> I'm clearly expecting some type of warning from the compiler when myString is 
> redefined, but I don't see one in Xcode 4.6.1.  Is this redefinition not a 
> mutable action?  It sure seems like it is.


myString is a pointer to an NSString (or subclass thereof). It's not const, 
it's not static so the pointer can point to any NSString (or subclass thereof) 
and be reassigned at will. There is a huge difference between an NSString, 
which cannot be mutated and a pointer to an NSString which can. 

This is pretty basic. 
___

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

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

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

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


What, exactly constitutes a mutable action on an instance?

2013-05-28 Thread Alex Zavatone
Though it's clearly defined in the docs when to use NSMubleAnything vs. 
NSAnything (insert Array, Dictionary, String, etc for Anything), there is no 
compiler warning when you perform a simple action such as allocate a string and 
then reassign values to it.

With this in mind, what exactly constitutes a mutable action?

If we take this:

NSString *myString;
myString = @"Hi";
myString = @"Hi there";

I'm clearly expecting some type of warning from the compiler when myString is 
redefined, but I don't see one in Xcode 4.6.1.  Is this redefinition not a 
mutable action?  It sure seems like it is.

Thanks in advance.
___

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

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

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

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


Re: Show / hide application menu / icon in dock / windows cycling / ...

2013-05-28 Thread Robert Vojta


On Tuesday, 28. May 2013 at 13:31, Ken Thomases wrote:

> Can't you just activate your app (if it's been deactivated) and order your 
> window to the front when the ACAccountStore request completes?

Ouch, stupid me, yes, does work ;-) 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Show / hide application menu / icon in dock / windows cycling / ...

2013-05-28 Thread Ken Thomases
On May 28, 2013, at 6:20 AM, Robert Vojta wrote:

> Maybe you know how to solve following problem and there will be no need for 
> switching activation policy or creating another helper.
> 
> 1. App creates new Wizard NSWindow
> 2. Window is visible, user did go through several steps and now I do ask 
> ACAccountStore for permission to access system Facebook account
> 3. Over my wizard window, system dialog appears and asks user if he allows / 
> disallows
> 4. User clicks on any button, system dialog disappears and my window 
> disappears as well (actually my window is below other apps windows)
> 
> And now, because my app has LSUIElement set to YES, app is not listed in 
> cycling, no menu, no dock icon and thus there's no way how to get back to my 
> wizard window unless user moves these windows or clicks again on my status 
> bar icon, because I know that wizard is still open and I move it to the front.

Can't you just activate your app (if it's been deactivated) and order your 
window to the front when the ACAccountStore request completes?

Regards,
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Show / hide application menu / icon in dock / windows cycling / ...

2013-05-28 Thread Robert Vojta
Ken, thanks for the reply. Prohibited is no way.

Maybe you know how to solve following problem and there will be no need for 
switching activation policy or creating another helper.

1. App creates new Wizard NSWindow
2. Window is visible, user did go through several steps and now I do ask 
ACAccountStore for permission to access system Facebook account
3. Over my wizard window, system dialog appears and asks user if he allows / 
disallows
4. User clicks on any button, system dialog disappears and my window disappears 
as well (actually my window is below other apps windows)

And now, because my app has LSUIElement set to YES, app is not listed in 
cycling, no menu, no dock icon and thus there's no way how to get back to my 
wizard window unless user moves these windows or clicks again on my status bar 
icon, because I know that wizard is still open and I move it to the front.

One solution, which I don't like, is to set windowLevel to 
NSFloatingWindowLevel for example. Now, my wizard window is still visible, but 
it's not convenient to have this window still on top.

I'm still thinking about it and it seems that helper is the only way unless I 
find some nice & clean solution.

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Building an MVC based App for Mac OS X - NOT for iOS

2013-05-28 Thread Uli Kusterer
On May 28, 2013, at 7:15 AM, Quincey Morris 
 wrote:
> In the broadest MVC terms, the "C" is often a NSWindowController subclass. 
> The "M" is often the app delegate *or* a NSDocument subclass, or is a more 
> specialized object graph to which the app delegate or document holds a 
> reference. The "V" is the window and its contained views.

 While it is true that many people use the app delegate as the model (aka a 
hidden singleton that is a dump for all sorts of stuff), I wouldn't recommend 
that.

 The app delegate is intended to provide behaviours for the application as 
shown in the Dock and Finder, and a root for global properties and actions 
exposed to AppleScript and other automation/scripting/interapplication 
communication mechanisms. If you have anything else, you should create a 
separate (often reusable) class that the application or application delegate 
creates.

 For document-based apps, NSApplication already does that by default, but you 
can modify the behaviour. For shoebox apps and the likes, you create an 
NSWindowController that implements the main window, and maybe another one for a 
preferences window. But only create them, keep their specific code out of the 
application and app delegate as much as possible. Otherwise your app delegate 
grows into a huge god-object and needs to be recompiled every time one of the 
other classes is changed even slightly, and worse, may cause all other files in 
your project to recompile every time you change it to adjust a method another 
object uses from it.

 In particular, only few menu items should be implemented by the application 
itself. Instead, most of them should be hooked up to the First Responder, where 
each window controller can then claim it using the responder chain when it is 
frontmost.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Oleg Krupnov
I just made the following experiment:

I specified a hash method for my NSMapTable, but it always returns 0.
This seems to force the NSMapGet to always use key comparison for
searching for elements, as hash is always "not unique".

Is this a good idea?

Let me think. The keys are quite short strings, like 5-10 chars.

If we take the expense of calculating hash once for each search, then
comparing hash values is very quick, plus a few string comparisons in
the end if hash is not unique

If we spare on calculating hash, we will compare strings on each
ramification of the binary tree. Besides, it seems that isEqual method
returns BOOL which means the keys will not be sorted, which makes
binary tree search impossible? In this case hash seems the only sane
solution for NSMapTable. Am I right?



On Tue, May 28, 2013 at 10:03 AM, Jean-Daniel Dupas
 wrote:
>
> Le 28 mai 2013 à 08:25, Oleg Krupnov  a écrit :
>
>> Hi Jens,
>>
>> I guess you may be right. But… two questions in this regard:
>>
>> 1. I thought that "isEqual" method is alternative to "hash" method,
>> because searching by key and searching by hash are two mutually
>> exclusive methods of looking up values, aren't they?
>>
>
> No, they aren't. The hash is used to speed up the lookup.
> The HashTable first uses the hash to find in which bucket the element is, and 
> as the hash is not guarantee to be unique, it then use the isEqual method to 
> determine what element in this bucket in the one you are looking for.
>
>> 2. What hash function you'd suggest in my case, that would calculate
>> unsigned int on output, for C strings? Because calculating hash
>> functions (such as md5) may be computationally expensive, which could
>> undermine my entire idea of sparing extra few calls on creating
>> NSStrings :)
>
> The main issue with using c string, is memory management of your keys. 
> NSString does that using ref counting, but you will have to take care of 
> everything if you are using C string.
> Avoiding NSString without being sure this will impact the performance is just 
> "premature optimization".
>
> That said, there is 2 famous hash functions that are usually used for this 
> kind of hashing: CityHash (http://code.google.com/p/cityhash/) and MurmurHash 
> (http://code.google.com/p/smhasher/)
>
>> Thanks!
>>
>> On Tue, May 28, 2013 at 9:08 AM, Jens Alfke  wrote:
>>>
>>> On May 27, 2013, at 10:46 PM, Oleg Krupnov  wrote:
>>>
>>> Now, the problem is that sometimes when I try to get a value from the
>>> table, the MapTableKeyComparator function is not called at all, and
>>> NSMapGet returns NULL, thought immediate dump of the table shows that
>>> all previous records are perfectly present in the table.
>>>
>>>
>>> Probably because you haven’t implemented a hash function, only an equals
>>> function. I’m guessing NSMapTable’s default hash function merely hashes the
>>> key pointer itself, which means that if you pass it a different pointer to
>>> an equal C string, it won’t find anything.
>>>
>>> —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:
>> https://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org
>>
>> This email sent to devli...@shadowlab.org
>
> -- 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: My App refuses to rotate

2013-05-28 Thread Gerriet M. Denkmann

On 28 May 2013, at 14:14, Andreas Liebschner  wrote:

> On Tue, May 28, 2013 at 9:01 AM, Gerriet M. Denkmann
>  wrote:
> 
>> But in the iPhone simulator and in the iPhone device the rootViewController
>> always has interfaceOrientation = 1 (Portrait).
>> All other ViewControllers also show interfaceOrientation = 1 (Portrait).
> 
> Any chance that what you are referring to as the rootViewController is
> actually a child of a UINavigationController or UITabBarController?
> 

No the rootViewController is a BaseViewController which has only 
supportedInterfaceOrientations overridden.

The superview hierarchy of WordsViewController is:
super 0x2012c000 UITableView
super 0x21d05b80 UIViewControllerWrapperView
super 0x1f53db90 UINavigationTransitionView
super 0x1f53e8f0 UILayoutContainerView
super 0x1f541270 UIWindow


> If that's the case, you will need to subclass UINavigationController
> or UITabBarController override its supportedInterfaceOrientations (+
> its shouldAutorotate in case you need to support iOS < 6) because
> that's where the magic happens.

Not interested in old iOS (yet) - sufficient if it runs on 6.1
Just checked: all ViewControllers have shouldAutorotate = YES.

Gerriet.


___

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

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

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

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


Re: My App refuses to rotate

2013-05-28 Thread Gerriet M. Denkmann

On 28 May 2013, at 14:03, David Duncan  wrote:

> Did you set the window's rootViewController to your view controller?

In WordsViewController (subclass of UIViewController) I added:
UIView *view = ss.view;
UIWindow *window = view.window; 
UIViewController *rootViewController = window.rootViewController;
NSLog(@"%s %@ self %p view %p window %p rootViewController 
%p",__FUNCTION__, 
a, self, view, window, rootViewController);

which prints:
 +[WordsViewController printControllersFor:at:] searchOption self 0x1238c0 view 
0x2012c000 window 0x1f541270 rootViewController 0x2097fca0


BaseViewController has:
- (NSUInteger)supportedInterfaceOrientations
{
UIInterfaceOrientationMask a = COMMON_ORIENTATION;
NSLog(@"%s %#lx %p",__FUNCTION__,a, self);
return a;
}

which prints repeatedly:
-[BaseViewController supportedInterfaceOrientations] 0x1e 0x2097fca0

So the rootViewController seems to be my BaseViewController.

The superview hierarchy of WordsViewController is:
 super 0x2012c000 UITableView
 super 0x21d05b80 UIViewControllerWrapperView
 super 0x1f53db90 UINavigationTransitionView
 super 0x1f53e8f0 UILayoutContainerView
 super 0x1f541270 UIWindow


Another thing:

Just tried it again on the device (iPhone 4S) and got the top bar (with battery 
percentage, etc.) and the keyboard in LandscapeRight (the first item in 
UISupportedInterfaceOrientations) but the table view still in portrait.
And it still did not rotate.
Changed the order in UISupportedInterfaceOrientations to start with 
UIInterfaceOrientationPortrait. Now it is at least usable (but still does not 
rotate).

> 
> On May 28, 2013, at 12:01 AM, Gerriet M. Denkmann  
> wrote:
> 
>> I have an iOS 6.1 app.
>> 
>> Info.plist contains:
>>  UIInterfaceOrientation
>>  UIInterfaceOrientationPortrait
>> 
>>  UISupportedInterfaceOrientations
>>  
>>  UIInterfaceOrientationLandscapeRight 
>>  UIInterfaceOrientationLandscapeLeft
>>  UIInterfaceOrientationPortrait
>>  UIInterfaceOrientationPortraitUpsideDown
>>  
>> 
>>  UISupportedInterfaceOrientations~ipad
>>  
>>  UIInterfaceOrientationPortrait
>>  
>> 
>> All ViewControllers have:
>> 
>> - (NSUInteger)supportedInterfaceOrientations
>> {
>>  return UIInterfaceOrientationMaskAll;
>> }
>> 
>> But in the iPhone simulator and in the iPhone device the rootViewController 
>> always has interfaceOrientation = 1 (Portrait).
>> All other ViewControllers also show interfaceOrientation = 1 (Portrait).
>> 
>> 
>> Why does the App not rotate?
>> 
>> What am I missing?
>> 
>> Gerriet.
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
>> 
>> This email sent to david.dun...@apple.com
> 
> --
> David Duncan
> 


___

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

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

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

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


Re: My App refuses to rotate

2013-05-28 Thread Andreas Liebschner
On Tue, May 28, 2013 at 9:01 AM, Gerriet M. Denkmann
 wrote:

> But in the iPhone simulator and in the iPhone device the rootViewController
> always has interfaceOrientation = 1 (Portrait).
> All other ViewControllers also show interfaceOrientation = 1 (Portrait).

Any chance that what you are referring to as the rootViewController is
actually a child of a UINavigationController or UITabBarController?

If that's the case, you will need to subclass UINavigationController
or UITabBarController override its supportedInterfaceOrientations (+
itsshouldAutorotate in case you need to support iOS < 6) because
that's where the magic happens.

Andreas
___

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

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

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

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


Re: My App refuses to rotate

2013-05-28 Thread David Duncan
Did you set the window's rootViewController to your view controller?

On May 28, 2013, at 12:01 AM, Gerriet M. Denkmann  wrote:

> I have an iOS 6.1 app.
> 
> Info.plist contains:
>   UIInterfaceOrientation
>   UIInterfaceOrientationPortrait
> 
>   UISupportedInterfaceOrientations
>   
>   UIInterfaceOrientationLandscapeRight 
>   UIInterfaceOrientationLandscapeLeft
>   UIInterfaceOrientationPortrait
>   UIInterfaceOrientationPortraitUpsideDown
>   
> 
>   UISupportedInterfaceOrientations~ipad
>   
>   UIInterfaceOrientationPortrait
>   
> 
> All ViewControllers have:
> 
> - (NSUInteger)supportedInterfaceOrientations
> {
>   return UIInterfaceOrientationMaskAll;
> }
> 
> But in the iPhone simulator and in the iPhone device the rootViewController 
> always has interfaceOrientation = 1 (Portrait).
> All other ViewControllers also show interfaceOrientation = 1 (Portrait).
> 
> 
> Why does the App not rotate?
> 
> What am I missing?
> 
> Gerriet.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

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

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

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

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


Re: NSMapTable with C strings as keys

2013-05-28 Thread Jean-Daniel Dupas

Le 28 mai 2013 à 08:25, Oleg Krupnov  a écrit :

> Hi Jens,
> 
> I guess you may be right. But… two questions in this regard:
> 
> 1. I thought that "isEqual" method is alternative to "hash" method,
> because searching by key and searching by hash are two mutually
> exclusive methods of looking up values, aren't they?
> 

No, they aren't. The hash is used to speed up the lookup.
The HashTable first uses the hash to find in which bucket the element is, and 
as the hash is not guarantee to be unique, it then use the isEqual method to 
determine what element in this bucket in the one you are looking for.

> 2. What hash function you'd suggest in my case, that would calculate
> unsigned int on output, for C strings? Because calculating hash
> functions (such as md5) may be computationally expensive, which could
> undermine my entire idea of sparing extra few calls on creating
> NSStrings :)

The main issue with using c string, is memory management of your keys. NSString 
does that using ref counting, but you will have to take care of everything if 
you are using C string.
Avoiding NSString without being sure this will impact the performance is just 
"premature optimization".

That said, there is 2 famous hash functions that are usually used for this kind 
of hashing: CityHash (http://code.google.com/p/cityhash/) and MurmurHash 
(http://code.google.com/p/smhasher/)

> Thanks!
> 
> On Tue, May 28, 2013 at 9:08 AM, Jens Alfke  wrote:
>> 
>> On May 27, 2013, at 10:46 PM, Oleg Krupnov  wrote:
>> 
>> Now, the problem is that sometimes when I try to get a value from the
>> table, the MapTableKeyComparator function is not called at all, and
>> NSMapGet returns NULL, thought immediate dump of the table shows that
>> all previous records are perfectly present in the table.
>> 
>> 
>> Probably because you haven’t implemented a hash function, only an equals
>> function. I’m guessing NSMapTable’s default hash function merely hashes the
>> key pointer itself, which means that if you pass it a different pointer to
>> an equal C string, it won’t find anything.
>> 
>> —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:
> https://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org
> 
> This email sent to devli...@shadowlab.org

-- 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

My App refuses to rotate

2013-05-28 Thread Gerriet M. Denkmann
I have an iOS 6.1 app.

Info.plist contains:
UIInterfaceOrientation
UIInterfaceOrientationPortrait

UISupportedInterfaceOrientations

UIInterfaceOrientationLandscapeRight 
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown


UISupportedInterfaceOrientations~ipad

UIInterfaceOrientationPortrait


All ViewControllers have:

- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}

But in the iPhone simulator and in the iPhone device the rootViewController 
always has interfaceOrientation = 1 (Portrait).
All other ViewControllers also show interfaceOrientation = 1 (Portrait).


Why does the App not rotate?

What am I missing?

Gerriet.


___

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

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

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

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