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

2013-05-29 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 j...@mooseyard.com het volgende 
geschreven:

 
 On May 28, 2013, at 6:39 AM, Alex Zavatone z...@mac.com 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: What, exactly constitutes a mutable action on an instance?

2013-05-29 Thread Robert Vojta


On Wednesday, 29. May 2013 at 8:37, Diederik Meijer | Ten Horses wrote:

 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;
 …..

No, ARC perfectly manages this - no leaks in this case.

self.string1 = @Hello;
self.string1 = @Hello hello;   - @Hello deallocated unless it's 
strongly referenced elsewhere
self.string1 = @Hello hello hello;   - @Hello hello deallocated unless 
it's strongly referenced elsewhere

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

Here's nice tutorial from Ray 
http://www.raywenderlich.com/5677/beginning-arc-in-ios-5-part-1 You can learn 
something here.

Real life example …

 strong - you're walking your dog on the lead, someone call your dog and he 
can't run
 copy - like strong, but your dog is cloned and you're walking your new clone 
on the lead
 weak - you're walking your dog off the lead, someone call your dog, he can run 
and you're without your dog

… if your property is weak and you do assign @Hello object to it, the object 
disappears and your property will be nil. That's because there's no strong 
reference to your @Hello object.

;-)

___

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

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

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

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

Flash inside an app

2013-05-29 Thread Alexandru Gologan
Hey, per OSX app-store regulations would an app be approved if it loads a flash 
player inside a uiwebview but does not show that view, instead expanding on the 
callbacks from it and creating a new experience and adding new functionality to 
that service!?
I know Shiny Groove does something similar for the Grooveshark service, is it 
ok?

Thanks,
Alexandru
___

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

Please do not post 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-29 Thread Quincey Morris
On May 28, 2013, at 23:37 , Diederik Meijer | Ten Horses 
diede...@tenhorses.com wrote:

 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;

No, you don't have to worry. When dealing with objects, ARC handles all 
retain/release correctly, regardless of whether the assignment is to the 
property or the ivar. That's kinda the point.

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

ARC still does the right thing, whether you use the ivar or the setter.

The ownership keyword is multi-purpose (unfortunately, IMO):

1. It defines the ownership attribute of a synthesized ivar (or must match the 
ownership attribute of a manually declared ivar). For this, copy is the same as 
strong.

2. It defines the behavior of a synthesized setter. For this, copy makes a 
copy, everything else just does an assignment (with the appropriate memory 
management according to the ivar ownership attribute).

3. It declares the ownership attribute of the property itself, separately from 
the ivar. For this, strong and copy represent a strong property; weak 
represents a weak property; __unsafe_unretained represents no ownership. 
However, the property's ownership attribute has no actual effect on the 
compiler. Everything the compiler does via synthesis is covered under #1 and #2.

Note that #1 and #2 are in truth private implementation details of the class. 
#3 is the public API contract, and communicates to clients of the class whether 
the property takes ownership of the property value.

___

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

Please do not post 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-29 Thread Diederik Meijer | Ten Horses
Thanks Robert and Quincey, that's very helpful!



Op May 29, 2013, om 8:26 AM heeft Quincey Morris 
quinceymor...@rivergatesoftware.com het volgende geschreven:

 On May 28, 2013, at 23:37 , Diederik Meijer | Ten Horses 
 diede...@tenhorses.com wrote:
 
 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;
 
 No, you don't have to worry. When dealing with objects, ARC handles all 
 retain/release correctly, regardless of whether the assignment is to the 
 property or the ivar. That's kinda the point.
 
 2. How do the strong, copy and weak keywords in the property declaration 
 affect this?
 
 ARC still does the right thing, whether you use the ivar or the setter.
 
 The ownership keyword is multi-purpose (unfortunately, IMO):
 
 1. It defines the ownership attribute of a synthesized ivar (or must match 
 the ownership attribute of a manually declared ivar). For this, copy is the 
 same as strong.
 
 2. It defines the behavior of a synthesized setter. For this, copy makes a 
 copy, everything else just does an assignment (with the appropriate memory 
 management according to the ivar ownership attribute).
 
 3. It declares the ownership attribute of the property itself, separately 
 from the ivar. For this, strong and copy represent a strong property; weak 
 represents a weak property; __unsafe_unretained represents no ownership. 
 However, the property's ownership attribute has no actual effect on the 
 compiler. Everything the compiler does via synthesis is covered under #1 and 
 #2.
 
 Note that #1 and #2 are in truth private implementation details of the class. 
 #3 is the public API contract, and communicates to clients of the class 
 whether the property takes ownership of the property value.
 

___

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

Please do not post 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

[RAA] realtime audio data transfer between two iOS devices

2013-05-29 Thread Rufat A. Abdullayev
Hello dear members!


Could you pls help me. I browsed a lot but could not find real answer

I'm implementing Voice over IP application. I'm getting output from mic on one 
iPhone and I would like to send that data in real time to another device (or 
may be some other device in group chat).

I'm thinking about direct iphone to iphone communication (in different 
networks) for data transfer. May be by means of client-server architecture.

