Re: GCD cancel handler invocation

2011-01-10 Thread Jonathon Kuo

On Jan 10, 2011, at 2:58 PM, Ken Thomases wrote:

> On Jan 10, 2011, at 4:20 PM, Dave Zarzycki wrote:
> 
>> On Jan 10, 2011, at 2:06 PM, Jonathon Kuo wrote:
>> 
>>> I set up a source handler on a TCP socket like this:
>>>  dispatch_source_t newsrc = 
>>> dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,sockfd,0,globalQueue); 
>>> 
>>> It works well, and when a client process closes his socket my 
>>> cancel_handler gets called, I clean up, and life is good. But if I do a 
>>> close(sockfd) from my side, my cancel_handler doesn't get invoked. I have 
>>> to explicitly do a dispatch_source_cancel(). Shouldn't closing the socket 
>>> be enough to cause my cancel_handler to be run?
>> 
>> Jonathon,
>> 
>> No. This is covered in the dispatch_source_create() man page under the 
>> section on cancelation:
>> 
>> Important: a cancellation handler is required for file descriptor and mach 
>> port based sources in order to safely close the descriptor or destroy the 
>> port. Closing the descriptor or port before the cancellation handler has run 
>> may result in a race condition: if a new descriptor is allocated with the 
>> same value as the recently closed descriptor while the source's event 
>> handler is still running, the event handler may read/write data to the wrong 
>> descriptor.
> 
> And, likewise, it is not safe to close a file descriptor in one thread while 
> it is the subject of a read(), select(), kevent(), or similar in another 
> thread.  In other words, in no system API is it safe to do what you're trying 
> to do.

Okay... then is the only place I should ever call the close() is from within 
the cancel_handler for that file descriptor?


___

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

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

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

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


GCD cancel handler invocation

2011-01-10 Thread Jonathon Kuo
I set up a source handler on a TCP socket like this:
dispatch_source_t newsrc = 
dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,sockfd,0,globalQueue); 

It works well, and when a client process closes his socket my cancel_handler 
gets called, I clean up, and life is good. But if I do a close(sockfd) from my 
side, my cancel_handler doesn't get invoked. I have to explicitly do a 
dispatch_source_cancel(). Shouldn't closing the socket be enough to cause my 
cancel_handler to be run?

___

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

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

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

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


Re: Context in GCD source cancel handler?

2011-01-06 Thread Jonathon Kuo
Wonderful, will do!
Thanks to all!

On Jan 6, 2011, at 1:31 PM, Dave Zarzycki wrote:

> Jonathon,
> 
> Please don't use SIGPIPE. That's just a hack from the 1970s to make simple 
> command line programs die when their input goes away. Instead, please call 
> signal(SIGPIPE, SIG_IGN) right inside of main(). Thereafter, Unix APIs like 
> read(), write(), etc will return -1 and errno will be equal to EPIPE.
> 
> davez
> 
> On Jan 6, 2011, at 1:22 PM, Jonathon Kuo wrote:
> 
>> On Jan 6, 2011, at 1:15 PM, Fritz Anderson wrote:
>> 
>>> Taking "by value" to mean "as many uninterpreted bits as will fit into a 
>>> variable of type void*," yes.
>> 
>> On Jan 6, 2011, at 1:14 PM, Dave Zarzycki wrote:
>> 
>>> Yes, that is the nature of void *. Nothing can be known about a void * 
>>> other than the value – therefore you can store anything there (even 
>>> non-pointers as long as they are <= sizeof(void *)).
>> 
>> Awesome! I get it now. This all came about because I am getting an 
>> occasional SIGPIPE when one of my read sources is closed on the client end, 
>> so having a context is great. Thanks!!
>> 
>> BTW, is there an inherent signal-handling capability with GCD so my program 
>> doesn't get blown out of the water when a SIGPIPE happens?
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/zarzycki%40apple.com
>> 
>> This email sent to zarzy...@apple.com
> 
> 

___

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

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

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

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


Re: Context in GCD source cancel handler?

2011-01-06 Thread Jonathon Kuo
On Jan 6, 2011, at 1:15 PM, Fritz Anderson wrote:

> Taking "by value" to mean "as many uninterpreted bits as will fit into a 
> variable of type void*," yes.

On Jan 6, 2011, at 1:14 PM, Dave Zarzycki wrote:

> Yes, that is the nature of void *. Nothing can be known about a void * other 
> than the value – therefore you can store anything there (even non-pointers as 
> long as they are <= sizeof(void *)).

Awesome! I get it now. This all came about because I am getting an occasional 
SIGPIPE when one of my read sources is closed on the client end, so having a 
context is great. Thanks!!

BTW, is there an inherent signal-handling capability with GCD so my program 
doesn't get blown out of the water when a SIGPIPE happens?

___

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

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

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

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


Re: Context in GCD source cancel handler?

2011-01-06 Thread Jonathon Kuo

On Jan 5, 2011, at 12:41 PM, Dave Keck wrote:

>> Q: When a context object is set with dispatch_set_context(), is it retained? 
>> Or do I need to retain it first, set it, and then in the cancel handler 
>> release it?
> 
> The 'context' argument is not retained. You can infer this primarily
> by the declaration of dispatch_set_context(), and also the mention
> that 'context' is "client defined" in dispatch/object.h; since the
> 'context' argument is an untyped pointer (void *),
> dispatch_set_context() cannot assume anything about the supplied
> 'context' argument, much less that it's a valid libdispatch object.
> 
So I can supply anything here and GCD stores it _by value_, whether its a 
simple integer or even a object pointer?

