Re: -[NSFileHandle readInBackgroundAndNotify] opens the file again

2012-08-01 Thread Rick Mann

On Jul 16, 2012, at 12:02 , Greg Parker  wrote:

> 
> On Jul 13, 2012, at 7:46 PM, Rick Mann  wrote:
> 
>> I'm using NSFileHandle in an ARC app on OS X Lion to read from a serial port.
>> 
>> Everything works fine 'till I go to close the port. I open the port with 
>> POSIX calls, set up some stuff, then instantiate an NSFileHandle with the 
>> file descriptor I got from open().
>> 
>> Then I call -readInBackgroundAndNotify, and a second file descriptor gets 
>> opened (I see this by using lsof).
>> 
>> That FD gets closed the moment some data comes in and a notification gets 
>> posted, but I just go right back and call -readInBackgroundAndNotify again 
>> to get the next data.
>> 
>> The problem is when I go to close the port. I still have a pending 
>> -readInBackgroundAndNotify, and so the port is opened twice. When I call 
>> -closeFile on the NSFileHandle, it closes the FD I initially opened, but 
>> leaves the second FD open.
>> 
>> I tried setting the NSFileHandle reference to nil so that ARC would release 
>> it, and hopefully call -dealloc on it, but either it's not doing that, or 
>> -dealloc doesn't close that second FD either.
>> 
>> In any case, when I go to open that port again, I get an error saying the 
>> resource is busy (if I quit my app, all FDs get closed).
>> 
>> This sure seems like a bug to me. Am I doing something wrong?
> 
> 
> NSFileHandle dups the file descriptor to avoid bugs where the descriptor is 
> closed from under it. That's expected.
> 
> NSFileHandle retains itself during the background operation to avoid being 
> deallocated while it's still in progress. I think the -closeFile call is 
> supposed to cancel the background operations which in turn should release 
> that extra retain, but perhaps something in there is not working correctly. 
> 
> What does the Allocations instrument say about the retain/release history? If 
> it looks like -readInBackgroundAndNotify is performing an extra retain that 
> doesn't get released then you should file a bug report.

I don't know how to use the Allocations instrument. I've filed a bug: 12004852. 
It contains my Xcode project.

-- 
Rick



___

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

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

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

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


Re: NSTask and NSPipe has buffering issues?

2012-08-01 Thread Mr. Gecko
Thank you!

That makes lots of sense and I was able to fix my code. I knew that I sometimes 
got zero length data, but never knew why. Now that I know it's the end of file… 
I can make lots of use of this knowledge.

Thanks for the help.

On Jul 31, 2012, at 11:20 PM, Ken Thomases  wrote:

> NSPipe itself doesn't require that a run loop be run, but the 
> "InBackgroundAndNotify" methods of the associated NSFileHandle objects do.
> 
> You receive a zero-length NSData when (and only when) a read encounters EOF.
> 
> There is an inherent race between the receipt of the task termination 
> notification and getting end-of-file on the output and error pipes.  This 
> race is not in Cocoa, it's in the kernel and the interprocess communication 
> mechanisms.  You can't rely on having received all of the data by the time 
> you are notified of the task termination.
> 
> You should separately track when NSTask has posted the termination 
> notification and when each pipe has gotten EOF.  Keep looping around the run 
> loop until *all three* things have happened.  (In other words, generalize 
> from your "running" variable.  You had the right idea but hadn't covered all 
> of the important parts.)
> 
> Regards,
> Ken
> 


___

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

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

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

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

Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Erik Stainsby
Hi Mark,

So I have a dictionary like so:  

NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United States",nil] 
forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];

I want to present them alphabetically as menuItems in an NSPopUpButton.  I grab 
the list of keys:

NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
allKeys]];

What I have come up with is this:

[sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [(NSString*)obj1 compare:(NSString*)obj2 ];
} ];

Is this a sane approach ? Seems a bit fussy to have to spec the cast like this. 
Or is this just the what-is of this kind of functionality?

~ Erik



On 2012-08-01, at 3:20 AM, Mark Woollard  wrote:

> Can you give a bit more info on what is stored in your NSArray? NSString? 
> NSManagedObject? NSDictionary? Something else?
> Regards
> Mark
> 
> On 1 Aug 2012, at 06:01, Erik Stainsby  wrote:
> 
>> The NSSortDescriptor documentation seems especially opaque to me tonight. 
>> Surely there is a useful short description somewhere … ?  *whimper*
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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/mark.woollard%40mac.com
>> 
>> This email sent to mark.wooll...@mac.com
> 


___

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

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

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

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

Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Michael Babin
On Aug 1, 2012, at 8:00 AM, Erik Stainsby  wrote:

> So I have a dictionary like so:  
> 
>   NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
> arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United 
> States",nil] forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];
> 
> I want to present them alphabetically as menuItems in an NSPopUpButton.  I 
> grab the list of keys:
> 
>   NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
> allKeys]];
> 
> What I have come up with is this:
> 
>   [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
>   return [(NSString*)obj1 compare:(NSString*)obj2 ];
>   } ];
> 
> Is this a sane approach ? Seems a bit fussy to have to spec the cast like 
> this. Or is this just the what-is of this kind of functionality?

If your comparison is only going to be a single method call with a single 
parameter like this, then probably a bit simpler to use:

[sortkeys sortUsingSelector:@selector(compare:)];



___

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

Please do not post 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Gerriet M. Denkmann

On 1 Aug 2012, at 21:38, Michael Babin  wrote:

> 
> On Aug 1, 2012, at 8:00 AM, Erik Stainsby  wrote:
> 
>> So I have a dictionary like so:  
>> 
>>  NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
>> arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United 
>> States",nil] forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];
>> 
>> I want to present them alphabetically as menuItems in an NSPopUpButton.  I 
>> grab the list of keys:
>> 
>>  NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
>> allKeys]];
>> 
>> What I have come up with is this:
>> 
>>  [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
>>  return [(NSString*)obj1 compare:(NSString*)obj2 ];
>>  } ];
>> 
>> Is this a sane approach ? Seems a bit fussy to have to spec the cast like 
>> this. Or is this just the what-is of this kind of functionality?
> 
> If your comparison is only going to be a single method call with a single 
> parameter like this, then probably a bit simpler to use:
> 
>   [sortkeys sortUsingSelector:@selector(compare:)];

The documentation says: "If you are comparing strings to present to the 
end-user, you should typically use localizedCompare: or 
localizedCaseInsensitiveCompare: instead."

Kind regards,

Gerriet.


___

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

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

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

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


Re: Repositioning another app's windows?

2012-08-01 Thread Rainer Brockerhoff

On Aug 1, 2012, at 11:38 , cocoa-dev-requ...@lists.apple.com wrote:
> Date: Wed, 01 Aug 2012 01:07:15 -0500
> From: Charles Srstka 
> Message-ID: 
> 
> On Jul 31, 2012, at 11:18 PM, Jerry Krinock  wrote:
> 
>> Neither way is 100% reliable.  Accessibility probably requires that "Enable 
>> Access for assistive devices" be on in System Preferences.  I don't see why 
>> we have that stupid checkbox.  At least, in 10.8 it's on by default in a new 
>> account.
> 
> My guess is that Apple probably considered it a security flaw to have 
> applications able to control applications' GUI elements by default.


Using the checkbox gives blanket permission for all processes, which is rather 
extreme.

A workaround for the "Enable Access" checkbox is to call AXMakeProcessTrusted() 
on your binary, which sets the setgid bit and uses a special "accessibility" 
group - needing a complex dance nowadays to ask for the admin password. (And, 
of course, making the app uneligible for the Mac App Store.) A similar 
reasoning applies to using event taps.

I have an open enhancement request (rdar:///9507141) to use entitlements for 
this, proposing, for instance:
> - com.apple.security.events.keyboard - allows the process to install keyboard 
> event taps
> - com.apple.security.events.mouse - allows the process to install mouse event 
> taps
> - com.apple.security.events.other - allows the process to install 
> other/special taps
> - com.apple.security.accessibility - allows the process to use accessibility 
> even if turned off in System Preferences.
> - This also opens up the possibility of the system alerting the user the 
> first time an application with these capabilities is run, or even downloaded.

Feel free to dupe or expand on this.
--
Rainer Brockerhoff  
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
In their own business even sages err."
Weblog: http://www.brockerhoff.net/blog


___

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

Please do not post 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Keary Suska
On Aug 1, 2012, at 7:00 AM, Erik Stainsby wrote:

> Hi Mark,
> 
> So I have a dictionary like so:  
> 
>   NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
> arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United 
> States",nil] forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];
> 
> I want to present them alphabetically as menuItems in an NSPopUpButton.  I 
> grab the list of keys:
> 
>   NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
> allKeys]];
> 
> What I have come up with is this:
> 
>   [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
>   return [(NSString*)obj1 compare:(NSString*)obj2 ];
>   } ];
> 
> Is this a sane approach ? Seems a bit fussy to have to spec the cast like 
> this. Or is this just the what-is of this kind of functionality?


Why not just use an NSDictionaryController and bind sortDescriptors?

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


___

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

Please do not post 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Alex Zavatone
I'm also working on this for the simple reason that it just appears that not 
having sorted dicts (in a straightforward way) is an offense to all that it 
holy and good.  Matt Galloway and others have already published methods for 
doing this, but sometimes, the learning is in the doing.

What I'm currently doing to populate a TVC from a dict is to reference the dict 
in the datastore first.  Ideally, I'd have accessors in the datastore to return 
the sections[sectionNum] and rows[rowNum].

Once I have that dict ref, this is what I'm doing:

NSDictionary *customerFilters = [DataStore findFiltersForCustomers: 
customers];

sectionArray = [[NSMutableArray alloc] init];
rowArray = [[NSMutableArray alloc] init];
for (id key in customerFilters) {
id myRowData = [customerFilters objectForKey:key];
[sectionArray addObject: key];
[rowArray addObject: myRowData];
NSLog(@"%@", key);
NSLog(@"%@", myRowData);
}

NSLog(@"%@",sectionArray );
NSLog(@"%@",rowArray );

IMHO, it's still a PITA and it would seem to make a boatload of sense to be 
able to grab keys and objects/values from dicts simply by using their index, 
without having to code up too much of a solution.





On Aug 1, 2012, at 10:38 AM, Michael Babin wrote:

> On Aug 1, 2012, at 8:00 AM, Erik Stainsby  wrote:
> 
>> So I have a dictionary like so:  
>> 
>>  NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
>> arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United 
>> States",nil] forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];
>> 
>> I want to present them alphabetically as menuItems in an NSPopUpButton.  I 
>> grab the list of keys:
>> 
>>  NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
>> allKeys]];
>> 
>> What I have come up with is this:
>> 
>>  [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
>>  return [(NSString*)obj1 compare:(NSString*)obj2 ];
>>  } ];
>> 
>> Is this a sane approach ? Seems a bit fussy to have to spec the cast like 
>> this. Or is this just the what-is of this kind of functionality?
> 
> If your comparison is only going to be a single method call with a single 
> parameter like this, then probably a bit simpler to use:
> 
>   [sortkeys sortUsingSelector:@selector(compare:)];
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

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

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

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


Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Alex Zavatone
I'm also working on this for the simple reason that it just appears that not 
having sorted dicts (in a straightforward way) is an offense to all that it 
holy and good.  Matt Galloway and others have already published methods for 
doing this, but sometimes, the learning is in the doing.

What I'm currently doing to populate a TVC from a dict is to reference the dict 
in the datastore first.  Ideally, I'd have accessors in the datastore to return 
the sections[sectionNum] and rows[rowNum].

Once I have that dict ref, this is what I'm doing:

   NSDictionary *customerFilters = [DataStore findFiltersForCustomers: 
customers];

   sectionArray = [[NSMutableArray alloc] init];
   rowArray = [[NSMutableArray alloc] init];
   for (id key in customerFilters) {
   id myRowData = [customerFilters objectForKey:key];
   [sectionArray addObject: key];
   [rowArray addObject: myRowData];
   NSLog(@"%@", key);
   NSLog(@"%@", myRowData);
   }

   NSLog(@"%@",sectionArray );
   NSLog(@"%@",rowArray );

IMHO, it's still a PITA and it would seem to make a boatload of sense to be 
able to grab keys and objects/values from dicts simply by using their index, 
without having to code up too much of a solution.





On Aug 1, 2012, at 10:38 AM, Michael Babin wrote:

> On Aug 1, 2012, at 8:00 AM, Erik Stainsby  wrote:
> 
>> So I have a dictionary like so:  
>> 
>>  NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
>> arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United 
>> States",nil] forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];
>> 
>> I want to present them alphabetically as menuItems in an NSPopUpButton.  I 
>> grab the list of keys:
>> 
>>  NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
>> allKeys]];
>> 
>> What I have come up with is this:
>> 
>>  [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
>>  return [(NSString*)obj1 compare:(NSString*)obj2 ];
>>  } ];
>> 
>> Is this a sane approach ? Seems a bit fussy to have to spec the cast like 
>> this. Or is this just the what-is of this kind of functionality?
> 
> If your comparison is only going to be a single method call with a single 
> parameter like this, then probably a bit simpler to use:
> 
>   [sortkeys sortUsingSelector:@selector(compare:)];
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/zav%40mac.com
> 
> This email sent to z...@mac.com

___

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

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

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

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


Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Alex Zavatone

On Aug 1, 2012, at 10:38 AM, Michael Babin wrote:

> On Aug 1, 2012, at 8:00 AM, Erik Stainsby  wrote:
> 
>> So I have a dictionary like so:  
>> 
>>  NSDictionary * countries = [NSDictionary dictionaryWithObjects:[NSArray 
>> arrayWithObjects:@"Australia",@"Canada",@"United Kingdom",@"United 
>> States",nil] forKeys:[NSArray arrayWithObjects:@"au",@"ca",@"uk",@"us",nil]];
>> 
>> I want to present them alphabetically as menuItems in an NSPopUpButton.  I 
>> grab the list of keys:
>> 
>>  NSMutableArray * sortkeys  = [NSMutableArray arrayWithArray:[countries 
>> allKeys]];
>> 
>> What I have come up with is this:
>> 
>>  [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
>>  return [(NSString*)obj1 compare:(NSString*)obj2 ];
>>  } ];
>> 
>> Is this a sane approach ? Seems a bit fussy to have to spec the cast like 
>> this. Or is this just the what-is of this kind of functionality?
> 
> If your comparison is only going to be a single method call with a single 
> parameter like this, then probably a bit simpler to use:
> 
>   [sortkeys sortUsingSelector:@selector(compare:)];

What's the reason for not using caseInsensitivecompare?


___

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

Please do not post 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Andy Lee
On Aug 1, 2012, at 12:08 PM, Alex Zavatone  wrote:
>> If your comparison is only going to be a single method call with a single 
>> parameter like this, then probably a bit simpler to use:
>> 
>>  [sortkeys sortUsingSelector:@selector(compare:)];
> 
> What's the reason for not using caseInsensitivecompare?

I'm guessing just an oversight.

Also, you can save a line of code with

NSArray *sortedkeys = [[countries allKeys] 
sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

If you need to do anything more than simple alphabetical sort it gets more 
verbose, but for sorting country names this should suffice.

I suspect this is one of those things for which lots of people have their own 
category methods on NSArray and/or NSString.

--Andy

___

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

Please do not post 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: -[NSFileHandle readInBackgroundAndNotify] opens the file again

2012-08-01 Thread Jens Alfke

On Aug 1, 2012, at 3:33 AM, Rick Mann  wrote:

> I don't know how to use the Allocations instrument. I've filed a bug: 
> 12004852. It contains my Xcode project.

The word "RTFM" comes to mind. Instruments isn't the most intuitive app in the 
world, but it does have documentation, and if you're smart enough to learn 
Cocoa programming you should be able to get the hang of it (I managed to.)

Filing bug reports without doing due diligence yourself first is wasting 
people's time (most likely the bug will get bounced back to you several months 
later with a comment saying "try using the Allocations instrument". D'ohhh.)

—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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Jens Alfke

On Aug 1, 2012, at 6:00 AM, Erik Stainsby  wrote:

> What I have come up with is this:
> 
>   [sortkeys sortUsingComparator:^NSComparisonResult(id obj1, id obj2) {
>   return [(NSString*)obj1 compare:(NSString*)obj2 ];
>   } ];
> 
> Is this a sane approach ? Seems a bit fussy to have to spec the cast like 
> this. Or is this just the what-is of this kind of functionality?

The "(NSString*)" casts are unnecessary, as "id" is type-compatible with any 
object-pointer type. You can also remove the "NSComparisonResult", as the 
compiler can infer the return type from the 'return' statement.

Alternatively you can change the parameter types to NSString*, which makes the 
block more type-safe:

[sortkeys sortUsingComparator:^(NSString* obj1, NSString* obj2) {
return [obj1 compare:obj2 ];
} ];

Or since your block just calls one method, you could just use:

[sortKeys sortUsingSelector: @selector(compare:)];

—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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Jens Alfke

On Aug 1, 2012, at 8:57 AM, Alex Zavatone  wrote:

>   sectionArray = [[NSMutableArray alloc] init];
>   rowArray = [[NSMutableArray alloc] init];
>   for (id key in customerFilters) {
>   id myRowData = [customerFilters objectForKey:key];
>   [sectionArray addObject: key];
>   [rowArray addObject: myRowData];
>   }

You can just use
sectionArray = [customerFilters allKeys];
rowArray = [customerFilters objectsForKeys: sectionArray] 
notFoundMarker: @""];

(There is an -allValues method, but the orderings is explicitly undefined, so 
it might not match the ordering of -allKeys.)

—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: -[NSFileHandle readInBackgroundAndNotify] opens the file again

2012-08-01 Thread Rick Mann

On Aug 1, 2012, at 9:37 , Jens Alfke  wrote:

> 
> On Aug 1, 2012, at 3:33 AM, Rick Mann  wrote:
> 
>> I don't know how to use the Allocations instrument. I've filed a bug: 
>> 12004852. It contains my Xcode project.
> 
> The word "RTFM" comes to mind. Instruments isn't the most intuitive app in 
> the world, but it does have documentation, and if you're smart enough to 
> learn Cocoa programming you should be able to get the hang of it (I managed 
> to.)

Thanks for that incredibly helpful suggestion.

I know how to run instruments. Show me the documentation that tells me how to 
actually do something with Allocations. If you look at my previous email on the 
subject, you can see that I ran Allocations way back when it was suggested, and 
found NO allocations of NSFileHandle.

I did a fair bit of work on this already. I don't have time do all of Apple's 
job for them. I've provided them with the code necessary to reproduce the 
problem, they're the ones that will have to fix it.

> Filing bug reports without doing due diligence yourself first is wasting 
> people's time (most likely the bug will get bounced back to you several 
> months later with a comment saying "try using the Allocations instrument". 
> D'ohhh.)

Then they will waste my time and theirs while I give them a similar explanation.

-- 
Rick


___

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

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

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

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


Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Alex Zavatone
Hmm.  The row accessor is doing something quite unexpected.  

Automatic Reference Counting Issue: Receiver type 'NSDictionary' for instance 
message does not declare a method with selector 'objectsForKeys:'

Since when does an NSDictionary on iOS 5.0 not declare a selector for 
objectForKeys:?

On Aug 1, 2012, at 12:45 PM, Jens Alfke wrote:

> 
>   rowArray = [customerFilters objectsForKeys: sectionArray] 
> notFoundMarker: @""];
> 
> (There is an -allValues method, but the orderings is explicitly undefined, so 
> it might not match the ordering of -allKeys.)
> 
> —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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Andy Lee
Never used it myself, but the method I see in the docs is called 
objectsForKeys:notFoundMarker:.

--Andy

On Aug 1, 2012, at 5:24 PM, Alex Zavatone  wrote:

> Hmm.  The row accessor is doing something quite unexpected.  
> 
> Automatic Reference Counting Issue: Receiver type 'NSDictionary' for instance 
> message does not declare a method with selector 'objectsForKeys:'
> 
> Since when does an NSDictionary on iOS 5.0 not declare a selector for 
> objectForKeys:?
> 
> On Aug 1, 2012, at 12:45 PM, Jens Alfke wrote:
> 
>> 
>>  rowArray = [customerFilters objectsForKeys: sectionArray] 
>> notFoundMarker: @""];
>> 
>> (There is an -allValues method, but the orderings is explicitly undefined, 
>> so it might not match the ordering of -allKeys.)
>> 
>> —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/aglee%40mac.com
> 
> This email sent to ag...@mac.com


___

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

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

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

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

Re: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Conrad Shultz

On Aug 1, 2012, at 2:24 PM, Alex Zavatone wrote:

> Hmm.  The row accessor is doing something quite unexpected.  
> 
> Automatic Reference Counting Issue: Receiver type 'NSDictionary' for instance 
> message does not declare a method with selector 'objectsForKeys:'
> 
> Since when does an NSDictionary on iOS 5.0 not declare a selector for 
> objectForKeys:?
> 

The selector is -objectsForKeys:notFoundMarker:, not to be confused with 
-objectForKey:.