How could I do that?

Is there any way that allows me data transfer between two or more devices by 
means of internet? I could use web server as a middle node to help device to 
establish communication.

PS
  At extra case I could use web server and store data in SQL database but it is 
less preferable case b/c of performance issue during live audio 
transfer/streaming


Thank you a lot!
Rufat


___

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

Please do not post 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-29 Thread Michael Hall
On May 28, 2013, at 5:55 PM, Greg Parker wrote:

 On May 28, 2013, at 3:39 PM, Michael Hall mik3h...@gmail.com 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.

This is sort of off-topic but I think this is a little tougher to be sure on 
isn't it? 
2*64 if a pretty big number. DES is sort of got on the outs because they were 
coming up with attacks that could go after it non-stop brute force in about 
2*56 tries. The birthday paradox may apply here too where collisions are much 
more likely at something a lot less than 2*64. I don't know. SHA-1 for purposes 
like like Jens suggested, to avoid forgeability, is also I thought sort of on 
the outs due to progress in attackers figuring out how to cause collisions. But 
it has been around a long time and I suppose converting to SHA-2 or something 
else for something like git would be a pretty large effort. If attackers aren't 
the concern I think it might still make a slow and large but tried and true as 
far as it goes general purpose hash, with usually good attributes for collision 
resistance and uniform distribution.

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-29 Thread Jean-Daniel Dupas

Le 29 mai 2013 à 00:46, Graham Cox graham@bigpond.com a écrit :

 
 On 28/05/2013, at 3:46 PM, Oleg Krupnov oleg.krup...@gmail.com 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.

It may be a thin wrapper. Unlike with NSData that actually wraps the passed 
buffer, NSString does not make any guarantee about what it does.
My experience is that most of the times, NSString with actually copy the bytes 
and create its own internal representation.

That said, even if NSString creates an internal representation, I agree that 
trying a more complex approach without profiling data is pointless.

-- 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: NSMapTable with C strings as keys

2013-05-29 Thread Jean-Daniel Dupas

Le 29 mai 2013 à 06:14, Oleg Krupnov oleg.krup...@gmail.com a écrit :

 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.
 

If method dispatch time is your main problem, just use CFString and 
CFDictionary API.

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

is bug reporter down?

2013-05-29 Thread Roland King
I've been trying for 2 weeks on every machine I use, home and work, on every 
browser installed on them and get an error, which I've reported twice. Not a 
very useful error, just An error has occurred. 

Is it just me, or is it actually down? I have two more UICollectionView and two 
NSManagedObjectContext bugs I'be been waiting to file. I've tried bugreport and 
bugreporter. I'm sure I remember cases in the past where it was down for some 
people and not others but if so, I never learned how they got out of it. 


___

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

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

Help/Unsubscribe/Update your Subscription:
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-29 Thread Paul Johnson
Quincy Morisses reply completely resolved the issue I was having with
bindings. I realized that we exchanged emails without copying this board. I
think Quincy's reply might be helpful to others, so I'm reposting his reply
on this board:

On May 28, 2013, at 16:25 , Paul Johnson p...@askerko.net wrote:

Thanks, Quincey, for your reply. AFAIK, my code is KVO-compliant. (I tried
to use @property and in fact found a decent and recent example that taught
me what I needed to synchronize the slider, stepper, and textField. Before
I found this example I was getting some runtime errors about
non-compliance. I started again from scratch, following the example code,
and came up with a nice short sample program. I've still got the
initialization issue though.)

I think the best way to show what I've done is to just bundle the project
in a .dmg file and send it to you as it is very short. I hope you can
suggest something without using much of your time.


When you bind the controls to a property, they get the initial value of the
property -- the value of the control you set in IB is ignored when the
binding is established.

So you'll need to arrange for the property to be initialized to the correct
value. For example, in the Bandwidth class:

- (id) init {
self = [super init];
_densityEstimationBandwidth = 10;
return self;
}


There is an alternative way to do this with literally no lines of code
(though I it's probably going to be too simple-minded an approach when your
app gets a bit more complicated). Select the Bandwidth object in your XIB,
and display the identity inspector (3rd icon from the left). Add a
user-defined run-time attribute, specifying densityEstimationBandwidth
for the key path, Number for the type, and the desired initial value.


