getting path for files in test bundle

2011-07-14 Thread Wilker
Hi,

I'm trying to do some tests here, but in case my tests have some fixture
files (video files), I added them to a group Fixtures on Test target, they
are also already on Copy Resources Bundle phase, but I can't get the path
for them... I'm trying with:

  NSString *dexterPath = [[NSBundle mainBundle] pathForResource:
@"dexter" ofType:@"mp4"];


But it always returns (null)

Any ideas on how to make it work?
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600
___

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

Please do not post 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: getting last accessed date

2011-07-14 Thread Rick C.
Hi again,

Ok I seem to be having never ending problems here unfortunately.  Using this 
code (below) I thought I could modify it for my needs.  But on the 
FSPathMakeRef line I keep getting the warning that "pointer targets in passing 
argument 1 of 'FSPathMakeRef' differ in signedness."  Would someone mind 
telling me why I'm getting this error?  Thanks you very much!


- (NSDate *)creationDate:(NSString *)path
{
FSRef ref;
FSCatalogInfo catalogInfo;
OSStatus status;
OSErr err;
NSTimeInterval seconds;
NSCalendarDate *epoch = [NSCalendarDate dateWithYear:1904 month:1
day:1 hour:0 minute:0 second:0 timeZone:[NSTimeZone
timeZoneForSecondsFromGMT:0]];

status = FSPathMakeRef([path fileSystemRepresentation], &ref, nil);
if (status != noErr) {
  NSLog(@"error making ref for %@: %d", path, status);
  return nil;
}

err = FSGetCatalogInfo(&ref, kFSCatInfoCreateDate, &catalogInfo,
NULL, NULL, NULL);
if (err != noErr) {
  NSLog(@"error getting catalog info: %d", err);
  return nil;
}

seconds = (double)((unsigned long
long)catalogInfo.createDate.highSeconds << 32) +
  (double)catalogInfo.createDate.lowSeconds +
  (double)catalogInfo.createDate.fraction / 0x;

return [epoch addTimeInterval:seconds];
}


On Jul 9, 2011, at 3:40 PM, Gary L. Wade wrote:

> Using Core Services or OS, you can call FSGetCatalogInfo. Also, I recall 
> things are different for stat under 64 bit, so you may want to make sure 
> you're doing the right thing.
> 
> - Gary L. Wade (Sent from my iPhone)
> 
> On Jul 8, 2011, at 8:37 PM, "Rick C."  wrote:
> 
>> Ok I have double-checked and the icon isn't actually the issue since I call 
>> iconForFile: after using stat.  With the original code I posted it just 
>> gives me today's date.  I can go into Finder and as an example I found a 
>> file that has a Last Opened date of 2009 and when I run stat it gives me 
>> today's date.  So it looks like stat is definitely not working...
>> 
>> Is there not an older Carbon method that was used for this before?  Is the 
>> only way by using spotlight metadata?
>> 
>> On a related note...I just updated one of my drives to Lion GM and on that 
>> drive I had a hard time to find a file with a different Last Opened date vs. 
>> Last Modified.  Makes me think the Last Opened date in Finder is coming from 
>> spotlight metadata could that be true?  If so then it looks like using the 
>> spotlight metadata and just falling back on the modification date might be 
>> the right way to go anyways???
>> 
>> 
>> On Jul 8, 2011, at 5:38 PM, Chris Ridd wrote:
>> 
>>> 
>>> On 8 Jul 2011, at 09:54, Rick C. wrote:
>>> 
 Sorry about that no I'm on Mac OS I was just sending the email from my 
 iPhone :-)
 
 Ok I double-checked and I think I am getting the same results as you are.  
 But iconForFile does not modify the Last Opened date that shows in Finder. 
  So the question is how do I get that besides using the spotlight metadata?
>>> 
>>> Does the resource fork (where the icon lives) have a different set of 
>>> timestamps from the data fork?
>>> 
>>> 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/garywade%40desisoftsystems.com
>> 
>> This email sent to garyw...@desisoftsystems.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: getting last accessed date

2011-07-14 Thread Matt Gough
> But on the FSPathMakeRef line I keep getting the warning that "pointer 
> targets in passing argument 1 of 'FSPathMakeRef' differ in signedness."  
> Would someone mind telling me why I'm getting this error?  Thanks you very 
> much!


Because FSPathMakeRef takes a UInt8* as its first parameter, while 
fileSystemRepresentation returns a char*.

status = FSPathMakeRef((UInt8*)[path fileSystemRepresentation], &ref, nil);

should stop the warning, but either way that wouldn't cause the code itself to 
behave any differently.

Matt

On 14 Jul 2011, at 11:22:39, Rick C. wrote:

> Hi again,
> 
> Ok I seem to be having never ending problems here unfortunately.  Using this 
> code (below) I thought I could modify it for my needs.  But on the 
> FSPathMakeRef line I keep getting the warning that "pointer targets in 
> passing argument 1 of 'FSPathMakeRef' differ in signedness."  Would someone 
> mind telling me why I'm getting this error?  Thanks you very much!
> 
> 
> - (NSDate *)creationDate:(NSString *)path
> {
> FSRef ref;
> FSCatalogInfo catalogInfo;
> OSStatus status;
> OSErr err;
> NSTimeInterval seconds;
> NSCalendarDate *epoch = [NSCalendarDate dateWithYear:1904 month:1
> day:1 hour:0 minute:0 second:0 timeZone:[NSTimeZone
> timeZoneForSecondsFromGMT:0]];
> 
> status = FSPathMakeRef([path fileSystemRepresentation], &ref, nil);
> if (status != noErr) {
>  NSLog(@"error making ref for %@: %d", path, status);
>  return nil;
> }
> 
> err = FSGetCatalogInfo(&ref, kFSCatInfoCreateDate, &catalogInfo,
> NULL, NULL, NULL);
> if (err != noErr) {
>  NSLog(@"error getting catalog info: %d", err);
>  return nil;
> }
> 
> seconds = (double)((unsigned long
> long)catalogInfo.createDate.highSeconds << 32) +
>  (double)catalogInfo.createDate.lowSeconds +
>  (double)catalogInfo.createDate.fraction / 0x;
> 
> return [epoch addTimeInterval:seconds];
> }
> 
> 
> On Jul 9, 2011, at 3:40 PM, Gary L. Wade wrote:
> 
>> Using Core Services or OS, you can call FSGetCatalogInfo. Also, I recall 
>> things are different for stat under 64 bit, so you may want to make sure 
>> you're doing the right thing.
>> 
>> - Gary L. Wade (Sent from my iPhone)
>> 
>> On Jul 8, 2011, at 8:37 PM, "Rick C."  wrote:
>> 
>>> Ok I have double-checked and the icon isn't actually the issue since I call 
>>> iconForFile: after using stat.  With the original code I posted it just 
>>> gives me today's date.  I can go into Finder and as an example I found a 
>>> file that has a Last Opened date of 2009 and when I run stat it gives me 
>>> today's date.  So it looks like stat is definitely not working...
>>> 
>>> Is there not an older Carbon method that was used for this before?  Is the 
>>> only way by using spotlight metadata?
>>> 
>>> On a related note...I just updated one of my drives to Lion GM and on that 
>>> drive I had a hard time to find a file with a different Last Opened date 
>>> vs. Last Modified.  Makes me think the Last Opened date in Finder is coming 
>>> from spotlight metadata could that be true?  If so then it looks like using 
>>> the spotlight metadata and just falling back on the modification date might 
>>> be the right way to go anyways???
>>> 
>>> 
>>> On Jul 8, 2011, at 5:38 PM, Chris Ridd wrote:
>>> 
 
 On 8 Jul 2011, at 09:54, Rick C. wrote:
 