(There was an errant square bracket in Jens' earlier message.)

-Conrad


___

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

Please do not post 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Alex Zavatone
Stupid extra brackets.  This works fine:

  NSArray *aRowArray = [customerFilters objectsForKeys: sectionArray 
notFoundMarker: @""] ;

On Aug 1, 2012, at 12:45 PM, Jens Alfke wrote:

> 
> On Aug 1, 2012, at 8:57 AM, Alex Zavatone  wrote:
> 
>>   sectionArray = [[NSMutableArray alloc] init];
>>   rowArray = [[NSMutableArray alloc] init];
>>   for (id key in customerFilters) {
>>   id myRowData = [customerFilters objectForKey:key];
>>   [sectionArray addObject: key];
>>   [rowArray addObject: myRowData];
>>   }
> 
> You can just use
>   sectionArray = [customerFilters allKeys];
>   rowArray = [customerFilters objectsForKeys: sectionArray] 
> notFoundMarker: @""];
> 
> (There is an -allValues method, but the orderings is explicitly undefined, so 
> it might not match the ordering of -allKeys.)
> 
> —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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Alex Zavatone
Stupid extra brackets.  This works fine:

  NSArray *aRowArray = [customerFilters objectsForKeys: sectionArray 
notFoundMarker: @""] ;

On Aug 1, 2012, at 12:45 PM, Jens Alfke wrote:

> 
> On Aug 1, 2012, at 8:57 AM, Alex Zavatone  wrote:
> 
>>   sectionArray = [[NSMutableArray alloc] init];
>>   rowArray = [[NSMutableArray alloc] init];
>>   for (id key in customerFilters) {
>>   id myRowData = [customerFilters objectForKey:key];
>>   [sectionArray addObject: key];
>>   [rowArray addObject: myRowData];
>>   }
> 
> You can just use
>   sectionArray = [customerFilters allKeys];
>   rowArray = [customerFilters objectsForKeys: sectionArray] 
> notFoundMarker: @""];
> 
> (There is an -allValues method, but the orderings is explicitly undefined, so 
> it might not match the ordering of -allKeys.)
> 
> —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: -[NSFileHandle readInBackgroundAndNotify] opens the file again

2012-08-01 Thread Rick Mann
On Aug 1, 2012, at 14:45 , Fritz Anderson  wrote:

> On 1 Aug 2012, at 3:58 PM, Rick Mann  wrote:
> 
>> I know how to run instruments. Show me the documentation that tells me how 
>> to actually do something with Allocations. If you look at my previous email 
>> on the subject, you can see that I ran Allocations way back when it was 
>> suggested, and found NO allocations of NSFileHandle.
> 
> My book has a couple of chapters on Instruments, including a lengthy example 
> of how to use the Allocations instrument.
> 
> I am reluctant to self-promote, but it's responsive to your search for 
> documentation.

No, please do. I appreciate it. I got a little farther by realizing I had to 
search for NSConcreteFileHandle (or just "filehandle"). But near as I can tell, 
it's still being deallocated, just leaving behind the file descriptor.

Instruments behaves inconsistently for me, and it's hard to understand why. I 
also can't find explanations for numerous things I see in the UI, things that 
don't make any sense (like percentages on lines of code that never execute).

-- 
Rick



___

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

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

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

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


Baffled by AVCaptureVideoPreviewLayer

2012-08-01 Thread lobs...@neu.edu
I'm having trouble  getting AVCaptureVideoPreviewLayer to work in OSX 10.8, 
XCode 4.4 . I'm trying to use the NSView mMovieView as the port. 

@property (nonatomic, strong) IBOutlet NSView   *mMovieView;
@property (nonatomic, strong) IBOutlet CALayer  *movieLayer;

movieLayer = [[self mMovieView] layer];
[movieLayer setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)];
AVCaptureVideoPreviewLayer *newPreviewLayer = 
[[AVCaptureVideoPreviewLayer alloc] initWithSession:[self captureSession]];
[newPreviewLayer setFrame:[movieLayer bounds]];
[movieLayer addSublayer:newPreviewLayer];

DLog(@"captureSession inputs are %@",captureSession.inputs);
DLog(@"captureSession outputs are %@",captureSession.outputs);

[captureSession startRunning];

DLog(@"AVCapture Session Started");

At the console, I see:
2012-08-01 17:32:53.919 Roboplasm[15629:303] -[MovieController setupAVCapture] 
captureSession inputs are (
"",
""
)
2012-08-01 17:32:53.920 Roboplasm[15629:303] -[MovieController setupAVCapture] 
captureSession outputs are (
)
2012-08-01 17:33:04.973 Roboplasm[15629:303] __37-[MovieController 
captureSessionInit]_block_invoke_085 did start running
2012-08-01 17:33:04.974 Roboplasm[15629:303] -[MovieController setupAVCapture] 
AVCapture Session Started

But no video preview. Any idea what's up.

Thanks,
Joseph Ayers
___

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

Please do not post 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: -[NSFileHandle readInBackgroundAndNotify] opens the file again

2012-08-01 Thread Fritz Anderson
On 1 Aug 2012, at 3:58 PM, Rick Mann  wrote:

> I know how to run instruments. Show me the documentation that tells me how to 
> actually do something with Allocations. If you look at my previous email on 
> the subject, you can see that I ran Allocations way back when it was 
> suggested, and found NO allocations of NSFileHandle.


My book has a couple of chapters on Instruments, including a lengthy example of 
how to use the Allocations instrument.

I am reluctant to self-promote, but it's responsive to your search for 
documentation.

— F

-- 
Fritz Anderson -- Xcode 4 Unleashed: Now in stores! -- 



___

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