On Tue, May 28, 2013 at 7:01 PM, Paul Johnson p...@askerko.net wrote:

 Wonderful! Thanks a lot! I owe you a beer.

 I learned a lot from your reply. Eventually I hope to fully understand the
 intricacies of Bindings. I think a good book on this topic would be a
 bestseller.

 I chose your 2nd method, setting the Key Path in the XIB file. (What I'm
 doing is converting a program that uses (arghh) Qt, and I want to minimize
 the amount of actual code I need to write so the advantage of using Xcode
 and Objective-C is totally obvious.)

 Again, thanks for your help.


 On Tue, May 28, 2013 at 6:48 PM, Quincey Morris 
 quinceymor...@rivergatesoftware.com wrote:

 On May 28, 2013, at 16:25 , Paul Johnson p...@askerko.net wrote:

 Thanks, Quincey, for your reply. AFAIK, my code is KVO-compliant. (I
 tried to use @property and in fact found a decent and recent example that
 taught me what I needed to synchronize the slider, stepper, and textField.
 Before I found this example I was getting some runtime errors about
 non-compliance. I started again from scratch, following the example code,
 and came up with a nice short sample program. I've still got the
 initialization issue though.)

 I think the best way to show what I've done is to just bundle the project
 in a .dmg file and send it to you as it is very short. I hope you can
 suggest something without using much of your time.


 When you bind the controls to a property, they get the initial value of
 the property -- the value of the control you set in IB is ignored when the
 binding is established.

 So you'll need to arrange for the property to be initialized to the
 correct value. For example, in the Bandwidth class:

 - (id) init {
 self = [super init];
 _densityEstimationBandwidth = 10;
 return self;
 }


 There is an alternative way to do this with literally no lines of code
 (though I it's probably going to be too simple-minded an approach when your
 app gets a bit more complicated). Select the Bandwidth object in your XIB,
 and display the identity inspector (3rd icon from the left). Add a
 user-defined run-time attribute, specifying densityEstimationBandwidth
 for the key path, Number for the type, and the desired initial value.



___

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

Please do not post 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: is bug reporter down?

2013-05-29 Thread Ken Thomases
On May 29, 2013, at 7:06 AM, Roland King wrote:

 I've been trying for 2 weeks on every machine I use, home and work, on every 
 browser installed on them and get an error, which I've reported twice. Not a 
 very useful error, just An error has occurred. 
 
 Is it just me, or is it actually down? I have two more UICollectionView and 
 two NSManagedObjectContext bugs I'be been waiting to file. I've tried 
 bugreport and bugreporter. I'm sure I remember cases in the past where it was 
 down for some people and not others but if so, I never learned how they got 
 out of it. 

I just logged in successfully.  If you haven't already, try both http://… and 
https://…; might make a difference.  I entered bugreport.apple.com.

Are you able to successfully log in to other parts of the site with the same 
Apple ID?  For example, the Developer Center.

Good luck,
Ken


___

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

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

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

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

Re: is bug reporter down?

2013-05-29 Thread Roland King

On 29 May, 2013, at 9:43 PM, Ken Thomases k...@codeweavers.com wrote:

 On May 29, 2013, at 7:06 AM, Roland King wrote:
 
 I've been trying for 2 weeks on every machine I use, home and work, on every 
 browser installed on them and get an error, which I've reported twice. Not a 
 very useful error, just An error has occurred. 
 
 Is it just me, or is it actually down? I have two more UICollectionView and 
 two NSManagedObjectContext bugs I'be been waiting to file. I've tried 
 bugreport and bugreporter. I'm sure I remember cases in the past where it 
 was down for some people and not others but if so, I never learned how they 
 got out of it. 
 
 I just logged in successfully.  If you haven't already, try both http://… and 
 https://…; might make a difference.  I entered bugreport.apple.com.
 
 Are you able to successfully log in to other parts of the site with the same 
 Apple ID?  For example, the Developer Center.
 
 Good luck,
 Ken
 

Damnation. Tried all of the above, http, https, both URLs, tried on an already 
authenticated session, cleaned cookies, tried it in incognito mode. I can 
access devcenter, devforums, I've checked for agreements I haven't agreed to 
(found none) and so it must just be my account. 

Thanks for the replies, unless anyone has faced this and knows how to get out 
of it, please treat this thread as closed (or mail me directly), I'll try dev 
support if I can find the link. 
___

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

Please do not post 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: is bug reporter down?

2013-05-29 Thread Steve Mills
On May 29, 2013, at 07:06:00, Roland King r...@rols.org
 wrote:

 I've been trying for 2 weeks on every machine I use, home and work, on every 
 browser installed on them and get an error, which I've reported twice. Not a 
 very useful error, just An error has occurred. 
 
 Is it just me, or is it actually down? I have two more UICollectionView and 
 two NSManagedObjectContext bugs I'be been waiting to file. I've tried 
 bugreport and bugreporter. I'm sure I remember cases in the past where it was 
 down for some people and not others but if so, I never learned how they got 
 out of it. 

I've had this problem from time to time, but quitting Safari and relaunching 
has always fixed it for me.

--
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: Flash inside an app

2013-05-29 Thread Jens Alfke

On May 29, 2013, at 12:06 AM, Alexandru Gologan alexandru.golo...@gmail.com 
wrote:

 Hey, per OSX app-store regulations would an app be approved if it loads a 
 flash player inside a uiwebview but does not show that view, instead 
 expanding on the callbacks from it and creating a new experience and adding 
 new functionality to that service!?
 I know Shiny Groove does something similar for the Grooveshark service, is it 
 ok?

I can’t think of any reason that wouldn’t be OK by Apple. What are you worried 
about?

On the other hand, I think it’s likely that the 3rd party service would be 
unhappy and try to block or break your app, either by keeping it from logging 
in or by changing the internal APIs incompatibly.