> Sorry about that no I'm on Mac OS I was just sending the email from my 
> iPhone :-)
> 
> Ok I double-checked and I think I am getting the same results as you are. 
>  But iconForFile does not modify the Last Opened date that shows in 
> Finder.  So the question is how do I get that besides using the spotlight 
> metadata?
 
 Does the resource fork (where the icon lives) have a different set of 
 timestamps from the data fork?
 
 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/garywade%40desisoftsystems.com
>>> 
>>> This email sent to garyw...@desisoftsystems.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/devlists.mg%40googlemail.com
> 
> This email sent to devlists...@googlemail.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

Re: getting path for files in test bundle

2011-07-14 Thread Fritz Anderson
On 14 Jul 2011, at 2:11 AM, Wilker wrote:

> I'm trying to do some tests here, but in case my tests have some fixture
> files (video files), I added them to a group Fixtures on Test target, they
> are also already on Copy Resources Bundle phase, but I can't get the path
> for them... I'm trying with:
> 
>  NSString *dexterPath = [[NSBundle mainBundle] pathForResource:
> @"dexter" ofType:@"mp4"];

[NSBundle bundleForClass: [self class]]. The test suite runs in the context of 
the application under test, and is not in the main bundle.

Also, the group in which a file appears in the Project navigator has no 
influence over its role in the product; that's a matter for the build phases.

— F

___

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

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


perform a NSFecthRequest on Self

2011-07-14 Thread Gustavo Adolfo Pizano
Hello.

I have a MO A which has a to-many relationship to another MO B)).

I want to perform a fetch on A to look for its related B but on a
specific property o B.

I have tried getting all the toB set form A and filter the set using a
Predicate with the B's property, but this takes quite long.


any ideas?


Gustavo
___

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

Please do not post 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: iOS UI Design Question / Opinions wanted

2011-07-14 Thread John Tsombakos
On Thu, Jul 14, 2011 at 1:25 AM, Roland King  wrote:

> Custom button with your own graphic tick/cross is probably what I'd use for
> this. That's easy to do and fits pretty well with the ios look and feel.
> Either have two buttons  and use them as radio buttons (unselect one when
> you hit the other) or if perhaps try one button which switches states each
> time you hit it. If that had a graphic with a large tick and small cross for
> the "yes" state and the opposite for the "no" state it would be quite
> obvious that you need to hit it to toggle.
>
> Hm.. Yeah, that sounds like a good idea, that seems like it would work.

Thanks!
___

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

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

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

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


Re: iOS UI Design Question / Opinions wanted

2011-07-14 Thread Thomas Davie

On 14 Jul 2011, at 06:05, John Tsombakos wrote:

> Hi,
> 
> Just getting more into iOS development, and am deciding on what to do for an
> app. One app is a "competition scoring" application, where the judges would
> use the app to calculate and score a game. The scores would are derived from
> a series of "challenges", each worth a set number of points.
> 
> Each challenge score is determined by a Yes/No completion - Did XYZ happen?
> Did The other thing happen? etc. I was trying to figure out how to design
> the UI and while for a web version that we already have that uses radio
> buttons for each question, I'm not sure what would be best for an iOS app. I
> looked at the UISwitch, but it shows "On/Off" and that's not quite right. A
> segmented control could possibly work, with one for Yes and one for No. I
> thought a checkbox to signify "Yes" - but it doesn't look like iOS has
> checkboxes (how did I never notice that!).
> 
> I want to make it simple, so popping up a separate alert/window would incur
> an extra step.
> 
> So I'm soliciting opinions / suggestions.

Along with various other people, I have a custom UISwitch that does exactly 
what you require, it's available here http://whataboutapp.co.uk/

Tom Davie___

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

Please do not post 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: iOS UI Design Question / Opinions wanted

2011-07-14 Thread John Tsombakos
On Thu, Jul 14, 2011 at 8:14 AM, Thomas Davie  wrote:

>
> Along with various other people, I have a custom UISwitch that does exactly
> what you require, it's available here http://whataboutapp.co.uk/
>
> Tom Davie


That looks exactly what I would want! Thanks!
___

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

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

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

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


[MEET] CocoaHeadsNYC tonight. Jalkut. Raffle. Pizza.

2011-07-14 Thread Andy Lee
The New York City CocoaHeads is meeting tonight, July 14. Daniel Jalkut will 
give a talk entitled "Block, Don’t Run: An intro to Cocoa run loops":

NSRunLoop lives at the heart of every Cocoa application
for iOS or Mac OS X, yet many developers don’t have a
clear understanding for how it works. Daniel will give
a high level overview of the run loop and how it mediates
between the system’s resources and your application’s
unique functionality.

In addition, Ideaswarm is providing us with two licenses for their latest 
release of AppViz (normally $49) which we’ll raffle off using our usual 
undignified method.