Please do not post 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: Sorting NSArray -- advice on how to accomplish a "simple" alpha ordering?

2012-08-01 Thread Graham Cox

On 02/08/2012, at 1:53 AM, Alex Zavatone wrote:

> not having sorted dicts (in a straightforward way) is an offense to all that 
> it holy and good.


I disagree. Dictionaries by their nature are not "sorted" because they are 
random-access containers. Separating the responsibility for sorting into 
another class (NSMutableArray) is a good example of the correct separation of 
concerns. Besides, what does "sorted" mean? There's no single definition of 
sorted, that's why there are many ways to accomplish it, with case sensitive or 
not, different locales, and so on.

If you really want a sorted dictionary, for your own definition of "sorted", 
adding the feature via a category is no problem.

> it would seem to make a boatload of sense to be able to grab keys and 
> objects/values from dicts simply by using their index

Maybe you're just using the wrong container for the job. Dictionaries have no 
index, the very concept does not make sense for a dictionary. THAT IS THEIR 
POINT! If you want indexing, use an array. If you want some sort of hybrid, 
composite one in a class of your own device.




--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: Icon Overlay on Mac OSX

2012-08-01 Thread Alfian Busyro

Hi Gideon,
Thanks for your reply.

I tried this CTBadge, and it gave me a custom application icon after I 
run it.

So a little bit different with what I want to do though.
Do you have any idea how to implement this to the finder , without 
injecting it like dropbox did.


With Regards,

Alfian

On 12/07/18 14:45, Gideon King wrote:
You might like to check out CTBadge - there are a couple of minor 
memory issues in the current release which will be picked up in 
Xcode's analyze function, but apart from that, it will probably point 
you in the right direction.


http://blog.oofn.net/2006/01/08/badging-for-everyone/


Regards

Gideon


On 09/07/2012, at 3:34 PM, Alfian Busyro > wrote:



Hi,

I'm a newbie in Cocoa framework, XCode and also Obj-C.
I'm still struggling to create an icon overlay in finder like the one 
in that dropbox did.





___

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

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


UITableView Reorder View

2012-08-01 Thread Sarang Kapadia
Hello,
I am using a UITableView and need a way to:

1.   Stretch the reorder grip across the cells to allow the user to reorder 
cells by touching any point within the cell

2.   Hide and unhide the reorder grip based on the cell selection status

Currently we are accessing a private class by name, 
UITableViewCellReorderControl in order to achieve what we need.  Is this 
acceptable or can you provide us with an alternate solution?

Sarang
___

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

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

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

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


What is the equivalent Cocoa window level of Carbon kUtilityWindowClass?

2012-08-01 Thread Volker Schumacher
Hi,

I am working on a cocoa application that creates both normal cocoa windows and 
cocoa windows that are initialized with carbon windows. All windows should be 
floating above all applications. For the cocoa windows i set the window level 
to NSTornOffMenuWindowLevel, and for the carbon windows i use 
kUtilityWindowClass. Both works fine, windows are floating above other 
applications, but the problem is that carbon and cocoa windows don't have the 
same window level, so carbon windows will always float on top of cocoa windows. 
is there a way of giving both window types the same window level without 
loosing the floating above other apps? i guess since kUtilityWindowClass seems 
to the only window class which enables floating about other apps in carbon, i 
am looking for its equivalent in cocoa...

thanks, 
volker

___

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

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


Threading issue

2012-08-01 Thread Bruce Sherwood
I want to make a version of VPython (vpython.org) that is based on
Cocoa (the Mac version is currently based on Carbon).

The VPython API permits the following short user program, which
displays a 3D cube moving to the right, and you can rotate and zoom
the camera with the mouse:

from visual import box
b = box()
while True:
b.pos.x += 0.001

This works because a GUI environment is invoked by the visual module
in a secondary thread (written mainly in C++, connected to Python by
Boost). The OpenGL rendering of the box in its current position is
driven by a 30-millisecond timer. This works with any environment
other than Cocoa.

However, the Cocoa GUI environment and interact loop are required to
be in the primary thread, so the challenge is to have the visual
module set up the Cocoa environment, with the user's program running
in a secondary thread.

One of the things I've tried is to have the visual module read the
user's program, comment out the import statement, and start a
secondary thread in which I execute the (modified) user's code using
the Python exec statement. This has the problem that threads started
in Python modules apparently cannot execute import statements, so that
if there are additional import statements in the user's program (such
as importing math functions), the program halts. I've written code to
find all import statements in the user's program, execute them to add
their symbols to the global symbol table, and pass them as the
environment for the exec statement, but that's a pretty gross kludge.

Any suggestions?

Bruce Sherwood
___

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

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


IOI2CSendRequest problem

2012-08-01 Thread Vitaly Bondar

Hello,

  I hope that here is correct place to ask about IOKit.

  I have faced problem with IOI2CSendRequest function from 
"IOKit/i2c/IOI2CInterface.h"


Apple example for fetching EDID from display (using of oxA0 and oxA1 
addresses) works fine.
But when i'm trying to use 0x6e/0x6F addresses - can't receive response 
from display.
If i send write command to display, like set brightness, i see that it 
is applied on display. But when i send command for fetching something - 
it is not works.
The commands itself is correct because same things works in Windows 
realization.


Part of code and a little more info here:
http://stackoverflow.com/questions/11561623/i2c-communication-in-iokit-on-mac-os-x

Is there is any known issues in i2c communication with display?
Maybe request structure filled wrong?