—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: [RAA] realtime audio data transfer between two iOS devices

2013-05-29 Thread Jens Alfke

On May 29, 2013, at 1:06 AM, Rufat A. Abdullayev rufa...@agbank.az wrote:

 Could you pls help me. I browsed a lot but could not find real answer

What types of search keywords did you use?

 I'm implementing Voice over IP application. I'm getting output from mic on 
 one iPhone and I would like to send that data in real time to another device 
 (or may be some other device in group chat).

This is a big topic. There are many protocols and frameworks, and many books 
written about it. You’re not going to get any simple answer.

Issues include:
* Discovery of the other device’s IP address (Bonjour works locally; at wider 
range you need some kind of server)
* Making a direct P2P connection to a device behind a NAT or firewall
* Using UDP for streaming (TCP is usually inappropriate, because packet loss is 
OK but latency isn’t)
* Voice-oriented data compression algorithms
* Real-time low-latency audio recording and playback
* Echo cancellation (this is a must unless both sides are using headphones)

Google’s libJingle might be a good place to start 
https://developers.google.com/talk/libjingle/

—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

Handling [super init] returning nil

2013-05-29 Thread Peter Teeson
In Apple's Concepts in Objective-C Programming discussing Issues with 
Initializers there is this code snippet

id anObject = [[MyClass alloc] init];
if (anObject) {
   [anObject doSOmething];
   // more messages…
} else {
  // handle error
}

All the code I Googled does not address the nil case in an error handling way. 
What one sees is mostly just returning nil.

In the interest of writing correct code I am curious to know the norm for 
handling such an error? 

Use NSAssert and/or assert and friends? 
Just log it? 
Put up a Dialog ?

TIA for your thoughts.

Peter

___

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

Please do not post 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-29 Thread Jens Alfke

On May 28, 2013, at 9:14 PM, Oleg Krupnov oleg.krup...@gmail.com wrote:

 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. 

Oh, also: What you’ve said above is a good reason for factoring out common code 
instead of repeating it in multiple places (aka “Don’t Repeat Yourself” or 
DRY). If you write this string lookup code once as a function/method you can 
use in many places, then it will show up as a hot-spot in the profiler if it’s 
slow, and then optimizing it in one place will speed up your app. If you 
copy/paste the code instead, the time will be split up among multiple copies of 
it so it’s less likely to show up, and even if it does show up you’d have to 
implement the optimization in many places.

(Unfortunately if you use inline functions you can have cases where you did 
only write the code once but the compiler copied it into lots of places, making 
it not show up as a hot spot. That’s a reason to be really careful about 
inlining; it can backfire on you. Mostly that's only a problem in C++ though, 
where inlining and templates are used a lot and it’s easy to write code that 
looks short and simple but explodes into a lot of instructions. I’ve had the 
“fun” of trying to optimize code like that before.)

—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-29 Thread Jens Alfke

On May 28, 2013, at 9:14 PM, Oleg Krupnov oleg.krup...@gmail.com wrote:

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

Did you actually profile the app and find that a lot of time is spent in this 
code?

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


Because the most important measure of time is the time you have available to 
develop the app. Any time you spend optimizing something is time you don’t have 
available to optimize a more significant piece of code, or add features, or fix 
bugs. Also, optimized code is often more complex than KISS code, making it less 
reliable, and harder to debug and improve.

Sometimes it’s really obvious that something is going to be a major bottleneck. 
(Or it’s not obvious, but you’re enough of an expert in the domain to know from 
experience that it will be.) And sometimes it’s almost as easy to do something 
efficiently than to do it slowly. But most often it does pay off to do it the 
simple way first and then go back and optimize only the things that are 
important.

—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: Core Data never seems to be able to auto-update schema

2013-05-29 Thread Sean McBride
On Tue, 28 May 2013 21:16:05 -0700, Rick Mann said:

Pity Xcode doesn't automatically make a copy of the model when you make
a change (after each build).

That would be really annoying during development when your model is changing 
rapidly.

Also, IIRC, inferred migration requires that newly added attributes have a 
default value.

Cheers,

-- 

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

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

Re: Handling [super init] returning nil

2013-05-29 Thread David Duncan
On May 29, 2013, at 9:36 AM, Peter Teeson ptee...@icloud.com wrote:

 In Apple's Concepts in Objective-C Programming discussing Issues with 
 Initializers there is this code snippet
 
 id anObject = [[MyClass alloc] init];
 if (anObject) {
   [anObject doSOmething];
   // more messages…
 } else {
  // handle error
 }
 
 All the code I Googled does not address the nil case in an error handling 
 way. What one sees is mostly just returning nil.
 
 In the interest of writing correct code I am curious to know the norm for 
 handling such an error? 


Generally the reason why you see so little handling of this error is that both 
its handling is context dependent, and that handling it may be in fact 
impossible.

Assuming the best case, an -init method returns nil because there is some error 
that prevents the object from being initialized, the proper course of handling 
it is going to be entirely application dependent. If that object represents a 
download you might alert the user that the download is impossible. If it 
represented a file on disk, you might just create the file and continue on 
instead. And so on. Hence why it is hard to tell you what to do with the error.