As always, we’ll go to Patsy’s for pizza afterward.

More details on our new web site:



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

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


Question about NSThread

2011-07-14 Thread Eric E. Dolecki
I haven't done much research, but if I have a method that does a lot of
looping, can I just safely bust this off (fire and forget)?

[NSThread detachNewThreadSelector:@selector(generateBigData) toTarget:self
withObject:nil];
___

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

Please do not post 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: Question about NSThread

2011-07-14 Thread Jeff Kelley
You *can*, but there is a limit to the number of threads you can create, and
even if you’re under the limit, you’ll likely be pegging the CPU in an
inefficient way. You would be better served using GCD and creating a
dispatch queue, then scheduling the task on that queue (or just using a
global queue).

Jeff Kelley


On Thu, Jul 14, 2011 at 10:08 AM, Eric E. Dolecki wrote:

> I haven't done much research, but if I have a method that does a lot of
> looping, can I just safely bust this off (fire and forget)?
>
> [NSThread detachNewThreadSelector:@selector(generateBigData) toTarget:self
> withObject:nil];
>
___

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

Please do not post 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: Question about NSThread

2011-07-14 Thread Eric E. Dolecki
Thank you for your feedback, I appreciate it.

Eric

On Thu, Jul 14, 2011 at 10:38 AM, Jeff Kelley  wrote:

> You *can*, but there is a limit to the number of threads you can create,
> and
> even if you’re under the limit, you’ll likely be pegging the CPU in an
> inefficient way. You would be better served using GCD and creating a
> dispatch queue, then scheduling the task on that queue (or just using a
> global queue).
>
> Jeff Kelley
>
>
> On Thu, Jul 14, 2011 at 10:08 AM, Eric E. Dolecki  >wrote:
>
> > I haven't done much research, but if I have a method that does a lot of
> > looping, can I just safely bust this off (fire and forget)?
> >
> > [NSThread detachNewThreadSelector:@selector(generateBigData)
> toTarget:self
> > withObject:nil];
> >
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post 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/edolecki%40gmail.com
>
> This email sent to edole...@gmail.com
>
___

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

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

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

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


Re: Question about NSThread

2011-07-14 Thread Ken Thomases
On Jul 14, 2011, at 9:08 AM, Eric E. Dolecki wrote:

> I haven't done much research, but if I have a method that does a lot of
> looping, can I just safely bust this off (fire and forget)?
> 
> [NSThread detachNewThreadSelector:@selector(generateBigData) toTarget:self
> withObject:nil];

When it comes to threads, you can't ever "just safely" anything.  You have to 
work to make sure your code is thread-safe.  For example, your generateBigData 
method is being invoked on self.  Is it accessing any of self's ivars?  Is it 
accessing _any_ state that will be also be accessed from the main thread or any 
other thread?  If so, you have to ensure that such accesses are safe.

What happens if multiple threads try to set an ivar at the same time?  What 
happens if one is trying to read an ivar while the other is setting it?  Do you 
have ivars that are interrelated such that they have to be changed together to 
be consistent?  If so, then what happens if one thread attempts to read them 
while another has set one but hasn't gotten around to setting the other, yet?  
Etc.

Thread safety doesn't just happen.  You have to design it in and then carefully 
implement it.  There are tons of pitfalls, even for developers who are being 
deliberate and careful.

Good luck,
Ken

___

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

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

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

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


Re: Exposing NSTableView's usesAlternatingRowBackgroundColors in the user preferences

2011-07-14 Thread Kyle Sluder
On Tue, Jul 12, 2011 at 11:53 AM, Peter  wrote:
> I'd like to expose NSTableView's option usesAlternatingRowBackgroundColors as 
> a settable preference in my app's preferences window. "Easy, just use a 
> binding", I thought before I realized that NSTableView does not expose this 
> setting via bindings, neither using IB nor programatically.
>
> I found two solutions to this problem, both of them more or less 
> unsatisfactory. In my NSTableView's subclass +initialize method I register 
> the default value
>
> #define defaults [NSUserDefaults standardUserDefaults]
> NSDictionary *appDefaults = [NSDictionary 
> dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], 
> @"usesAlternatingRowBackgroundColors", nil];
> [defaults registerDefaults:appDefaults];
>
> whereas in -awakeFromNib I use the value stored in the user defaults
>
> #define defaultValues [[NSUserDefaultsController 
> sharedUserDefaultsController] values]
> [self setUsesAlternatingRowBackgroundColors:[[defaultValues 
> valueForKey:@"usesAlternatingRowBackgroundColors"] boolValue]];
>
> In my preferences panel I have bound the value key of a checkbox to the 
> shared user defaults controller.
> This is all pretty standard and it works so far.
>
> 1. Solution
> In my preferences panel's controller I have defined the following action 
> method for the check box
>
> - (IBAction)clickAlternatingRowsCheckbox:(id)sender{
>   NSInteger checkboxState = [sender state];
>   if (checkboxState == NSOffState) {
>      [myTableView setUsesAlternatingRowBackgroundColors:NO];
>   }
>   else if (checkboxState == NSOnState) {
>      [myTableView setUsesAlternatingRowBackgroundColors:YES];
>   }
> }
>
> This solution saves the setting to the user defaults via bindings, but works 
> only when the value is changed via the GUI and breaks MVC - the preferences 
> controller should better not be hooked up with a view used elsewhere in the 
> app. To avoid this, I deviced a
>
> 2. Solution
> I set the controller of my NSTableView's subclass as KVO observer of the key 
> in the sharedUserDefaultsController:
>
>   #define theDefaultsController [NSUserDefaultsController 
> sharedUserDefaultsController]
>   [theDefaultsController addObserver:self 
> forKeyPath:@"values.usesAlternatingRowBackgroundColors" options: 
> NSKeyValueObservingOptionNew context:NULL];
>
> The controller handles the observation like this
>
> - (void) observeValueForKeyPath: (NSString *) keyPath
>                       ofObject: (id) object
>                         change: (NSDictionary *) change
>                        context: (void *) context
> {
>   if ( [keyPath isEqualToString:@"values.usesAlternatingRowBackgroundColors"] 
> ) {
>      //NSLog(@"%@", [change objectForKey:NSKeyValueChangeNewKey]);
>      [self.myTableView 
> setUsesAlternatingRowBackgroundColors:[[theDefaultsController 
> valueForKeyPath:@"values.usesAlternatingRowBackgroundColors"] boolValue]];
>   }
> }
>
> The problem is, that since [change objectForKey:NSKeyValueChangeNewKey] 
> returns  in the log, I can't get the changed value from the change 
> dictionary, so I have to read it from the sharedUserDefaultsController - 
> which works, but seems pretty ridiculous. (Instead of checking the check 
> boxes state, I could have used the same approach in the 1. solution, too, 
> BTW.) Somehow, KVO seems to be unable to handle the boolean encoded as 
> NSNumber. Ideas on this anybody?