Will be great to hear even guesses.

Thank you.

Best regards,
Vitaly Bondar
___

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

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


I2C communication to display (ddc/ci)

2012-08-01 Thread Vitaly Bondar

Hello,

I have faced problem with IOI2CSendRequest function from 
"IOKit/i2c/IOI2CInterface.h"
If this mailing list is wrong for asking this question, please direct me 
to correct place.


Apple example for fetching EDID from display (using of oxA0 and oxA1 
addresses) works fine.

(http://www.opensource.apple.com/source/IOGraphics/IOGraphics-409/tools/i2cexample.c)
But when i'm trying to use 0x6e/0x6F addresses - can't receive response 
from display.
If i send write command to display, like set brightness, i see that it 
is applied on display. But when i send command for fetching something - 
it is not works.
The commands itself is correct because same things works in Windows 
realization.


Part of code and a little more info here:
http://stackoverflow.com/questions/11561623/i2c-communication-in-iokit-on-mac-os-x

Is there is any known issues in i2c communication with display?
Maybe request structure filled wrong?

Will be great to hear even guesses.

Thank you.

Best regards,
Vitaly Bondar
___

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

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


I2C question - what is correct mailing list

2012-08-01 Thread Vitaly Bondar

Hello,

 This is question to cocoa-dev moderators. I had asked twice question 
about IOKit/i2c interface, but this messages was blocked as i understand.

Can you please help to find correct mailing list for my question.

Thank you.

___

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

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

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

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


Re: searching through all user accounts

2012-08-01 Thread Marcus Karlsson
On Sun, Jul 29, 2012 at 06:23:14PM +0800, Rick C. wrote:
> Hi,
> 
> I have a search app which normally searches through the current users home 
> directory using NSTask and find command.  If I wanted to make it search 
> through all user accounts could I ask some advice on what is the best way to 
> make it work?  Because I know permissions will be an issue.  Thanks,
> 
> rc

You can iterate through all users using getpwent() and run one task per
user. Find will just ignore any directories and files which it doesn't
have permission to read. If you want to go around that then you will
have to for example elevate to a user that have the appropriate access
rights or add ACL's that allows you to read.

Marcus
___

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

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


NSTask: auxiliary executable does not see its data file

2012-08-01 Thread Daniel Stein
[I posted this at discussions.apple.com, but realise that this is  
probably a more appropriate venue for a technical question]


I am writing a simple Cocoa-ObjectiveC wrapper around a command-line  
tool written in C, and understand the basics of using NSTask, NSPipe,  
NSFileHandle and multiple executable targets. My development platform  
is Xcode 3 / Leopard.



The Cocoa interface uses an NSTextView to display the stdout (and  
stderr, if necessary) of the CL tool, and to accept text directed to  
the tool's stdin. The message appearing in the text view on launching  
the app is that the data file is not found.



I use a Copy Files build phase in the Xcode project to put the  
auxiliary executable in the MacOS folder of the app bundle where the  
app's executable is. The data file is there, but the tool executable  
is not seeing it when it is being run by NSTask. The tool target has  
to load a read-only data file on launch or it fails. The tool target  
builds and executes OK in the Xcode console because it has its own  
Copy Files build phase to get a copy of the data file.



The tool tries to open the file with an ordinary call to fopen():


f = fopen("my.data",READ_MODE);


In windowDidLoad I've set the path for the auxiliary executable like  
this:



path = [[ NSBundle mainBundle ] pathForAuxiliaryExecutable:  
@"BackEnd" ];



backEnd = [[ NSTask alloc ] init ];

//[ backEnd setCurrentDirectoryPath: [ path  
stringByDeletingLastPathComponent ] ];


[ backEnd setLaunchPath: path ];


Of course, I'm concerned about having had to comment out the  
setCurrentDirectoryPath operation, which I inserted on the following  
advice:



http://cocoadev.com/wiki/UsingAuxiliaryExecutableInBundle


There is probably something somewhere in my auxiliary executable code  
that is not working with the environment it gets as an NSTask. I am  
puzzled that the standalone tool executable has no trouble the data  
file located in the same directory from which it launches, and runs  
fine in the Xcode console. In fact, when I drill into the app bundle  
and run the tool executable down there, it is fine, of course.



I probably have not sufficiently studied the source code for the  
auxiliary executable and the mechanics of how NSTask sets up the  
launch environment for the auxiliary. I was doing a lot of Cocoa  
programming a few years ago, when the OS was still 10.4, and I am  
trying to spin up to using 10.5 and 10.6 now, and a lot of things feel  
different. Any gentle advice will be greatly appreciated.

___

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

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

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

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


Re: Trying to capture raw touch events on the trackpad

2012-08-01 Thread Zongyao Qu
is mView an iboutlet member?
and where [mView setAcceptsTouchEvents:YES] get called? awakeFromNib or init?

Best Regards,
Zongyao QU


2012/7/27 Akhil Jindal :
> Hi all,
>
> I'm trying to capture raw touch events on the trackpad to define my own
> gesture events. I've gone through the documentation here:
> http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html
>
> I've set [mView setAcceptsTouchEvents:YES] and implemented the following
> functions:
>
>
> - (void)touchesBeganWithEvent:(NSEvent *)event;
>
> - (void)touchesMovedWithEvent:(NSEvent *)event;
>
>
> - (void)touchesEndedWithEvent:(NSEvent *)event;
>
> - (void)touchesCancelledWithEvent:(NSEvent *)event;
>
>
> but *I'm just not getting any calls in any of the above functions*. I keep
> getting calls in mouseMoved, mouseEntered, but not any touch messages.
>
> Am I missing something?
>
> Kindly help.
>
> Regards,
> Akhil Jindal
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post 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/zongyao.qu%40gmail.com
>
> This email sent to zongyao...@gmail.com
___

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

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

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

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