On the other hand, the worst case is that +alloc returned nil because there is 
no memory left in your address space. More than likely your application will 
crash soon trying to do just about anything.

Typically in cases where there is a possibility for failure that can be 
recovered from, an NSError object is returned (typically as an additional 
parameter). If you search for methods that use NSError you'll find copious 
examples of this. But again how you actually handle the error is entirely 
context dependent.
--
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

Reserved method prefixes in Cocoa. Is there a reference list?

2013-05-29 Thread Alex Zavatone
I'm aware that certain prefixes like set are bad news to use to start method 
names for obvious reasons, but with the caffeine levels in my brain cell 
running low, I'm at a loss to recall some of the others (is return verboten?).  
Is there a list of reserved method prefix strings that you simply shouldn't use 
to start your methods?

Just want to have a little list handy of don't start methods with these words.

My sleep deprivation thanks you.



___

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

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

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

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


Re: Reserved method prefixes in Cocoa. Is there a reference list?

2013-05-29 Thread Jens Alfke

On May 29, 2013, at 10:37 AM, Alex Zavatone z...@mac.com wrote:

 I'm aware that certain prefixes like set are bad news to use to start 
 method names for obvious reasons, but with the caffeine levels in my brain 
 cell running low, I'm at a loss to recall some of the others (is return 
 verboten?).  Is there a list of reserved method prefix strings that you 
 simply shouldn't use to start your methods?

There aren’t any forbidden prefixes that I know of, but there are ones that 
should be used only for particular purposes, because the compiler and/or 
runtime will make assumptions about them when they see that prefix.

It’s fine to have a method -setFoo:, it’s just that it will be interpreted as a 
setter for a property “foo”. Which is usually what you meant anyway.

ARC makes assumptions about special refcounting behavior of methods named 
“copy” or “mutableCopy” or that start with “init” or “alloc” or “new” — all of 
these are assumed to return an object reference that needs to be released by 
the caller. There might be others but those are all I can remember; the ARC 
docs may have a complete list.

—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: Reserved method prefixes in Cocoa. Is there a reference list?

2013-05-29 Thread Kyle Sluder
On Wed, May 29, 2013, at 11:28 AM, Jens Alfke wrote:
 
 There aren’t any forbidden prefixes that I know of, but there are ones
 that should be used only for particular purposes, because the compiler
 and/or runtime will make assumptions about them when they see that
 prefix.

Apple selfishly reserves the underscore prefix for its own private
methods, and even goes so far as to suggest prefixing your own methods
with ugly unique prefixes:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html

Because clearly we don't need namespaces in a modern object oriented
programming language.

--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: Flash inside an app

2013-05-29 Thread Kyle Sluder
On Wed, May 29, 2013, at 12:06 AM, Alexandru Gologan wrote:
 Hey, per OSX app-store regulations would an app be approved if it loads a
 flash player inside a uiwebview

How do you propose to achieve this?

--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: Flash inside an app

2013-05-29 Thread Kyle Sluder
On Wed, May 29, 2013, at 11:46 AM, Kyle Sluder wrote:
 On Wed, May 29, 2013, at 12:06 AM, Alexandru Gologan wrote:
  Hey, per OSX app-store regulations would an app be approved if it loads a
  flash player inside a uiwebview
 
 How do you propose to achieve this?

Never mind. You clearly did not mean UIWebView, since you're asking
about the OS X app store.

UIWebView == iOS, WebView == Mac.

--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: Reserved method prefixes in Cocoa. Is there a reference list?

2013-05-29 Thread Alex Zavatone
Now that my brain cell's caffeine levels are normalizing, I seem to recall 
somewhere in the Cocoa docs stating that starting a method name with a string 
like return is somewhat frowned upon.

Yeah, it must have been in the ARC docs.  I remember that using init or new are 
not good ideas.

That pointed me in the right direction:

Here's part of what I was concerned about from:
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.pdf

Basic Memory Management Rules
The memory management model is based on object ownership. Any object may have 
one or more owners. As long as an object has at least one owner, it continues 
to exist. If an object has no owners, the runtime system destroys it 
automatically. To make sure it is clear when you own an object and when you do 
not, Cocoa sets the following policy:

•   You own any object you create
You create an object using a method whose name begins with “alloc”, 
“new”, “copy”, or “mutableCopy” (for example, alloc, newObject, or mutableCopy).


I'll just try to note any rules or recommendations that I come across.  Thanks.