___

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

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

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

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


Re: Context in GCD source cancel handler?

2011-01-05 Thread Jonathon Kuo
Thanks Dave, that's awesome! Just what I was looking for! 

Q: When a context object is set with dispatch_set_context(), is it retained? Or 
do I need to retain it first, set it, and then in the cancel handler release it?

-Jon

On Jan 5, 2011, at 11:15 AM, Dave Zarzycki wrote:

> Jonathon,
> 
> GCD is an object oriented API done in C. If you look at the man page entitled 
> dispatch_object, you'll see that one can call dispatch_set_context() and 
> dispatch_get_context() against any GCD object (sources and queues are where 
> they make the most sense). In fact, if you're simply looking for a "goodbye 
> kiss" when the last reference to a GCD object is dropped (via 
> dispatch_retain() and dispatch_release()), then your code can install a 
> finalizer via dispatch_set_finalizer_f(), which is passed the same context 
> managed by the aforementioned API.
> 
> Have fun,
> 
> davez
> 
> 
> On Jan 5, 2011, at 10:58 AM, Jonathon Kuo wrote:
> 
>> When a GCD source gets cancelled, either via dispatch_source_cancel() or 
>> because the source went away, I have no context other than the 
>> dispatch_source_t source variable. How can I know for which source a source 
>> cancel handler gets invoked? I have many simultaneous sources (sockets, 
>> files, etc) and when a source cancel handler gets called I have no idea what 
>> source it's for, so I can't do cleanup. Is dispatch_source_t queryable? Is 
>> there a way to attach a userInfo object to it? Do I have to manage this 
>> externally in a table myself?___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/zarzycki%40apple.com
>> 
>> This email sent to zarzy...@apple.com
> 
> 

___

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

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

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

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


Context in GCD source cancel handler?

2011-01-05 Thread Jonathon Kuo
When a GCD source gets cancelled, either via dispatch_source_cancel() or 
because the source went away, I have no context other than the 
dispatch_source_t source variable. How can I know for which source a source 
cancel handler gets invoked? I have many simultaneous sources (sockets, files, 
etc) and when a source cancel handler gets called I have no idea what source 
it's for, so I can't do cleanup. Is dispatch_source_t queryable? Is there a way 
to attach a userInfo object to it? Do I have to manage this externally in a 
table myself?___

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

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

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

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


Re: cannot access __block variable of array type inside block

2010-12-14 Thread Jonathon Kuo
Thanks, Dave!  That works, though I don't understand why...


On Dec 14, 2010, at 7:35 PM, Dave Zarzycki wrote:

> Jonathon,
> 
> This is being tracked by our internal bug number 8590846. I'm told that the 
> workaround is to place the array within a structure:
> 
> __block struct {
>   double result[COUNT];
> } results;
> 
> 
> davez
> 
> 
> 
> On Dec 14, 2010, at 7:30 PM, Jonathon Kuo wrote:
> 
>> I'm trying to learn GCD and reading 
>> http://developer.apple.com/library/mac/#featuredarticles/BlocksGCD/index.html
>> But the Global Concurrent Queues example in that document (last updated 
>> 2010-11-10) doesn't even compile. It complains about accessing array 
>> 'result' from within the block:
>> 
>> #define COUNT 128
>> __block double result[COUNT];
>> dispatch_apply(COUNT, q_default, ^(size_t i){
>>  result[i] = complex_calculation(i);   /* <=== ERROR HERE!
>> });
>> double sum = 0;
>> for (int i=0; i < COUNT; i++) sum += result[i];
>> 
>> 
>> What is wrong here? This looks like it should work. Below is my full program.
>> -Jonathon
>> 
>> 
>> #include 
>> #include 
>> #define COUNT 128
>> 
>> double complex_calculation( int i )
>> {
>>  return i * 3.14;
>> }
>> 
>> int main()
>> {
>>  int i = 0;
>>  __block double result[COUNT];
>> 
>>  dispatch_queue_t q_default;
>>  /* get default queue */
>>  q_default = dispatch_get_global_queue(0, 0);
>> 
>>  dispatch_apply(COUNT, q_default, ^(size_t i) {
>>result[i] = complex_calculation(i);   /* <=== ERROR HERE!
>>  });
>> 
>>  double sum = 0;
>>  for (i=0; i < COUNT; i++) sum += result[i];
>>  printf("%f\n", sum);
>>  return 0;
>> }
>> 
>> $ cc -g blk3.c -o blk3
>> blk3.c: In function ‘__main_block_invoke_1’:
>> blk3.c:20: error: cannot access __block variable of array type inside block
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/zarzycki%40apple.com
>> 
>> This email sent to zarzy...@apple.com
> 

___

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

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

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

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


cannot access __block variable of array type inside block

2010-12-14 Thread Jonathon Kuo
I'm trying to learn GCD and reading 
http://developer.apple.com/library/mac/#featuredarticles/BlocksGCD/index.html
But the Global Concurrent Queues example in that document (last updated 
2010-11-10) doesn't even compile. It complains about accessing array 'result' 
from within the block:

#define COUNT 128
__block double result[COUNT];
dispatch_apply(COUNT, q_default, ^(size_t i){
result[i] = complex_calculation(i);   /* <=== ERROR HERE!
 });
double sum = 0;
for (int i=0; i < COUNT; i++) sum += result[i];


What is wrong here? This looks like it should work. Below is my full program.
-Jonathon


#include 
#include 
#define COUNT 128

double complex_calculation( int i )
{
  return i * 3.14;
}

int main()
{
  int i = 0;
  __block double result[COUNT];

  dispatch_queue_t q_default;
  /* get default queue */
  q_default = dispatch_get_global_queue(0, 0);

  dispatch_apply(COUNT, q_default, ^(size_t i) {
result[i] = complex_calculation(i);   /* <=== ERROR HERE!
  });

  double sum = 0;
  for (i=0; i < COUNT; i++) sum += result[i];
  printf("%f\n", sum);
  return 0;
}

$ cc -g blk3.c -o blk3
blk3.c: In function ‘__main_block_invoke_1’:
blk3.c:20: error: cannot access __block variable of array type inside block


___

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

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

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

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


Re: [iPhone] Toolbar button and "Touch Down"

2010-11-17 Thread Jonathon Kuo
On Nov 17, 2010, at 10:54 AM, Matt Neuburg wrote:
> 
> On Nov 17, 2010, at 10:25 AM, Jonathon Kuo wrote:
> 
>> One question though: Taking another poster's suggestion, I placed a UISwitch 
>> in the toolbar and set Touch Down on it. It does register, but only for the 
>> OFF -> ON transition. Switching it from ON -> OFF doesn't invoke the action 
>> method. Should I be using one of the other events to capture both state 
>> transitions?
> 
> Yes. Just connect the switch to the controller in the nib to form an action; 
> the correct event will be selected automatically.

Yep, using "Value Changed" it invokes the action for both switch transitions. I 
can just look at [sender state] and tell what's going on. Cool.
> 
> Please understand that I am trying to educate, not criticize, when I say that 
> for success in programming (for iOS or anything else) you must be willing to 
> try stuff - on your own. This has nothing to do with being a newbie - it's a 
> matter of character and determination. You could have selected the UIButton 
> within the UIBarButtonItem; you just didn't try hard enough. If you had, 
> repeated clicking and playing around would have led you to the truth. 
> Similarly, to discover what event is appropriate for a UISwitch, try 
> different events and see. m. 

Heh, this is kinda what I'm afraid of doing - screwing around with stuff and 
getting things to work, but not in the Cocoa Way.™  I guess there's a bit of 
intimidation to it so I try to follow where its leading me and not force it. 
But I suppose you're right, success awaits those who go where angels fear to 
tread (or whatever that saying is!)

___

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

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

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

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


Re: [iPhone] Toolbar button and "Touch Down"

2010-11-17 Thread Jonathon Kuo
On Nov 17, 2010, at 8:47 AM, Matt Neuburg wrote:
> 
> On Nov 16, 2010, at 9:26 AM, Jonathon Kuo wrote:
> 
>> I agree: that's how I expected it to work, too, but that's not how it does 
>> work (Xcode 3.2.4). If I drag a Round Rect Button onto the Toolbar, it 
>> instantly gets promoted to a UIBarButtonItem (really!), and I can't set 
>> "Touch Down" on it, nor can I change the class of it in IB. That's why I'm 
>> confused...
> 
> The Round Rect button that is dragged into the toolbar is not "promoted" to 
> anything. It is wrapped in a UIBarButtonItem, exactly as Dave (and I 
> advised). If you don't understand how to select the button itself using the 
> design window, then use List View in the nib's main document window and drill 
> down until you find it. m.

Thank you Matt for the clear explanation (and your patience with a noob)! I got 
access to the button from the List view and set the Touch Down event on the 
button. It works!

One question though: Taking another poster's suggestion, I placed a UISwitch in 
the toolbar and set Touch Down on it. It does register, but only for the OFF -> 
ON transition. Switching it from ON -> OFF doesn't invoke the action method. 
Should I be using one of the other events to capture both state transitions?

Thanks again!

___

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

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

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

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


Re: [iPhone] Toolbar button and "Touch Down"

2010-11-16 Thread Jonathon Kuo
On Nov 16, 2010, at 9:12 AM, Matt Neuburg wrote:

> On Mon, 15 Nov 2010 10:02:44 -0800, Jonathon Kuo 
>  said:
>> Interesting idea, probably a little beyond me. :) 
> 
> Nonsense. This is perfectly standard and easy. A UIButton can send an action 
> message on TouchDown. It makes no difference that the UIButton is inside a 
> UIBarButton. How much plainer can it be? m.

I agree: that's how I expected it to work, too, but that's not how it does work 
(Xcode 3.2.4). If I drag a Round Rect Button onto the Toolbar, it instantly 
gets promoted to a UIBarButtonItem (really!), and I can't set "Touch Down" on 
it, nor can I change the class of it in IB. That's why I'm confused...

___

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

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

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

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


Re: [iPhone] Toolbar button and "Touch Down"

2010-11-15 Thread Jonathon Kuo
Interesting idea, probably a little beyond me. :) I was hoping there might be a 
direct way of having the UIBarButtonItem respond immediately to a user's touch, 
instead of waiting until the user's finger is lifted.

On Nov 12, 2010, at 8:53 PM, Dave DeLong wrote:

> Random idea (untested, just spouting here)
> 
> What about initing a barButtonItem with a custom view (that view being a 
> UIButton that has the target/action set on the appropriate touch down inside 
> [the end zone! - sorry, couldn't resist]), and then setting the target/action 
> of the barButtonItem itself to nil?
> 
> In other words, let a different control handle the target/action instead of 
> the bar button item itself.
> 
> Dave
> 
> On Nov 12, 2010, at 11:57 AM, Jon Sigman wrote:
> 
>> I struggled this too, but without solution. It seems that toolbar 'buttons' 
>> aren't real buttons -- they're class UIBarButtonItem from UIBarItem from 
>> NSObject. Since they're not really buttons, there doesn't appear any way to 
>> modify their behavior. If there is a way, I'd like to know, too...
>> 
>> 
>> 
>> 
>> 
>> From: Jonathon Kuo 
>> To: Cocoa-Dev List 
>> Sent: Fri, November 12, 2010 10:02:15 AM
>> Subject: [iPhone] Toolbar button and "Touch Down"
>> 
>> I'm doing an iPhone 4.1 app and I have a toolbar at the bottom with bar 
>> buttons. 
>> The problem is that I need to set one of the bar buttons to "Touch Down" 
>> instead 
>> of the default "Touch Up Inside" but IB doesn't show any touch options for 
>> toolbar buttons (it does for buttons not in the toolbar).
>> 
>> Is there a programmatic way to set this?
>> Thx
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/rf_egr%40yahoo.com
>> 
>> This email sent to rf_...@yahoo.com
>> 
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
>> 
>> This email sent to davedel...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


[iPhone] Toolbar button and "Touch Down"

2010-11-12 Thread Jonathon Kuo
I'm doing an iPhone 4.1 app and I have a toolbar at the bottom with bar 
buttons. The problem is that I need to set one of the bar buttons to "Touch 
Down" instead of the default "Touch Up Inside" but IB doesn't show any touch 
options for toolbar buttons (it does for buttons not in the toolbar).

Is there a programmatic way to set this?
Thx

___

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

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

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

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


Re: Get wrong tag value from NSPopupButtonCell

2010-10-29 Thread Jonathon Kuo
What's the point of doing this:
>   NSPopUpButtonCell *testCell = [ [ [ NSPopUpButtonCell alloc] init] 
> autorelease];

if you're doing this 2 lines later:
>   testCell = [ olPopups selectedCell];


At this point, I would check for testCell being nil.
-Jon

On Oct 29, 2010, at 2:02 PM, Reinhard Segeler wrote:

> Hi,
>   Can't get the correct tag value in this way. What's wrong?
> 
>   NSPopUpButtonCell *testCell = [ [ [ NSPopUpButtonCell alloc] init] 
> autorelease];
> 
>   // olPopups is an Outlet to an NSMatrix
>   [ olPopups selectCellAtRow:0 column:0 ];
> 
>   testCell = [ olPopups selectedCell];
> 
>   [ testCell setTag:1000];
> 
>   testTag = [ testCell tag];
>   
> results always in tag == 0, even though the tag value is shown correctly in 
> the debugger.
> 
> Thanks
> 
> --  Reinhard
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/newslists%40autonomy.caltech.edu
> 
> This email sent to newsli...@autonomy.caltech.edu
> 

___

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

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

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

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


Re: NSImage is Caching

2010-10-05 Thread Jonathon Kuo
You're missing a [theImage release] at the end of your method.

On Oct 5, 2010, at 2:46 PM, Chris Tracewell wrote:

> I have an NSImageView that accepts an image drop then sizes the image and 
> ftp's it to a web server. The image view is bound to myObject.myImage 
> property which set by a window controller calling its loadMyImage every time 
> the window opens...
> 
> 
> -(void)loadMyImage
>   {
>   NSImage *theImage = [[NSImage alloc] initWithContentsOfURL: theURL];
>   [self setMyImage: theImage];
>   }
> 
> The problem is that the image is being cached and I cannot figure out how. I 
> can drop images galore and it ftp's them to their final destination --> which 
> is where the image is loaded from. However, the image will stay the same even 
> when I destroy myObject, create another one and it calls loadMyImage method 
> again. Even between application restarts. 
> 
> This must be a setting in NSURL or NSURLConnection or NSURLCache, anyone have 
> a clue as to where to start? FWIW - my web browser always shows the freshest 
> image.
> 
> Thanks in advance.
> 
> -- chris
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/newslists%40autonomy.caltech.edu
> 
> This email sent to newsli...@autonomy.caltech.edu
> 

___

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

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

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

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


Re: Is it possible to set UISlider intervals?

2010-08-10 Thread Jonathon Kuo

On Aug 10, 2010, at 5:43 PM, Devraj Mukherjee wrote:

> Hi all,
> 
> I am using UISliders in my iOS app.
> 
> I can't see a way of setting the slide value interval. Is this
> possible? Or do I have to calculate the change based on the 0.1
> increases?
> 
> Minimum value set to -20 and Max to 20 and I want the slider to
> increment by 0.5 on a slide.

UISliders do not 'increment' their value, they increase or decrease their value 
according to how they're touched. You can use these properties to set the 
slider limits:

slider.minimumValue = 0.0;
slider.maximumValue = 0.5;

This is also possible to set within Interface Builder.

___

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

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

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

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


Re: UIImageView and UIViewContentModeBottomLeft

2010-08-04 Thread Jonathon Kuo
On Aug 4, 2010, at 9:43 AM, David Duncan wrote:

>  A UIView (really the CALayer owned by the view) can and will display content 
> larger than its bounds if given to it.

Is there a way to restrict this behavior, i.e., to make it that the UIView does 
not display content beyond its bounds? I'm dealing with this very problem. The 
content "spills" over onto other things.


___

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

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

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

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


Re: Fast enumeration

2010-07-22 Thread Jonathon Kuo
On Jul 22, 2010, at 1:10 PM, Quincey Morris wrote:

> id _id;
> 
> for (_id in array) {
> }
> 
> if (_id)
> {
> }

If I use this to go backward through the array:

for (_id in [array reverseObjectEnumerator]) {  
}

...is it still considered 'fast' enumeration?

-Jon

___

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

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

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

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


Re: class_respondsToSelector() in runtime.h?

2010-07-01 Thread Jonathon Kuo

On Jul 1, 2010, at 9:49 AM, Kyle Sluder wrote:

> On Jul 1, 2010, at 9:42 AM, Jonathon Kuo  
> wrote:
> 
>> On Jul 1, 2010, at 7:56 AM, Matt Neuburg wrote:
>> 
>>> "Instance methods defined in a root class can be performed both by instances
>>> and by class objects. Therefore, all class objects have access to the
>>> instance methods defined in the root class."
>> 
>> Not that it would generally be USEFUL to do so, since the purpose of an 
>> instance is to hold instance variable values; a class object accessing 
>> instance variables through an instance method would come up with 
>> uninitialized ivar values, no?
> 
> They are instances of the root class, so they have all the root class 
> instances variables, of which there is precisely one: isa.

Interesting... so what happens at runtime if a class object invokes an instance 
method that accesses instance variables? Exception? Assertion? Seg fault?

___

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

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

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

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


Re: class_respondsToSelector() in runtime.h?

2010-07-01 Thread Jonathon Kuo
On Jul 1, 2010, at 7:56 AM, Matt Neuburg wrote:

> "Instance methods defined in a root class can be performed both by instances
> and by class objects. Therefore, all class objects have access to the
> instance methods defined in the root class."

Not that it would generally be USEFUL to do so, since the purpose of an 
instance is to hold instance variable values; a class object accessing instance 
variables through an instance method would come up with uninitialized ivar 
values, no?

___

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

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

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

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


Hit testing on NSTextField with custom cells

2010-03-18 Thread Jonathon Kuo
I've created a subclass of NSTextFieldCell that just adds the 
-hitTestForEvent:inRect:ofView: 
method. If I substitute my subclass in an NSTableView for the standard 
NSTextFieldCells, I do get this callback when a table element is clicked. 

But if I substitute my subclass in for an NSTextField's NSTextFieldCell, I 
never get the hit. How can I get this to 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Clicking on an NSColorWell

2010-03-17 Thread Jonathon Kuo
That's an awesome app. I've been looking at it, but it's a bit convoluted. I 
can't quite seem to isolate the basic mechanism at play here. It uses a 
NSTableView populated with a custom subclass of NSTextFieldCell that supports 
an image? I'm just looking to have a column of color swatches I can be notified 
when I click on them. Couldn't I do that with NSTextFields with 
setBackgroundColor:? The trick then is to get the on-click event.




On Mar 12, 2010, at 3:02 PM, Corbin Dunn wrote:

> Try the "AnimatedTableView" example. Feel free to post questions after you 
> run it. It has a custom mini color picker thingy.
> 
> corbin
> 
> On Mar 12, 2010, at 2:17 PM, Jonathon Kuo wrote:
> 
>> I need to generate an ad-hoc number of color swatches in a floating window 
>> so that when a user clicks on one of them, the 'active' color of a stylus 
>> will change to that color. Most likely NSColorWell is not the right tool for 
>> the job...
>> 
>> On Mar 12, 2010, at 2:10 PM, Kevin Wojniak wrote:
>> 
>>> Subclass and override mouseDown: - however if you're trying to intercept 
>>> right before the color panel is shown, or a drag starts, that may be 
>>> trickier.
>>> 
>>> What are you trying to do generally?
> 
> 

___

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

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

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

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


Re: Clicking on an NSColorWell

2010-03-12 Thread Jonathon Kuo
I need to generate an ad-hoc number of color swatches in a floating window so 
that when a user clicks on one of them, the 'active' color of a stylus will 
change to that color. Most likely NSColorWell is not the right tool for the 
job...

On Mar 12, 2010, at 2:10 PM, Kevin Wojniak wrote:

> Subclass and override mouseDown: - however if you're trying to intercept 
> right before the color panel is shown, or a drag starts, that may be trickier.
> 
> What are you trying to do generally?
> 
> 
> On Mar 12, 2010, at 1:30 PM, Jonathon Kuo wrote:
> 
>> How can I intercept or get notified when a user clicks on an NSColorWell? 
>> OSX 10.6.2
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/kainjow%40kainjow.com
>> 
>> This email sent to kain...@kainjow.com
> 
> 

___

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

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

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

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


Clicking on an NSColorWell

2010-03-12 Thread Jonathon Kuo
How can I intercept or get notified when a user clicks on an NSColorWell? 
OSX 10.6.2

___

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

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

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

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


Re: Cocoa-based GPS framework?

2010-02-12 Thread Jonathon Kuo
Googling around, I see Core Location usage in reference only to the  
iPhone... Is it only part of the iPhone SDK? Would there be a problem  
using it in building a MacBook application?

Jon

On Feb 12, 2010, at 9:11 AM, Steven Degutis wrote:

If you can support 10.6, I would recommend using Core Location,  
which is pretty solid from my understanding.


-Steven

On Fri, Feb 12, 2010 at 11:57 AM, Jonathon Kuo > wrote:
There used to be an open source Cocoa-based GPS framework for OSX  
called FourCoordinates, but I can't find it anywhere on the web  
anymore, just dead links. Is there something more modern that has  
replaced it?

___



___

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

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

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

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


Cocoa-based GPS framework?

2010-02-12 Thread Jonathon Kuo
There used to be an open source Cocoa-based GPS framework for OSX  
called FourCoordinates, but I can't find it anywhere on the web  
anymore, just dead links. Is there something more modern that has  
replaced it?

___

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

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

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

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


Re: Multiple variable rules in for() statement

2009-11-12 Thread Jonathon Kuo

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


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


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

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

So I tried this:

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

error: redefinition of ‘i’

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


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


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

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


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

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


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


Thanks!
Jon

___

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

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

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

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


Multiple variable rules in for() statement

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


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

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

So I tried this:

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

error: redefinition of ‘i’

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



___

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

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

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

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


Re: Coding with VM limitation on the iPhone?

2009-08-18 Thread Jonathon Kuo

On Aug 18, 2009, at 4:37 PM, Luke the Hiesterman wrote:

Your app will not be paged to the disk at all. It must run entirely  
on in physical memory. To know when you're running out of memory,  
override -[UIViewController didReceiveMemoryWarning]


On Aug 18, 2009, at 4:38 PM, Alex Kac wrote:

You typically only get about 5-40MB of available RAM. Its not flash.  
Its real RAM. But you have no guarantees. The iPhone has a robust  
memory system with low memory warnings and such and you just have to  
use those to determine if you have enough.


Hmm, that's kind of a harsh environment... The notification mechanism  
is great for the purpose of controlling bloat, but doesn't tell you  
how much VM you have to play with at the outset. I suppose all I can  
do is *try* to alloc() and if it fails, well, then what? It sounds  
like it's mostly out of my control if whatever else is running has  
already consumed VM. Gotta rethink this entire thing.


___

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

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

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

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


Coding with VM limitation on the iPhone?

2009-08-18 Thread Jonathon Kuo
I'm writing an app for the iPhone, but I need to be mindful how much  
virtual memory there is available to the app when it runs, so I can  
manage allocing and deallocing some large arrays. I'm guessing that  
the OS runs in a small amount (100MB?) of flash memory compared to the  
16GB or 32GB of general storage memory? Also, is there a system call I  
can invoke from within my app to determine how large it is getting?


___

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

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

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

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


Re: NSNotificationQueue & NSOperationQueue thread death

2009-05-06 Thread Jonathon Kuo

On May 6, 2009, at 9:03 AM, Michael Ash wrote:


It is correct that every thread conceptually has exactly one runloop.
I say "conceptually" because in fact they are created on demand.


So if a thread has no need to pay attention to asynchronous events  
(timers, input sources, etc) but is only in existence to run its own  
functional code (say, calculate a square root), it has no need to have  
a runloop running. It can simply execute in more or less linear  
fashion and exit.



A thread starts out with no runloop, but as soon something tries to
interact with that thread's runloop, one is created for it.



Here's where I don't quite follow. If my thread doesn't set up and  
explicitly run its runloop, won't async events just get ignored  
because the thread has no code to receive/process them?



___

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

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

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

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


Re: NSNotificationQueue & NSOperationQueue thread death

2009-05-06 Thread Jonathon Kuo
On May 4, 2009, at 8:12 PM, Ken Thomases wrote Re: 'A couple NSRunLoop  
questions':


Every thread has exactly one run loop associated with it.  You don't  
create run loops nor do you remove them.


On May 5, 2009, at 9:24 PM, Michael Ash wrote Re: 'NSNotificationQueue  
& NSOperationQueue thread death':


Background threads, whether directly managed by you or indirectly  
created by NSOperationQueue, do not use a runloop by default.


Sorry for my newb confusion. I know that these are different words  
from different authors, but I'm having trouble reconciling these two  
statements. How could a thread not have or use a runloop? Nothing on  
it would ever execute...?


___

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

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

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

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


Re: -hexValue for NSString?

2009-03-23 Thread Jonathon Kuo

Kewl, two excellent solutions! Cocoa is pretty versatile.

I have alot to learn yet but I don't quite have my head around why its  
more "Cocoaish" to invoke a class like NSScanner on an external object  
(Ali's approach) versus expecting the NSString object to be able to  
render its own contents in a format I'd like (Dave's approach)?


Thanks Ali and Dave!

On Mar 23, 2009, at 6:16 PM, Ali Ozer wrote:


NSScanner has

- (BOOL)scanHexInt:(unsigned *)value;		// Optionally prefixed with  
"0x" or "0X"

- (BOOL)scanHexLongLong:(unsigned long long *)result;

so you can

unsigned yourValueHere;
BOOL success = [[NSScanner scannerWithString:string]  
scanHexInt:&yourValueHere];


Ali

On Mar 23, 2009, at 6:00 PM, Jonathon Kuo wrote:

In NSString theres -intValue, -floatValue, -doubleValue, but no - 
hexValue (that I can find). I'd like to convert ascii hex NSStrings  
(@"001A4CD3" etc) into integer values. Having a -hexValue method  
would make that a snap. If theres no Cocoa way, I guess I could try  
my hand at writing a category(?) method on NSString using sscanf  
with %x.







___

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

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

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

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


-hexValue for NSString?

2009-03-23 Thread Jonathon Kuo
In NSString theres -intValue, -floatValue, -doubleValue, but no - 
hexValue (that I can find). I'd like to convert ascii hex NSStrings  
(@"001A4CD3" etc) into integer values. Having a -hexValue method would  
make that a snap. If theres no Cocoa way, I guess I could try my hand  
at writing a category(?) method on NSString using sscanf with %x.


___

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

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

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

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


Re: Announce the time every 30 minutes

2008-12-12 Thread Jonathon Kuo


On Dec 12, 2008, at 10:36 AM, has wrote:


Mr. Gecko wrote:


I'm trying to find out how to announce the time every 30 minutes,



You could run 'say `date`' as a cron job.


Interesting. The "speaker" translates "Fri Dec 12 17:52:58 PST 2008"  
into these spoken words:


"free december twelfth seventeen hours fifty two minutes fifty eight  
seconds pee ess tee two thousand and eight"


It gets everything correct except the day of the week abbreviation!


___

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

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

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

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


Re: - [NSBitmapImageRep tiffRepresentation] malloc error

2008-12-12 Thread Jonathon Kuo

On Dec 12, 2008, at 2:29 PM, Nick Zitzmann wrote:

In most 32-bit programs, even trying to allocate hundreds of  
megabytes of contiguous RAM at once often fails due to memory  
fragmentation.


Is there a function that allocates contiguous RAM? You mean VRAM,  
right? I thought anything you malloc'd is VRAM, and gets mapped any  
which way into real RAM by the OS, so contiguity of the real RAM is  
not an issue, only of process VRAM?


___

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

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

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

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


Re: D.O. [NSPortCoder sendBeforeTime:sendReplyPort:] timed out

2008-12-08 Thread Jonathon Kuo
No, we were never able to find a fix or workaround for this. We're  
operating now on the assumption that it's an unfixable design flaw in  
DO. This makes for a very fragile client/server implementation.


Jonathon

On Dec 6, 2008, at 1:31 AM, Bridger Maxwell wrote:


Hey,

Did you ever figure out what the problem is? It sounds like I am  
having the exact same problem. It has been driving me insane for a  
while now. I can't figure it out for the life of me.


Thank You,
Bridger Maxwell

On Thu, May 22, 2008 at 10:02 PM, R.L. Grigg <[EMAIL PROTECTED] 
> wrote:
I have a Cocoa DO server and a client that connects to it. When the  
client orderly exits with [server removeMessageClient:self] the  
client can reconnect and everything just works. But if the client  
crashes and then tries to reconnect to the server, the server  
somehow refuses the request:


2008-05-23 09:33:20.855 client[6621:10b] [NOTE: this exception  
originated in the server.]
[NSPortCoder sendBeforeTime:sendReplyPort:] timed out  
(10233202800.854183 233202800.854681) 1


Is there some exception the server can detect when a client crashes  
so it can drop/reset that connection? Or is there some way to do  
this from the client side when trying to reconnect? The only way I  
can "clear" it is to restart the server.


Russ
Xcode 3.0, OSX 10.5.2, Cocoa

___

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

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

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


This email sent to [EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSImageView antialiasing when scaling up images

2008-12-02 Thread Jonathon Kuo

Totally awesome!
Thank you!

On Dec 2, 2008, at 5:11 PM, Mike Abdullah wrote:

You'll want to subclass NSImageView and implement your own - 
drawRect: method. Call super's implementation, but beforehand, do  
something like:


[[NSGraphicsContext currentContext] set setImageInterpolation:  
NSImageInterpolationNone];


On 2 Dec 2008, at 23:45, Jonathon Kuo wrote:

I have some tiny images (4x3, etc) that I'm displaying in a large  
NSImageView. I set the view with setImageScaling:NSScaleToFit. This  
works, but instead of getting well-defined block 'pixels', I get  
sort of a 'shower-door' gradient effect within each pixel block.


 

How can I set the NSImageView to disable this effect?
OSX 10.5.5



___

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

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

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

This email sent to [EMAIL PROTECTED]


NSImageView antialiasing when scaling up images

2008-12-02 Thread Jonathon Kuo
I have some tiny images (4x3, etc) that I'm displaying in a large  
NSImageView. I set the view with setImageScaling:NSScaleToFit. This  
works, but instead of getting well-defined block 'pixels', I get sort  
of a 'shower-door' gradient effect within each pixel block.


<>
 <>


How can I set the NSImageView to disable this effect?
OSX 10.5.5

___

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

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

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

This email sent to [EMAIL PROTECTED]

Re: Wrapping C functions in Objective C proxy objects: naming convention?

2008-11-20 Thread Jonathon Kuo


On Nov 20, 2008, at 5:53 PM, Charles Srstka wrote:


On Nov 20, 2008, at 7:40 PM, Jonathon Kuo wrote:



On Nov 20, 2008, at 5:06 PM, Charles Srstka wrote:


On Nov 20, 2008, at 5:58 PM, Jonathon Kuo wrote:


On Nov 20, 2008, at 2:07 PM, Shawn Erickson wrote:


On Thu, Nov 20, 2008 at 1:23 PM, Jonathon Kuo
<[EMAIL PROTECTED]> wrote:

Just my 2 cents, but it seems an abuse to turn functions into  
objects.
Functions don't retain state; objects do. Objective C very  
gracefully allows

objects to call C functions. If you're doing something like [calc
addDoubleA:a withDoubleB:b], you've got a function masquerading  
as an

object, which I think misses the entire point of OOP.


It is common, if not appropriate, to have utility classes (often  
ones
with just class methods) that provide "functions" for others to  
use.

At a minimum it allows you to namespace sets of utility methods.


Exactly, as classes aren't objects.


Yes they are - in Objective-C, anyway.

Oops, my bad. Meant to say classes aren't instantiated objects (and  
thus they have no context or state, and so are appropriate for  
library-type functions, etc.)


Yep. Good thing the built-in Cocoa frameworks don't have any  
instantiated objects that contain library-type functions. Otherwise,  
we'd have all sorts of singleton objects with names like  
NSFileManager, NSWorkspace, NSUserDefaults, NSFontManager...


Well, to be fair, in each class you mention, you're accessing a  
special object: the default NSFileManager object for the file system,  
the shared NSWorkspace instance, etc. Those aren't examples of simple  
libraries in class clothing, which is all I was getting at.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Wrapping C functions in Objective C proxy objects: naming convention?

2008-11-20 Thread Jonathon Kuo


On Nov 20, 2008, at 5:06 PM, Charles Srstka wrote:


On Nov 20, 2008, at 5:58 PM, Jonathon Kuo wrote:


On Nov 20, 2008, at 2:07 PM, Shawn Erickson wrote:


On Thu, Nov 20, 2008 at 1:23 PM, Jonathon Kuo
<[EMAIL PROTECTED]> wrote:

Just my 2 cents, but it seems an abuse to turn functions into  
objects.
Functions don't retain state; objects do. Objective C very  
gracefully allows

objects to call C functions. If you're doing something like [calc
addDoubleA:a withDoubleB:b], you've got a function masquerading  
as an

object, which I think misses the entire point of OOP.


It is common, if not appropriate, to have utility classes (often  
ones

with just class methods) that provide "functions" for others to use.
At a minimum it allows you to namespace sets of utility methods.


Exactly, as classes aren't objects.


Yes they are - in Objective-C, anyway.

Oops, my bad. Meant to say classes aren't instantiated objects (and  
thus they have no context or state, and so are appropriate for library- 
type functions, etc.)




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Wrapping C functions in Objective C proxy objects: naming convention?

2008-11-20 Thread Jonathon Kuo

On Nov 20, 2008, at 2:07 PM, Shawn Erickson wrote:


On Thu, Nov 20, 2008 at 1:23 PM, Jonathon Kuo
<[EMAIL PROTECTED]> wrote:

Just my 2 cents, but it seems an abuse to turn functions into  
objects.
Functions don't retain state; objects do. Objective C very  
gracefully allows

objects to call C functions. If you're doing something like [calc
addDoubleA:a withDoubleB:b], you've got a function masquerading as an
object, which I think misses the entire point of OOP.


It is common, if not appropriate, to have utility classes (often ones
with just class methods) that provide "functions" for others to use.
At a minimum it allows you to namespace sets of utility methods.


Exactly, as classes aren't objects.
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Wrapping C functions in Objective C proxy objects: naming convention?

2008-11-20 Thread Jonathon Kuo

On Nov 19, 2008, at 9:27 PM, Austin Ziegler wrote:


For a project that I'm working on, I have a need to write a code
generator that will wrap certain kinds of C functions as Objective C
messages on an Objective C proxy. Because I don't ultimately control
the input, the parameters on the C functions may be poorly named. I'm
looking for advice on how one might make useful object message names
from C functions.


Just my 2 cents, but it seems an abuse to turn functions into objects.  
Functions don't retain state; objects do. Objective C very gracefully  
allows objects to call C functions. If you're doing something like  
[calc addDoubleA:a withDoubleB:b], you've got a function masquerading  
as an object, which I think misses the entire point of OOP.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Delete myDriver.kext files from normal user.

2008-10-17 Thread Jonathon Kuo


On Oct 17, 2008, at 5:33 PM, Michael Ash wrote:


On Fri, Oct 17, 2008 at 5:29 PM, Kyle Sluder
<[EMAIL PROTECTED]> wrote:

On Fri, Oct 17, 2008 at 5:17 PM, Jonathon Kuo
<[EMAIL PROTECTED]> wrote:

Just curious why the recommendation against system()?


1) There's no need for it here.  Why launch /bin/sh just to launch
/bin/rm, when you can call unlink(2) yourself?
2) In this case, system(3) will launch a shell *as root*.  It's  
almost

always preferable to avoid this.
3) Doing anything involving arguments is always a tricky subject,
because of Unicode.
4) Invoking shells (through use of system(3) in particular) is
typically a red flag.  It's usually indicative of a lack of knowledge
of the environment.


And most important of all (I think), it almost always opens a  
security hole.


This case is a great example. The system() call as posted uses "rm" as
the command. This in turn relies on the $PATH to hand over the correct
rm. It is probably feasible, maybe not even very hard, to ensure that
this person's application gets launched with a custom-crafted $PATH.
Make the first entry in $PATH be a special directory containing an
executable script called "rm" that spawns a root shell and makes it
listen on a certain TCP port and, bam, you've just been compromised.




Certainly there are a lot of ways to write security vulnerabilities.
But most of the time they happen because you make a mistake. System()
is insecure *by default*, and takes special effort and attention to
make it not be insecure. Much better is to simply not use it in the
first place, as no good can possibly come of it.


If the coder doesn't take care to use fully qualified pathnames like / 
bin/rm, etc., then it opens the door to security issues. That's not an  
inherent problem with system(), per se, but the coder. Wouldn't fork()/ 
exec() and NSTask also suffer from this same issue?



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Delete myDriver.kext files from normal user.

2008-10-17 Thread Jonathon Kuo

On Oct 17, 2008, at 1:21 PM, Kyle Sluder wrote:

On Fri, Oct 17, 2008 at 8:51 AM, Sachin Kumar <[EMAIL PROTECTED] 
> wrote:

I am using system("rm -r myDriver.kext") to delete the file.


Please, *don't do this*.  Pretend 'system' doesn't exist.  unlink(2)
does exactly what you're looking for.


Just curious why the recommendation against system()?


___

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

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

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

This email sent to [EMAIL PROTECTED]