No, all of this seems pretty standard.

NSController subclasses do not support NSKeyValueChangeOldKey or
NSKeyValueChangeNewKey. This is a longstanding bug in NSController.
rdar://problem/3404770

The solution is to query the object directly for its new value.
Really, this is all that NSKeyValueChangeNewKey is doing for you. See
the comments on the various -will/didChangeValueForKey: variants in
NSKeyValueObserving.h for precisely what NSKeyValueChange{Old,New}Key
contains. NSKeyValueChangeOldKey is slightly more powerful, since it
gets sent at -didChangeValueForKey: time but contains information that
only existed at -willChangeValueForKey: time. But in many cases you
can mimic its functionality using NSKeyValueObservingOptionPrior. But
I bet that doesn't work with NSController either.

In any event, keep doing what you're doing, and file a bug at
http://bugreport.apple.com saying you encountered this problem and
asking that it be fixed.

--Kyle Sluder
___

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

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

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

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


Re: QTMovie/QTMovieLayer and SSL client athentication...

2011-07-14 Thread Glen Haderman
Sorry, I was misinterpreting what I was seeing in the apache log.

A client certificate is **not** being sent back to the server upon request from 
the server.

We can also see this by setting breakpoints on SSLHandshake and 
SSLSetCertificate.  SSLHandshake is getting called at the right times and 
SSLSetCertificate -- which in the case of the client would be used for setting 
the **client** certificate -- is never called.

We can see from the apache logs and from testing in a browser that the server 
is correctly asking the client for a client certificate.

We have tried creating a self-signed CA cert and using it to sign a newly 
created client cert.  We then put the client cert in the keychain for the 
logged in user (the test user who is launching the client app), logout/login, 
make adjustment to apache config, restart apache, and try launching the client 
again.  Same problem.  SSLSetCertificate is never called and the 2-way 
handshake fails when no client cert is provided.

Interestingly, the movie playback apis on iOS actually do this implicitly using 
a pre-installed apple client cert.

That's okay, but ideally we would like to be able to provide our own client 
certs.  Failing that, we'll settle for using a pre-installed apple cert if 
that's the only way it can be done.


-GH








- Original Message -
From: Glen Haderman 
To: "cocoa-dev@lists.apple.com" 
Cc: 
Sent: Tuesday, July 12, 2011 10:03 AM
Subject: QTMovie/QTMovieLayer and SSL client athentication...

We can see from the Apache logs that QTMovie does hand over a client 
certificate when the server asks for it during an SSL handshake.

But we cannot tell which certificate it is and which CA cert that we need to 
use on the server side (the CA cert that generated the client cert).

This is a little upside down.  Typically with certificate client 
authentication, the CA cert is in hand first and the client cert is generated 
from it and bundled with the client component.  In this case, QTMovie is hiding 
its internal client cert and the process by which it hands it back to the 
server upon request, and there's no documentation explaining how all of this is 
done and -- more importantly -- which CA cert was used to generate it.


Has anyone successfully done 2-way SSL authentication from a QTMovie before?

If so, what CA cert did you use on the server side?


edited snippet:

    // ourwebproxy.com is running Apache 2 on Mac OS X and has the 
following client authentication settings:
    // SSLCACertificateFile    
/private/etc/apache2/certs_and_keys/all_pre-installed_ca_certs_from_system_keychain_concatenated.pem
    // SSLVerifyClient         require
    // SSLVerifyDepth        10
    NSURL * url = [NSURL 
URLWithString:@"https://ourwebproxy.com/themovie.mp4";];
        
        
    
        NSDictionary * attributes = [NSDictionary 
dictionaryWithObjectsAndKeys:        url,
                                                                                
QTMovieURLAttribute,
                                                                                
                                                                                
[NSNumber numberWithBool:YES],
                                                                                
QTMovieOpenForPlaybackAttribute,
                                                                                
                                                                                
[NSNumber numberWithBool:YES],
                                                                                
QTMovieOpenAsyncOKAttribute,
                                                                                
                                                                                
nil];

        movie = [[Movie alloc] initWithAttributes:attributes error:nil];
        
        
    
    movielayer = [QTMovieLayer layerWithMovie:movie];



-GH
___

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

Please do not post 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/glenhaderman%40yahoo.com

This email sent to glenhader...@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/archive%40mail-archive.com

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


Core Data search optimizations

2011-07-14 Thread Indragie Karunaratne
Hi guys,

I'm working on a search feature in one of my Core Data based apps and I'm 
trying to gather everyone's tips on search optimization to get it as fast as I 
possibly can. The search needs to be fast enough that it can deliver 
near-instantaneous results for database of 20,000+ objects.

What I've done so far (as far as optimization goes)
- Implemented the technique shown in WWDC 2010 session 137, creating a keyword 
entity and creating a to-many relationship from my main object entities to it. 
The keyword entity's 'name' attribute is indexed, and keywords are created 
during the initial import procedure by splitting apart relevant strings in the 
main entities and normalizing them (stripped of case and diacritics)
- Using >= and < binary comparators instead of BEGINSWITH, etc. My predicate 
format is: SUBQUERY(keywords, $keyword, ($keyword.name >= $LB) AND 
($keyword.name < $UB)).@count != 0

Where $LB is the lower bounds string and $UB is upper bounds. I create a 
compound AND predicate using this format and the array of search terms.

Right now, I'm executing a fetch once (when the user types the first letter) 
using a fetch batch size of about 20, and then narrowing down the search 
results using NSArray's -filteredArrayUsingPredicate method as they continue 
typing. I also prefetch the "keywords" relationship because this is used to 
filter. The part that takes up the most time, obviously, is the initial fetch. 
There's a noticeable delay of ~1-2s on a library of around 15,000 objects. Time 
profiling shows that it is indeed the fetch that is causing the delay:

http://cl.ly/3a1b2022452M2V323f2H

One other thing thats worth noting is that I have to fetch multiple entities 
for the results. All of the entities have a "ranking" attribute, but I can't 
fetch more than one at once so I'm forced to fetch them separately, combine 
them into a single array, and then sort manually via 
-sortedArrayUsingDescriptors. 

Any tips on how to speed this up would 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: getting path for files in test bundle

2011-07-14 Thread Wilker
Thanks a lot Fritz :)
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600



On Thu, Jul 14, 2011 at 8:30 AM, Fritz Anderson wrote:

> On 14 Jul 2011, at 2:11 AM, Wilker wrote:
>
> > I'm trying to do some tests here, but in case my tests have some fixture
> > files (video files), I added them to a group Fixtures on Test target,
> they
> > are also already on Copy Resources Bundle phase, but I can't get the path
> > for them... I'm trying with:
> >
> >  NSString *dexterPath = [[NSBundle mainBundle] pathForResource:
> > @"dexter" ofType:@"mp4"];
>
> [NSBundle bundleForClass: [self class]]. The test suite runs in the context
> of the application under test, and is not in the main bundle.
>
> Also, the group in which a file appears in the Project navigator has no
> influence over its role in the product; that's a matter for the build
> phases.
>
>— F
>
>
___

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

Please do not post 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: Core Data search optimizations

2011-07-14 Thread Heath Borders
I would use CLucene for this. It isn't as easy to use as CoreData (it
is written in C++, so you'll need some Objective-C++ as a shim at a
minimum), but it is powerful and VERY fast.

-Heath
>From my iTouch4

On Jul 14, 2011, at 1:17 PM, Indragie Karunaratne  wrote:

> Hi guys,
>
> I'm working on a search feature in one of my Core Data based apps and I'm 
> trying to gather everyone's tips on search optimization to get it as fast as 
> I possibly can. The search needs to be fast enough that it can deliver 
> near-instantaneous results for database of 20,000+ objects.
>
> What I've done so far (as far as optimization goes)
> - Implemented the technique shown in WWDC 2010 session 137, creating a 
> keyword entity and creating a to-many relationship from my main object 
> entities to it. The keyword entity's 'name' attribute is indexed, and 
> keywords are created during the initial import procedure by splitting apart 
> relevant strings in the main entities and normalizing them (stripped of case 
> and diacritics)
> - Using >= and < binary comparators instead of BEGINSWITH, etc. My predicate 
> format is: SUBQUERY(keywords, $keyword, ($keyword.name >= $LB) AND 
> ($keyword.name < $UB)).@count != 0
>
> Where $LB is the lower bounds string and $UB is upper bounds. I create a 
> compound AND predicate using this format and the array of search terms.
>
> Right now, I'm executing a fetch once (when the user types the first letter) 
> using a fetch batch size of about 20, and then narrowing down the search 
> results using NSArray's -filteredArrayUsingPredicate method as they continue 
> typing. I also prefetch the "keywords" relationship because this is used to 
> filter. The part that takes up the most time, obviously, is the initial 
> fetch. There's a noticeable delay of ~1-2s on a library of around 15,000 
> objects. Time profiling shows that it is indeed the fetch that is causing the 
> delay:
>
> http://cl.ly/3a1b2022452M2V323f2H
>
> One other thing thats worth noting is that I have to fetch multiple entities 
> for the results. All of the entities have a "ranking" attribute, but I can't 
> fetch more than one at once so I'm forced to fetch them separately, combine 
> them into a single array, and then sort manually via 
> -sortedArrayUsingDescriptors.
>
> Any tips on how to speed this up would 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:
> http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com
>
> This email sent to heath.bord...@gmail.com
___

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

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

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

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


Re: Exposing NSTableView's usesAlternatingRowBackgroundColors in the user preferences

2011-07-14 Thread Peter
Thanks Kyle for the enlightenment! Very much appreciated.
So however awkward - I guess I have to live with this technique.

Am 14.07.2011 um 18:29 schrieb Kyle Sluder:

> On Tue, Jul 12, 2011 at 11:53 AM, Peter  wrote:
>> I'd like to expose NSTableView's option usesAlternatingRowBackgroundColors 
>> as a settable preference in my app's preferences window. "Easy, just use a 
>> binding", I thought before I realized that NSTableView does not expose this 
>> setting via bindings, neither using IB nor programatically.
>> 
>> I found two solutions to this problem, both of them more or less 
>> unsatisfactory. In my NSTableView's subclass +initialize method I register 
>> the default value
>> 
>> #define defaults [NSUserDefaults standardUserDefaults]
>> NSDictionary *appDefaults = [NSDictionary 
>> dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], 
>> @"usesAlternatingRowBackgroundColors", nil];
>> [defaults registerDefaults:appDefaults];
>> 
>> whereas in -awakeFromNib I use the value stored in the user defaults
>> 
>> #define defaultValues [[NSUserDefaultsController 
>> sharedUserDefaultsController] values]
>> [self setUsesAlternatingRowBackgroundColors:[[defaultValues 
>> valueForKey:@"usesAlternatingRowBackgroundColors"] boolValue]];
>> 
>> In my preferences panel I have bound the value key of a checkbox to the 
>> shared user defaults controller.
>> This is all pretty standard and it works so far.
>> 
>> 1. Solution
>> In my preferences panel's controller I have defined the following action 
>> method for the check box
>> 
>> - (IBAction)clickAlternatingRowsCheckbox:(id)sender{
>>  NSInteger checkboxState = [sender state];
>>  if (checkboxState == NSOffState) {
>> [myTableView setUsesAlternatingRowBackgroundColors:NO];
>>  }
>>  else if (checkboxState == NSOnState) {
>> [myTableView setUsesAlternatingRowBackgroundColors:YES];
>>  }
>> }
>> 
>> This solution saves the setting to the user defaults via bindings, but works 
>> only when the value is changed via the GUI and breaks MVC - the preferences 
>> controller should better not be hooked up with a view used elsewhere in the 
>> app. To avoid this, I deviced a
>> 
>> 2. Solution
>> I set the controller of my NSTableView's subclass as KVO observer of the key 
>> in the sharedUserDefaultsController:
>> 
>>  #define theDefaultsController [NSUserDefaultsController 
>> sharedUserDefaultsController]
>>  [theDefaultsController addObserver:self 
>> forKeyPath:@"values.usesAlternatingRowBackgroundColors" options: 
>> NSKeyValueObservingOptionNew context:NULL];
>> 
>> The controller handles the observation like this
>> 
>> - (void) observeValueForKeyPath: (NSString *) keyPath
>>  ofObject: (id) object
>>change: (NSDictionary *) change
>>   context: (void *) context
>> {
>>  if ( [keyPath isEqualToString:@"values.usesAlternatingRowBackgroundColors"] 
>> ) {
>> //NSLog(@"%@", [change objectForKey:NSKeyValueChangeNewKey]);
>> [self.myTableView 
>> setUsesAlternatingRowBackgroundColors:[[theDefaultsController 
>> valueForKeyPath:@"values.usesAlternatingRowBackgroundColors"] boolValue]];
>>  }
>> }
>> 
>> The problem is, that since [change objectForKey:NSKeyValueChangeNewKey] 
>> returns  in the log, I can't get the changed value from the change 
>> dictionary, so I have to read it from the sharedUserDefaultsController - 
>> which works, but seems pretty ridiculous. (Instead of checking the check 
>> boxes state, I could have used the same approach in the 1. solution, too, 
>> BTW.) Somehow, KVO seems to be unable to handle the boolean encoded as 
>> NSNumber. Ideas on this anybody?
> 
> 
> No, all of this seems pretty standard.
> 
> NSController subclasses do not support NSKeyValueChangeOldKey or
> NSKeyValueChangeNewKey. This is a longstanding bug in NSController.
> rdar://problem/3404770
> 
> The solution is to query the object directly for its new value.
> Really, this is all that NSKeyValueChangeNewKey is doing for you. See
> the comments on the various -will/didChangeValueForKey: variants in
> NSKeyValueObserving.h for precisely what NSKeyValueChange{Old,New}Key
> contains. NSKeyValueChangeOldKey is slightly more powerful, since it
> gets sent at -didChangeValueForKey: time but contains information that
> only existed at -willChangeValueForKey: time. But in many cases you
> can mimic its functionality using NSKeyValueObservingOptionPrior. But
> I bet that doesn't work with NSController either.
> 
> In any event, keep doing what you're doing, and file a bug at
> http://bugreport.apple.com saying you encountered this problem and
> asking that it be fixed.
> 
> --Kyle Sluder
> 



___

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

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

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

model key path and properties

2011-07-14 Thread Torsten Curdt
Xcode4.0.2 on 10.6.8:

I have a NSArrayController and I add items to that controller. In the
nib I have bound a NSPopUpButton's "Content" to that
NSArrayController's arrangedObjects. Now with an empty model key path
I see the object's description in the popup. All good and expected.
Now these items the NSArrayController manages have a "name" property.
Accessing the name like this works just fine:

NSLog(@"name: %@", [[[self.myArrayController arrangedObjects]
objectAtIndex:0] name]);

Now I would think I just need to change the model key path of the
"Content" binding to be "name" but IB gives me the exclamation mark
and says "no completion found".

I am confused. Shouldn't this just work like that? ...or what did I miss?

cheers,
Torsten
___

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

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

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

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


Re: Core Data search optimizations

2011-07-14 Thread Indragie Karunaratne
Thanks for the replies. However, my app is already built on top of Core Data so 
switching to another framework isn't really an option. 

On 2011-07-14, at 2:58 PM, Ruslan Zasukhin wrote:

> On 7/14/11 9:15 PM, "Indragie Karunaratne"  wrote:
> 
> Hi Indragie,
> 
> You  may want to consider just to use other db engine.
> 
> For example, our Valentina db engine can be 100+ times faster of normal RDB
> engines...
> 
> If you have interest I can give you more details.
> 
>> Hi guys,
>> 
>> I'm working on a search feature in one of my Core Data based apps and I'm
>> trying to gather everyone's tips on search optimization to get it as fast as 
>> I
>> possibly can. The search needs to be fast enough that it can deliver
>> near-instantaneous results for database of 20,000+ objects.
>> 
>> What I've done so far (as far as optimization goes)
>> - Implemented the technique shown in WWDC 2010 session 137, creating a 
>> keyword
>> entity and creating a to-many relationship from my main object entities to 
>> it.
>> The keyword entity's 'name' attribute is indexed, and keywords are created
>> during the initial import procedure by splitting apart relevant strings in 
>> the
>> main entities and normalizing them (stripped of case and diacritics)
>> - Using >= and < binary comparators instead of BEGINSWITH, etc. My predicate
>> format is: SUBQUERY(keywords, $keyword, ($keyword.name >= $LB) AND
>> ($keyword.name < $UB)).@count != 0
>> 
>> Where $LB is the lower bounds string and $UB is upper bounds. I create a
>> compound AND predicate using this format and the array of search terms.
>> 
>> Right now, I'm executing a fetch once (when the user types the first letter)
>> using a fetch batch size of about 20, and then narrowing down the search
>> results using NSArray's -filteredArrayUsingPredicate method as they continue
>> typing. I also prefetch the "keywords" relationship because this is used to
>> filter. The part that takes up the most time, obviously, is the initial 
>> fetch.
>> There's a noticeable delay of ~1-2s on a library of around 15,000 objects.
>> Time profiling shows that it is indeed the fetch that is causing the delay:
>> 
>> http://cl.ly/3a1b2022452M2V323f2H
>> 
>> One other thing thats worth noting is that I have to fetch multiple entities
>> for the results. All of the entities have a "ranking" attribute, but I can't
>> fetch more than one at once so I'm forced to fetch them separately, combine
>> them into a single array, and then sort manually via
>> -sortedArrayUsingDescriptors.
>> 
>> Any tips on how to speed this up would 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/ruslan_zasukhin%40valentina-d
>> b.com
>> 
>> This email sent to ruslan_zasuk...@valentina-db.com
>> 
> 
> -- 
> Best regards,
> 
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc
> 
> Valentina - Joining Worlds of Information
> http://www.paradigmasoft.com
> 
> [I feel the need: the need for speed]
> 
> 