On May 29, 2013, at 2:28 PM, Jens Alfke wrote:

 
 On May 29, 2013, at 10:37 AM, Alex Zavatone z...@mac.com wrote:
 
 I'm aware that certain prefixes like set are bad news to use to start 
 method names for obvious reasons, but with the caffeine levels in my brain 
 cell running low, I'm at a loss to recall some of the others (is return 
 verboten?).  Is there a list of reserved method prefix strings that you 
 simply shouldn't use to start your methods?
 
 There aren’t any forbidden prefixes that I know of, but there are ones that 
 should be used only for particular purposes, because the compiler and/or 
 runtime will make assumptions about them when they see that prefix.
 
 It’s fine to have a method -setFoo:, it’s just that it will be interpreted as 
 a setter for a property “foo”. Which is usually what you meant anyway.
 
 ARC makes assumptions about special refcounting behavior of methods named 
 “copy” or “mutableCopy” or that start with “init” or “alloc” or “new” — all 
 of these are assumed to return an object reference that needs to be released 
 by the caller. There might be others but those are all I can remember; the 
 ARC docs may have a complete list.
 
 —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: Reserved method prefixes in Cocoa. Is there a reference list?

2013-05-29 Thread Jens Alfke

On May 29, 2013, at 11:46 AM, Kyle Sluder k...@ksluder.com wrote:

 Because clearly we don't need namespaces in a modern object oriented
 programming language.

Oh boy. First off, to pre-empt any lengthy threads about this, people should go 
and read last year’s discussion over on the objc-language list, which started 
with a very detailed proposal for how to add namespaces.

Second, adding namespaces is definitely nontrivial, mostly for compatibility 
reasons. Any naive way of adding namespaces would break many of the dynamic 
features of Objective-C and consequently things like KVC/KVO and target-action.

Anyway, people, don’t reply here. If you read that earlier thread and still 
think you have more to add, go do it on the objc-language list, not here.

—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: Reserved method prefixes in Cocoa. Is there a reference list?

2013-05-29 Thread Alex Zavatone

On May 29, 2013, at 2:46 PM, Kyle Sluder wrote:

 On Wed, May 29, 2013, at 11:28 AM, Jens Alfke wrote:
 
 There aren’t any forbidden prefixes that I know of, but there are ones
 that should be used only for particular purposes, because the compiler
 and/or runtime will make assumptions about them when they see that
 prefix.
 
 Apple selfishly reserves the underscore prefix for its own private
 methods, and even goes so far as to suggest prefixing your own methods
 with ugly unique prefixes:
 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html

Be that as it may, this is exactly the document I was looking for - and also a 
little eye opening.  It looks like there are many more conditions to pay 
attention to when naming methods.  Thank you Kyle.



___

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

Please do not post 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: Reserved method prefixes in Cocoa. Is there a reference list?

2013-05-29 Thread Lee Ann Rucker
Clang objected to a variable that started with new when we turned it into a 
property, because then there was a method named new that wasn't doing what it 
expected. I don't remember the details; I renamed it a long time ago.

On May 29, 2013, at 10:37 AM, Alex Zavatone wrote:

 I'm aware that certain prefixes like set are bad news to use to start 
 method names for obvious reasons, but with the caffeine levels in my brain 
 cell running low, I'm at a loss to recall some of the others (is return 
 verboten?).  Is there a list of reserved method prefix strings that you 
 simply shouldn't use to start your methods?
 
 Just want to have a little list handy of don't start methods with these 
 words.
 
 My sleep deprivation thanks you.
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com
 
 This email sent to lruc...@vmware.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


Dismissing menu from menu item that uses custom view

2013-05-29 Thread Steve Mills
I have an NSView subclass that's used to draw contents of a menu item. When I 
get a mouseUp in my view, I need to flash the hilite (I'm guessing just draw it 
a couple times with a short delay between draws), dismiss the menu and perform 
the action associated with the item. These seem like the right methods to use, 
but the menu is not closing before the action executes. What's a better way to 
do this? The MenuItemView sample app also has this problem when you click the 
Button.

- (void)mouseUp:(NSEvent*)event
{
UNUSED_VAR(event);

NSMenuItem* item = [self enclosingMenuItem];
NSMenu* menu = [item menu];

// On mouseUp, we want to dismiss the menu being tracked:
[menu cancelTracking];

// Then send the action to the target:
SEL act = [item action];
id  targ = [item target];

if(act != nil  targ != nil)
//  [NSApp sendAction:act to:targ from:item];
// Temporarily sending the About menu item so it'll fire the About box:
[NSApp sendAction:act to:targ from:[menu itemAtIndex:0]];

// Copied from MenuItemView sample project. I don't think this is necessary:
//  [self setNeedsDisplay:YES];
}

--
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: Dismissing menu from menu item that uses custom view

2013-05-29 Thread Graham Cox

On 30/05/2013, at 8:41 AM, Steve Mills smi...@makemusic.com wrote:

 but the menu is not closing before the action executes


This is normal. I think the idea is that the user gets a cue that whatever 
action is being executed came from a menu choice, so the menu remains visible 
while the action is carried out.

Further, if you don't want this, calling -cancelTracking probably only 
schedules the closure, and requires some iterations of the runloop to take 
effect. The easiest solution might be not to directly invoke your action, but 
schedule that to be performed after a short delay (maybe 0), which will let the 
menu close first before invoking the action.

--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: Dismissing menu from menu item that uses custom view

2013-05-29 Thread Lee Ann Rucker
Use performSelector:withObject:afterDelay:0 to push your response to the end of 
the run loop, giving the UI a chance to update first. It's what I do when a 
button (etc) is going to trigger something that won't be instantaneous, where 
the button shouldn't keep showing in the pressed state while it happens.