reading preferences from com.apple.mail under 10.8

2012-08-01 Thread Rob McBroom
Hello. I’m trying to read Mail’s preferences to find a suitable SMTP server so 
users don’t have to re-enter such configuration details. It seems to have 
stopped working and I can’t find a [documented] reason.

I’ve tried

NSUserDefaults *mailPrefs = [[NSUserDefaults alloc] init];
NSArray *smtpList = [[mailPrefs persistentDomainForName:@"com.apple.mail"] 
objectForKey:@"DeliveryAccounts"];

and

NSArray *mailPrefs = (__bridge NSArray 
*)CFPreferencesCopyValue((CFStringRef)@"DeliveryAccounts", 
(CFStringRef)@"com.apple.mail", kCFPreferencesCurrentUser, 
kCFPreferencesAnyHost);

but neither return any results on a 10.8 system. My application is not 
sandboxed. Mail is, but so is TextEdit and I have no problem reading its prefs.

Any ideas? Thanks.

-- 
Rob McBroom



___

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

Please do not post 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: Icon Overlay on Mac OSX

2012-08-01 Thread Charles Srstka
On Jul 18, 2012, at 4:42 AM, Alfian Busyro  wrote:

> Hi Gideon,
> Thanks for your reply.
> 
> I tried this CTBadge, and it gave me a custom application icon after I run it.
> So a little bit different with what I want to do though.
> Do you have any idea how to implement this to the finder , without injecting 
> it like dropbox did.
> 
> With Regards,
> 
> Alfian

Nope.

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: Threading issue

2012-08-01 Thread Jens Alfke

On Jul 20, 2012, at 12:04 PM, Bruce Sherwood  wrote:

> However, the Cocoa GUI environment and interact loop are required to
> be in the primary thread, so the challenge is to have the visual
> module set up the Cocoa environment, with the user's program running
> in a secondary thread.

This sounds like a Python embedding question ("how do I start and run the 
Python interpreter on a background thread?") not a Cocoa question. I don't know 
if there's anyone here with the necessary Python embedding expertise to answer 
it; you'd probably have better luck on a Python forum.

—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: NSTask: auxiliary executable does not see its data file

2012-08-01 Thread Jens Alfke

On Jul 30, 2012, at 8:08 AM, Daniel Stein  wrote:

> The tool tries to open the file with an ordinary call to fopen():
> f = fopen("my.data",READ_MODE);

Of course this assumes the current directory is the one containing the my.data 
file. By default it won't be, because the tool inherits the current directory 
from the app, and IIRC when an app is launched the CWD is set to the root 
directory of its bundle.

In general it's not a good idea to depend on the CWD in an app anyway. Why not 
pass the absolute path of the data file as a command-line argument to the tool 
from NSTask?

> //[ backEnd setCurrentDirectoryPath: [ path stringByDeletingLastPathComponent 
> ] ];
> 
> Of course, I'm concerned about having had to comment out the 
> setCurrentDirectoryPath operation

Um, yeah. But you haven't said why you commented it out. From what I remember 
about NSTask, that line would have set things up so your existing tool would 
work.

—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: reading preferences from com.apple.mail under 10.8

2012-08-01 Thread Jens Alfke

On Jul 31, 2012, at 8:07 AM, Rob McBroom  wrote:

> Hello. I’m trying to read Mail’s preferences to find a suitable SMTP server 
> so users don’t have to re-enter such configuration details. It seems to have 
> stopped working and I can’t find a [documented] reason.

Probably Mail changed where it stores that pref. It might be under a different 
key, or it might be stored in another domain entirely.

App defaults keys are not public, so you're relying on undocumented internal 
behavior of Mail, that could (and did!) change at any time.

A more supported way to get that info might be to query Mail's scripting 
interface using an AppleScript or the scripting bridge API.

—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: Icon Overlay on Mac OSX

2012-08-01 Thread Jens Alfke

On Jul 18, 2012, at 2:42 AM, Alfian Busyro  wrote:

> I tried this CTBadge, and it gave me a custom application icon after I run it.
> So a little bit different with what I want to do though.
> Do you have any idea how to implement this to the finder , without injecting 
> it like dropbox did.

Set custom icons for the files? (I have no idea how custom file icons are done 
nowadays, though. They used to be stored in the resource fork, but that's been 
deprecated for a decade now. Maybe they're in extended file attributes?)

—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: Icon Overlay on Mac OSX

2012-08-01 Thread Charles Srstka
On Aug 2, 2012, at 12:47 AM, Jens Alfke  wrote:

> On Jul 18, 2012, at 2:42 AM, Alfian Busyro  wrote:
> 
>> I tried this CTBadge, and it gave me a custom application icon after I run 
>> it.
>> So a little bit different with what I want to do though.
>> Do you have any idea how to implement this to the finder , without injecting 
>> it like dropbox did.
> 
> Set custom icons for the files? (I have no idea how custom file icons are 
> done nowadays, though. They used to be stored in the resource fork, but 
> that's been deprecated for a decade now. Maybe they're in extended file 
> attributes?)

They're still in the resource fork (which itself is an extended file attribute).

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