___

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

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


Control and default colors?

2011-07-14 Thread Jeffrey Walton
Hi ALl,

Is it possible to query a control (such as a background or button) for
its default color? Under interface builder, there appears to be a
default color recognized. Is this specific to IB?

I'm more interested in assigning the default color at runtime (if the
user previously changed it), but there does not seem to be a [UIColor
defaultColor] or UIDefaultColor. The idea is similar to:

self.view.backgroundColor = [UIView defaultColor];

Jeff
___

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

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

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

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


A better solution? - Accessing an array of strings saved to user defaults via bindings (solved in the end...)

2011-07-14 Thread Peter
I have found various references on this list and on the web about the 
impossibility to hook up an *editable* single-column NSTableView to an 
NSMutableArray of strings via bindings - and about some clever ways to work 
around this limitation. These workarounds may work in principle, but fail in a 
NSUserDefaultsController-NSArrayController-NSTableView setup.

I tried to be exceedingly clever using the following category (as proposed by 
Joanna Carter http://carterconsulting.org.uk/forums/viewtopic.php?f=3&t=14):

@interface NSMutableString (KVCHelper) 
@property (copy) NSString *string;
@end

@implementation NSMutableString (KVCHelper)
@dynamic string;
- (NSString *) string{
   return self;
} 
@end

alongside with various NSValueTransformers converting strings or arrays to 
their mutable variants, as well as converting the array to a mutable dictionary 
and back using this one

#import "ArrayOfStringsToArrayOfMutableDictionariesVT.h"
#define kStringKey @"stringKey"

@implementation ArrayOfStringsToArrayOfMutableDictionariesVT
+ (Class) transformedValueClass
{
return [NSMutableArray class];
}

+ (BOOL) allowsReverseTransformation
{
return YES;
}

- (id) transformedValue:(id)array
{
   NSMutableArray *myMutableArray = [[NSMutableArray alloc] 
initWithCapacity:[array count]];
   for (NSString *myString in array) {
  [myMutableArray addObject:[NSMutableDictionary 
dictionaryWithObject:myString forKey:kStringKey]];
   }
   return [myMutableArray autorelease];
}

- (id) reverseTransformedValue:(id)array
{
   NSMutableArray *myMutableArray = [[NSMutableArray alloc] 
initWithCapacity:[array count]];
   for (NSDictionary *myDictionary in array) {
  [myMutableArray addObject:[myDictionary objectForKey:kStringKey]];
   }
   return [myMutableArray autorelease];
}
@end

All to no avail, they work but don't help. The dead end is always 
NSUserDefaults, or more precisely its controller. It's such a pain that you can 
save an NSArray in user defaults but then nevertheless be unable to access it 
using bindings.

So my question is:

How could I possibly wrap an NSArray in the user defaults in a way that I can 
conveniently access it via bindings to populate an editable NSTableView? Is 
there a way to wrap an NSArray into some kind of opaque data object, so that 
the array controller is prevented from accessing single items in the array, but 
instead receives it from and hands it over to the user defaults controller in a 
single item lump?

My point is: I'd like to abandon saving an NSArray in the user defaults if I 
can use something similarly ordered and access it via bindings instead. I know 
I could create a wrapper class for each string element in the array, but I 
wonder if there isn't an easier solution choosing a different container object.

There is still a rumor about the NSUserDefaultsController yielding immutable 
objects and this being one source for this problem. That's untrue. It seems to 
have changed with OS 10.4. I can write data from a table view to the 
applications preferences plist, but the data type is wrong - the string "test" 
(set via the table view in the GUI) is wrapped into a dictionary on write, 
whereas the rest (set programmatically on initialization) are simple strings:

{
fruitsList = (
{
abc = test;
},
Orange,
Strawberry,
Raspberry,
Whatnot
);
}
 
OK - this was the pointer to myself - silly...

I converted my original array of strings (= myArray) to a mutable array of 
mutable dictionaries, each containing a single string under some arbitrary key 
(which has to be kept constant for all these dictionaries, of course). So my 
+initialize method looks as follows:

   NSArray *myArray = [NSMutableArray arrayWithObjects:@"Apple", @"Orange", 
@"Strawberry", @"Raspberry", @"Whatnot", nil];
   NSMutableArray *myMutableArray = [[NSMutableArray alloc] 
initWithCapacity:[myArray count]];
   for (NSString *myString in myArray) {
  [myMutableArray addObject:[NSMutableDictionary 
dictionaryWithObject:myString forKey:@"abc"]];
   }
   
   NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
myMutableArray,
@"fruitsList", 
nil];
   
   [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];

And my application prefs plist looks like this:
{
fruitsList = (
{
abc = Apple;
},
{
abc = Orange;
},
{
abc = Strawberry;
},
{
abc = Raspberry;
},
{
abc = Whatnot;
}
);
}

Setting the model key path for the table column to abc (while checking Handles 
Content as Compound Value) makes it possible to access and edit all these 
strings via bindings.

Is there a more elegant/efficient solution than l

Key-value coding dynamically-created arrays in NSTableView

2011-07-14 Thread John Bartleson
Many of us are familiar with the use of key-value coding in  
NSTableView and NSOutlineView data-source methods.


For example (from Key-Value Coding Programming Guide):
- (id)   tableView:(NSTableView *)tableview
 objectValueForTableColumn:(id)column
  row:(int)row
{
ChildObject *child = [childrenArray objectAtIndex:row];
return [child valueForKey:[column identifier]];
}
Here the column identifier specified in the nib is used to select  
which ChildObject accessor

to use as the source for the column's data.

But suppose the columns of the tableView are not defined in the nib.  
Instead, they are defined
dynamically by user action at run time. It's easy to dynamically add  
columns to the tableView and to
give each one a unique identifier , but is it even possible to somehow  
assign key names to elements

in a dynamic data array so valueForKey: can find those elements?

This issue is made more difficult because the technique valueForKey  
uses to select an accessor is not
apparent, at least to a n00b like me. For extra points, can anyone  
describe how valueForKey works?