On May 29, 2013, at 3:41 PM, Steve Mills wrote:

 I have an NSView subclass that's used to draw contents of a menu item. When I 
 get a mouseUp in my view, I need to flash the hilite (I'm guessing just draw 
 it a couple times with a short delay between draws), dismiss the menu and 
 perform the action associated with the item. These seem like the right 
 methods to use, but the menu is not closing before the action executes. 
 What's a better way to do this? The MenuItemView sample app also has this 
 problem when you click the Button.
 
 - (void)mouseUp:(NSEvent*)event
 {
   UNUSED_VAR(event);
   
   NSMenuItem* item = [self enclosingMenuItem];
   NSMenu* menu = [item menu];
   
   // On mouseUp, we want to dismiss the menu being tracked:
   [menu cancelTracking];
   
   // Then send the action to the target:
   SEL act = [item action];
   id  targ = [item target];
   
   if(act != nil  targ != nil)
 //[NSApp sendAction:act to:targ from:item];
 // Temporarily sending the About menu item so it'll fire the About box:
   [NSApp sendAction:act to:targ from:[menu itemAtIndex:0]];
   
 // Copied from MenuItemView sample project. I don't think this is necessary:
 //[self setNeedsDisplay:YES];
 }
 
 --
 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/lrucker%40vmware.com
 
 This email sent to lruc...@vmware.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: Dismissing menu from menu item that uses custom view

2013-05-29 Thread Steve Mills
On May 29, 2013, at 18:06:45, Lee Ann Rucker lruc...@vmware.com
 wrote:

 Use performSelector:withObject:afterDelay:0 to push your response to the end 
 of the run loop, giving the UI a chance to update first. It's what I do when 
 a button (etc) is going to trigger something that won't be instantaneous, 
 where the button shouldn't keep showing in the pressed state while it happens.

Good idea, but I need to send the 3rd parameter; the selector, the target, and 
the sender. I can't do that with performSelector:withObject:afterDelay:.

--
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: Dismissing menu from menu item that uses custom view

2013-05-29 Thread Steve Mills
On May 29, 2013, at 17:59:58, Graham Cox graham@bigpond.com
 wrote:

 This is normal. I think the idea is that the user gets a cue that whatever 
 action is being executed came from a menu choice, so the menu remains 
 visible while the action is carried out.

That's totally untrue. When an item is chosen, the menu goes away, but the menu 
title in the menubar remains hilited until control is returned to the event 
loop that spawned the menu. Leaving the menu visible would be very ugly and 
confusing.

--
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: Dismissing menu from menu item that uses custom view

2013-05-29 Thread Lee Ann Rucker
Don't delay the action/target part, write a wrapper function and delay that:

- (void)mouseUp:(NSEvent*)event
{
UNUSED_VAR(event);

NSMenuItem* item = [self enclosingMenuItem];
NSMenu* menu = [item menu];
// On mouseUp, we want to dismiss the menu being tracked:
[menu cancelTracking];
[self performSelector:@selector(delayedSendAction:) withObject:item 
afterDelay:0];
}

- (void)delayedSendAction: (NSMenuItem *)item
{
// Then send the action to the target:
SEL act = [item action];
id  targ = [item target];

if(act != nil  targ != nil)
//  [NSApp sendAction:act to:targ from:item];
// Temporarily sending the About menu item so it'll fire the About box:
[NSApp sendAction:act to:targ from:[menu itemAtIndex:0]];

// Copied from MenuItemView sample project. I don't think this is necessary:
//  [self setNeedsDisplay:YES];
}
On May 29, 2013, at 4:34 PM, Steve Mills wrote:

 On May 29, 2013, at 18:06:45, Lee Ann Rucker lruc...@vmware.com
 wrote:
 
 Use performSelector:withObject:afterDelay:0 to push your response to the end 
 of the run loop, giving the UI a chance to update first. It's what I do when 
 a button (etc) is going to trigger something that won't be instantaneous, 
 where the button shouldn't keep showing in the pressed state while it 
 happens.
 
 Good idea, but I need to send the 3rd parameter; the selector, the target, 
 and the sender. I can't do that with performSelector:withObject:afterDelay:.
 
 --
 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/lrucker%40vmware.com
 
 This email sent to lruc...@vmware.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: Dismissing menu from menu item that uses custom view

2013-05-29 Thread Graham Cox

On 30/05/2013, at 9:37 AM, Steve Mills smi...@makemusic.com wrote:

 On May 29, 2013, at 17:59:58, Graham Cox graham@bigpond.com
 wrote:
 
 This is normal. I think the idea is that the user gets a cue that whatever 
 action is being executed came from a menu choice, so the menu remains 
 visible while the action is carried out.
 
 That's totally untrue. When an item is chosen, the menu goes away, but the 
 menu title in the menubar remains hilited until control is returned to the 
 event loop that spawned the menu. Leaving the menu visible would be very ugly 
 and confusing.

You're right. Shouldn't comment before coffee.

--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: NSMapTable with C strings as keys

2013-05-29 Thread Ian Joyner
On 29 May 2013, at 14:14, Oleg Krupnov oleg.krup...@gmail.com wrote:

 While I generally agree that premature optimization is evil,

That seems to come out of a belief that well-structured code is code that runs 
poorly (this belief came out of an IBM system of the 50s/60s that had really 
poorly running subroutine calls - so the recommendation was not to structure 
things).

In one sense I think we should always be optimizing code. That is in the sense 
that we write well structured and correct code. Usually optimization naturally 
follows. There seems to be a school of thought that writing poorly structured 
code must be optimized, but I have usually seen that most badly running code is 
a result of poor structure and refactoring makes it both structured and 
optimized. Once you have got to such a structured state then you might be able 
to see where further optimizations can be made to profiled areas of code which 
might result in more complex, but still structured and optimized. Where 
something simple is replaced by a more complex algorithm it should be well 
documented.

That is the subject of Dijkstra's book A Discipline of Programming. Once a 
well-structured algorithm is developed, better optimizations can then be seen. 
This is the 'engineering' part of software development - making software run 
practically (not the drawing diagrams part). For particular computations (that 
is where the algorithm works on particular data sets), an algorithm might not 
be optimal, so needs to cater to those cases.

In summary - we should be producing well-structured code early on. This will 
usually result in well-optimized code. However, this is not a guarantee and 
particular cases may need to be addressed later (that is the premature 
optimization case). But we should always aim to produce well-structured 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-29 Thread Jens Alfke

On May 29, 2013, at 6:30 PM, Ian Joyner ianjoy...@me.com wrote:

 That seems to come out of a belief that well-structured code is code that 
 runs poorly

No, it’s a paraphrase of a famous quote by Don Knuth (We should forget about 
small efficiencies, say about 97% of the time: premature optimization is the 
root of all evil.”[1]) He later attributed this to C.A.R. Hoare.

The main points behind this are, in my opinion, that: (a) you don’t ever have 
time to optimize the entire program, and (b) it’s often very unintuitive which 
parts of the code are bottlenecks. Additionally I find that (c) lots of the 
code I write ends up being scaffolding that’s going to get replaced anyway 
later on during development; and (d) heavily optimized code is often harder to 
maintain.

A more extreme version of this statement is the Ward Cunningham's mantra “Do 
The Simplest Thing That Could Possibly Work”[2].

I think these are two of the best lessons I’ve learned as I progressed in my 
craft. They've made me a lot more productive. There’s no point in optimizing 
something that never gets finished; and getting rat-holed into tweaking tiny 
details was really preventing me from getting things to the point where they 
were useable at all.

—Jens

[1] http://en.wikipedia.org/wiki/Program_optimization#When_to_optimize
[2] 
http://en.wikiquote.org/wiki/Ward_Cunningham#The_Simplest_Thing_that_Could_Possibly_Work
___

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

Please do not post 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: Dismissing menu from menu item that uses custom view

2013-05-29 Thread Steve Mills
On May 29, 2013, at 18:46:18, Lee Ann Rucker lruc...@vmware.com
 wrote:

 Don't delay the action/target part, write a wrapper function and delay that:

Heh, so simple. Thanks!

--
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-29 Thread Eric Wing
I'm not disagreeing with anything about knowing/optimizing your real
bottlenecks.

But I did do hash table benchmarks a few months back:
http://playcontrol.net/opensource/LuaHashMap/benchmarks.html

CFDictionary I did not formally do in the benchmark, but I did run on
the side for curiosity. I found that the C-string to CFString
conversion ended up putting it at the bottom of the list in terms of
performance.


-Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
___

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

Please do not post 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-29 Thread Charles Srstka
On May 29, 2013, at 10:29 PM, Eric Wing ewmail...@gmail.com wrote:

 But I did do hash table benchmarks a few months back:
 http://playcontrol.net/opensource/LuaHashMap/benchmarks.html

Perhaps off topic, but I wonder if it would be possible to alter your line 
charts so that those circles that appear periodically along the lines are 
actually a different shape for each line instead of always being circles. This 
wouldn't alter the visual appearance of the charts too much, and would make 
them much easier to read for those who suffer from colorblindness and thus have 
trouble differentiating using color alone (I particularly find it difficult to 
distinguish the Tcl line from the Python line in the chart at the top of the 
linked page without the use of Digital ColorMeter).

Charles


___

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

Please do not post 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-29 Thread Jens Alfke

On May 29, 2013, at 8:29 PM, Eric Wing ewmail...@gmail.com wrote:

 CFDictionary I did not formally do in the benchmark, but I did run on
 the side for curiosity. I found that the C-string to CFString
 conversion ended up putting it at the bottom of the list in terms of
 performance.

It seems unfair to include the C-string-to-object conversion time in the 
benchmark, if what you’re trying to measure is hash-table performance. Did you 
include that in the benchmarks for the other languages too? (And using real 
Unicode-savvy string objects — I know Python has both types)?

—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