(I'm not using bindings)

___

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

Please do not post 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: model key path and properties

2011-07-14 Thread Quincey Morris
On Jul 14, 2011, at 15:29, Torsten Curdt wrote:

> I have a NSArrayController and I add items to that controller. In the
> nib I have bound a NSPopUpButton's "Content" to that
> NSArrayController's arrangedObjects. Now with an empty model key path
> I see the object's description in the popup. All good and expected.
> Now these items the NSArrayController manages have a "name" property.
> Accessing the name like this works just fine:
> 
>NSLog(@"name: %@", [[[self.myArrayController arrangedObjects]
> objectAtIndex:0] name]);
> 
> Now I would think I just need to change the model key path of the
> "Content" binding to be "name" but IB gives me the exclamation mark
> and says "no completion found".

The popup button's Content binding is an *entire* array. Arrays don't have a 
"name" property. IOW, "arrangedObjects.name" is not a valid key path.

Now, it's certainly true that NSArray responds to the KVC method 
'valueForKey:@"name"', and it should produce an array of names, but since 
NSArrayController is something of a black box, you don't really know that this 
mechanism works via a binding to an array controller. You can try binding it 
anyway, and I guess if it works it works. We had a long thread about something 
similar a few months ago, and in that case it didn't work. The binding of a 
popup button does *not* work like the binding of a table column to its value, 
and that's probably the conceptual model that led you to try this. (I can't 
remember if this scenario is the exact same thing, though.)

The other problem, though, is that even if it works, it's not a KVO-compliant 
mechanism. The popup menu content isn't going to update properly if the array 
changes, or if its elements' name properties change.

Assuming that the "un-arranged" array that your array controller's content is 
bound to is (or is in) your data model, then the best solution is probably to 
do the whole thing "correctly":

1. In your window controller, observe the data model array. It also needs a 
mechanism to be told about changes to the "name" properties of the individual 
array elements, since the array's KVO notifications don't handle such property 
changes.

2. In your window controller, define a derived array property that is the 
desired values of the popup menu.

3. Have your window controller maintain this derived array property 
KVO-compliantly.

4. Bind the popup button directly to the window controller's derived array 
property.

Unfortunately, there's no free lunch in this case. OTOH, doing it the "correct" 
way makes it pretty easy to do things like add separators and "Other..." items 
to the popup menu.

Of course, if you go to all that trouble, it's probably easier just to set the 
popup button's menu directly. However, you still don't escape the data model 
KVO . :)


___

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

Please do not post 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: iOS UI Design Question / Opinions wanted

2011-07-14 Thread John Tsombakos
On Thu, Jul 14, 2011 at 9:26 AM, John Tsombakos  wrote:

> On Thu, Jul 14, 2011 at 8:14 AM, Thomas Davie  wrote:
>
>>
>> Along with various other people, I have a custom UISwitch that does
>> exactly what you require, it's available here http://whataboutapp.co.uk/
>>
>> Tom Davie
>
>
> That looks exactly what I would want! Thanks!
>

Hm. Checking it out, looks promising. However, is there a way to put the
control into a view in Interface Builder? Or do you have to do it in code
(alloc/initWithFrame)? There isn't any docs included with the library.

Thanks!
___

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

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

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

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


Re: Key-value coding dynamically-created arrays in NSTableView

2011-07-14 Thread Quincey Morris
On Jul 14, 2011, at 17:08, John Bartleson wrote:

> Here the column identifier specified in the nib is used to select which 
> ChildObject accessor
> to use as the source for the column's data.
> 
> But suppose the columns of the tableView are not defined in the nib. Instead, 
> they are defined
> dynamically by user action at run time. It's easy to dynamically add columns 
> to the tableView and to
> give each one a unique identifier , but is it even possible to somehow assign 
> key names to elements
> in a dynamic data array so valueForKey: can find those elements?
> 
> This issue is made more difficult because the technique valueForKey uses to 
> select an accessor is not
> apparent, at least to a n00b like me. For extra points, can anyone describe 
> how valueForKey works?

If you write '[child valueForKey:@"xxx"]', it eventually invokes 'child.xxx'.

So, if you're adding columns that correspond to *known* ChildObject properties, 
you know you must use the property name as the column identifier, if you want 
your technique to work. This is the same whether the columns are created in the 
nib, or created later in code.

If you're saying you want to "add" arbitrary properties to ChildObject at 
run-time, that's a bit harder. One approach is to use a NSDictionary instead of 
a ChildObject, which responds to 'valueForKey:@"xxx"' by looking up 
'objectForKey:@"xxx"'. But that only works for very simple cases.

Another approach is to have the ChildObject class override 
'valueForUndefinedKey:'. In your override, you figure out if the undefined key 
is something you can come up with a value for. If not, you can just call super 
to get the normal exception.

As you can see, the answer you need depends on the question you're asking. Are 
you just trying to add columns at run-time, or are you trying to "add" data 
model properties at run time?

___

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

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


another attributes question

2011-07-14 Thread Rick C.
Hi again,

I am trying now to get the Kind attribute like what shows in a Finder Get Info 
panel.  I have tried LSCopyKindStringForURL and also kMDItemKind but both of 
these list the "shortened" version of Kind in Finder not the longer version you 
see in the Get Info panel.  So for example on an app the shortened version 
would be Application and the longer version would be Application (Intel).  How 
can I get this longer version is there a way?  Thanks,

rc___

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

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


iOS: AVFoundation, creating sample buffers for an AVAssetWriter from OpenGL ... so confused :-/

2011-07-14 Thread John Michael Zorko

Hello, all ...

I'm trying to create a sample buffer from an OpenGL view using glReadPixels(), 
so I can write the sample buffer with an AVAssetWriter I set up. I'm recording 
audio and video, and i'm really quite confused as to how to do this. So far, 
i'm recording audio and video straight from the sample buffers passed into the 
sample buffer delegate's captureOutput:didOutputSampleBuffer:fromConnection 
call, using an AVAssetWriter that I already set up. However, since i've got a 
shader doing things to the video, I actually want to write the shader-modified 
frame instead of the one passed to the delegate. The examples i've seen so far 
use AVAssetWriterInputPixelBufferAdaptor, but the examples only handle video, 
not video and audio. How do I take what glReadPixels() returns and put it into 
a CMSampleBuffer, so I can write it with my AVAssetWriter?

Any help would be quite appreciated :-)

Regards,

John



___

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

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