Space-efficient saving for Versions?

2011-07-28 Thread Daniel Vollmer
Salutations,

in my custom document package I'm always including a large-ish chunk of data 
that does not get modified as I change the document itself. Currently, I'm 
keeping this around as NSData-object and write it out when being asked by 
NSDocument to return my fileWrapper as one sub-file of the directory package.
Can I do anything to make it more obvious to the Versions / autosave-mechanism 
that this file in the package is always the same? Or will it compare the files 
anyway and notice it's identical to the one used in the previous revision?

Thanks,
Daniel.___

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

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

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

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


Keeping NSOutlineView always active?

2011-07-28 Thread Leo

Hi all,

Is it possible to make NSOutlineView look always active, even if it's 
not the actual first responder?


Similar to the way the sidebar appears in the Finder: the selection in 
sidebar always appears as active, even when you work with the actual 
window contents.


Am I missing something obvious?

Thanks,
Leo
___

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


Keeping NSOutlineView always active?

2011-07-28 Thread Leo

Hi all,

Is it possible to make NSOutlineView look always active, even if it's 
not the actual first responder?


Similar to the way the sidebar appears in the Finder: the selection in 
sidebar always appears as active, even when you work with the actual 
window contents.


Am I missing something obvious?

Thanks,
Leo
___

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: Keeping NSOutlineView always active?

2011-07-28 Thread Leo

Oops sorry - please ignore, just reposted as a separate thread.

Leo


On 7/28/11 4:09:38 AM, Leo wrote:

Hi all,

Is it possible to make NSOutlineView look always active, even if it's 
not the actual first responder?


Similar to the way the sidebar appears in the Finder: the selection in 
sidebar always appears as active, even when you work with the actual 
window contents.


Am I missing something obvious?

Thanks,
Leo 

___

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


UI like Transmission BT

2011-07-28 Thread Wilker
Hi Guys,

Which components of XCode 4 I should use in order to make an UI like the
Transmission BT (http://www.transmissionbt.com/)

I mean the part of downloads, one below the other, its like each download is
a view, but I don't know how to put them one below the order, and how to
make background color cycle. I was looking on Collection View, but after
reading doc it don't really seems to feet for me, I just need something
simpler, one below the other, scroll when its bigger than screen.

Any hints please?
---
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: UI like Transmission BT

2011-07-28 Thread Daniel Vollmer

On 28 Jul 2011, at 10:16, Wilker wrote:

> Hi Guys,
> 
> Which components of XCode 4 I should use in order to make an UI like the
> Transmission BT (http://www.transmissionbt.com/)

Why don't you check yourself in the source-code:
https://trac.transmissionbt.com/browser/trunk/macosx

Daniel.
___

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

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

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

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


Re: UI like Transmission BT

2011-07-28 Thread Thomas Davie

On 28 Jul 2011, at 09:16, Wilker wrote:

> Hi Guys,
> 
> Which components of XCode 4 I should use in order to make an UI like the
> Transmission BT (http://www.transmissionbt.com/)
> 
> I mean the part of downloads, one below the other, its like each download is
> a view, but I don't know how to put them one below the order, and how to
> make background color cycle. I was looking on Collection View, but after
> reading doc it don't really seems to feet for me, I just need something
> simpler, one below the other, scroll when its bigger than screen.

You have three options:
1) Restrict yourself to 10.7 and use NSTableView with NSViews instead of 
NSCells.
2) Code an NSCell for that – this can be pretty damn horrible as NSCells can't 
keep their own state internally, because they will get reused for other rows.
3) Write your own view for putting a bunch of other views one above each other.

1 is trivially easy, 3 is pretty easy, 2 is a nightmare waiting to happen and 
the reason that 1 exists.

Bob___

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: UI like Transmission BT

2011-07-28 Thread Wilker
Thanks guys, I mean I will take the NSTableView + NSView solution, Mac users
migrate fast and my software will still on first release, I mean its ok for
me for early adopting it :)
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600



On Thu, Jul 28, 2011 at 6:15 AM, Thomas Davie  wrote:

>
> On 28 Jul 2011, at 09:16, Wilker wrote:
>
> > Hi Guys,
> >
> > Which components of XCode 4 I should use in order to make an UI like the
> > Transmission BT (http://www.transmissionbt.com/)
> >
> > I mean the part of downloads, one below the other, its like each download
> is
> > a view, but I don't know how to put them one below the order, and how to
> > make background color cycle. I was looking on Collection View, but after
> > reading doc it don't really seems to feet for me, I just need something
> > simpler, one below the other, scroll when its bigger than screen.
>
> You have three options:
> 1) Restrict yourself to 10.7 and use NSTableView with NSViews instead of
> NSCells.
> 2) Code an NSCell for that – this can be pretty damn horrible as NSCells
> can't keep their own state internally, because they will get reused for
> other rows.
> 3) Write your own view for putting a bunch of other views one above each
> other.
>
> 1 is trivially easy, 3 is pretty easy, 2 is a nightmare waiting to happen
> and the reason that 1 exists.
>
> Bob
___

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: UI like Transmission BT

2011-07-28 Thread Corbin Dunn

On Jul 28, 2011, at 2:15 AM, Thomas Davie wrote:

> 
> On 28 Jul 2011, at 09:16, Wilker wrote:
> 
>> Hi Guys,
>> 
>> Which components of XCode 4 I should use in order to make an UI like the
>> Transmission BT (http://www.transmissionbt.com/)
>> 
>> I mean the part of downloads, one below the other, its like each download is
>> a view, but I don't know how to put them one below the order, and how to
>> make background color cycle. I was looking on Collection View, but after
>> reading doc it don't really seems to feet for me, I just need something
>> simpler, one below the other, scroll when its bigger than screen.
> 
> You have three options:
> 1) Restrict yourself to 10.7 and use NSTableView with NSViews instead of 
> NSCells.

I vote for this option.

corbin

___

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: Space-efficient saving for Versions?

2011-07-28 Thread Kevin Perry
The Versions store will do this automatically. It can detect when blocks of a 
file have been duplicated and avoid storing those blocks on disk.

On Jul 28, 2011, at 12:37 AM, Daniel Vollmer wrote:

> Salutations,
> 
> in my custom document package I'm always including a large-ish chunk of data 
> that does not get modified as I change the document itself. Currently, I'm 
> keeping this around as NSData-object and write it out when being asked by 
> NSDocument to return my fileWrapper as one sub-file of the directory package.
> Can I do anything to make it more obvious to the Versions / 
> autosave-mechanism that this file in the package is always the same? Or will 
> it compare the files anyway and notice it's identical to the one used in the 
> previous revision?
> 
> Thanks,
>   Daniel.___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kperry%40apple.com
> 
> This email sent to kpe...@apple.com

___

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

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

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

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


Re: Running Cocoa from a dynamic library

2011-07-28 Thread Jens Alfke

On Jul 27, 2011, at 8:02 AM, Guido Sales Calvano wrote:

> Ogre3D however, uses a cocoa window to render on, and obviously I want user 
> input. But if I start ogre in a dynamic library ui events register 
> incorrectly. 

It’s not the fact that it’s in a dynamic library that causes trouble (for 
example, all system frameworks are in dynamic libraries!) It’s the fact that 
you’re starting a generic Unix process (node.js server) and then trying to turn 
it into a GUI app by calling AppKit in it, without going through the usual 
AppKit initialization (NSApplicationMain). However, I don’t think calling 
NSApplicationMain is the right thing for you to do, because (a) it expects to 
be the first thing called when the process starts, and (b) it will take over 
the main thread.

I know that this can be done, though I don’t know the details of how. But 
hopefully this will get you looking closer to the right place, or nudge people 
who do know more to provide some answers.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: Running Cocoa from a dynamic library

2011-07-28 Thread Bill Appleton
You might try NPAPI, it is designed to let you draw on a surface and get
events

Your plugin runs in a separate process, and is scriptable by javascript



best

bill





On Wed, Jul 27, 2011 at 8:02 AM, Guido Sales Calvano  wrote:

> Dear community,
>
> I'm building a project I've been thinking about for 14 years now. Finally
> doing
> it. But I've hit a stumbling block... So I need help...
>
> I'm trying to wrap Ogre3D a graphics engine in a javascript api using v8,
> and
> then load that as a module in node js, a javascript framework focussed on
> web
> communication tasks such as running a server. Node js can load other
> javascript
> modules that are bound to C++ code as dynamic libraries.
>
> Ogre3D however, uses a cocoa window to render on, and obviously I want user
> input. But if I start ogre in a dynamic library ui events register
> incorrectly.
> Only clicks and drag operations are detected, but no key input or mouse
> move
> events. This only happens when I load the library dynamically. I know this
> because I created a simple program that just loaded my dynamic lib to test
> the
> assumption. If I don't load the lib dynamically, but link directly
> everything
> works fine.
>
> The answer is probably quite simple, once you know where to look, but I
> don't
> know where to look. So please help.
>
> Kind regards (:
>
> Guido
> ___
>
> 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/billappleton%40dreamfactory.com
>
> This email sent to billapple...@dreamfactory.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


Filter an array

2011-07-28 Thread Chris Paveglio
I have an array of file paths, and I need to filter them to return only files 
with extensions I have in another array. So any files that end with {.tif, 
.png, .eps} etc. 
I'm looking at using: - (NSArray 
*)filteredArrayUsingPredicate:(NSPredicate *)predicate
Is this the best option for this kind of filter? Is there any other way, aside 
from "doing it the long long way", i.e. enumerating over each's item's 
pathExtension in array1 through each file extension in array2?
Thanks,
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/archive%40mail-archive.com

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


Re: NSFileManager - a cautionary tale

2011-07-28 Thread Greg Parker
On Jul 26, 2011, at 6:51 PM, Graham Cox wrote:
> On 27/07/2011, at 11:14 AM, Graham Cox wrote:
>> However, this method eventually calls mkdir, which fails with an error if 
>> the directory already exists. This call to mkdir causes the App Store 
>> reviewers to have conniptions, even though it certainly fails. The failure 
>> of mkdir is interpreted by NSFileManager as a success (i.e. the method 
>> apparently works by attempting the mkdir, rather than checking for its 
>> existence beforehand).

Did you file a bug report?


> Another thing to mention - we run this code during app launch, so we didn't 
> see it in fs_usage, which requires that the process it's peeking at is 
> running already. I'm not sure if there is a way to observe file system stuff 
> during launch - if anyone knows, please let me know!

Run in a debugger with a breakpoint at the top of main(). When you hit the 
breakpoint, start on fs_usage and continue. If you need to catch something that 
runs before main(), try a breakpoint on something low-level like malloc() and 
disable it after it hits the first time.


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


___

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

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

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

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


Re: Filter an array

2011-07-28 Thread Kyle Sluder
On Thu, Jul 28, 2011 at 1:35 PM, Chris Paveglio
 wrote:
> I have an array of file paths, and I need to filter them to return only files 
> with extensions I have in another array. So any files that end with {.tif, 
> .png, .eps} etc.
> I'm looking at using: - (NSArray 
> *)filteredArrayUsingPredicate:(NSPredicate *)predicate
> Is this the best option for this kind of filter? Is there any other way, 
> aside from "doing it the long long way", i.e. enumerating over each's item's 
> pathExtension in array1 through each file extension in array2?

Actually, the "long way" might be your best bet after all.

You could use -[NSArray indexesOfObjectsWithOptions:passingTest:] to
enlist GCD to do a parallel filtering of all your strings:

// warning: typed in mail client
NSArray *validExtensions = [NSArray arrayWithObjects:@".tif", @".png",
@".eps", nil];
NSIndexSet *indexes = [myFilePaths
indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^(id
obj, NSUInteger idx, BOOL *stop) {
  NSString *filePath = (NSString *)obj;
  for (NSString *extension in validExtensions) {
if ([[string pathExtension] isEqualToString:extension])
  return YES;
  }

  return NO;
}];

NSArray *filteredPaths = [myFilePaths objectsAtIndexes:indexes];

--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: Filter an array

2011-07-28 Thread Kyle Sluder
Oh, I don't know how I missed this, but there's a very convenient
-[NSArray pathsMatchingExtensions:] method already declared in
NSPathUtilities.h:
http://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/doc/uid/2137-BBCHHAJJ

So your entire problem boils down to one method call.

--Kyle Sluder

On Thu, Jul 28, 2011 at 1:45 PM, Kyle Sluder  wrote:
> On Thu, Jul 28, 2011 at 1:35 PM, Chris Paveglio
>  wrote:
>> I have an array of file paths, and I need to filter them to return only 
>> files with extensions I have in another array. So any files that end with 
>> {.tif, .png, .eps} etc.
>> I'm looking at using: - (NSArray 
>> *)filteredArrayUsingPredicate:(NSPredicate *)predicate
>> Is this the best option for this kind of filter? Is there any other way, 
>> aside from "doing it the long long way", i.e. enumerating over each's item's 
>> pathExtension in array1 through each file extension in array2?
>
> Actually, the "long way" might be your best bet after all.
>
> You could use -[NSArray indexesOfObjectsWithOptions:passingTest:] to
> enlist GCD to do a parallel filtering of all your strings:
>
> // warning: typed in mail client
> NSArray *validExtensions = [NSArray arrayWithObjects:@".tif", @".png",
> @".eps", nil];
> NSIndexSet *indexes = [myFilePaths
> indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^(id
> obj, NSUInteger idx, BOOL *stop) {
>  NSString *filePath = (NSString *)obj;
>  for (NSString *extension in validExtensions) {
>    if ([[string pathExtension] isEqualToString:extension])
>      return YES;
>  }
>
>  return NO;
> }];
>
> NSArray *filteredPaths = [myFilePaths objectsAtIndexes:indexes];
>
> --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: NSFileManager - a cautionary tale

2011-07-28 Thread wadeslists
>> Another thing to mention - we run this code during app launch, so we didn't 
>> see it in fs_usage, which requires that the process it's peeking at is 
>> running already. I'm not sure if there is a way to observe file system stuff 
>> during launch - if anyone knows, please let me know!

sudo fs_usage | grep 

You could also use one of the various instruments in Instruments; if you launch 
your app from Instruments it'll record it's startup.
___

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: Filter an array

2011-07-28 Thread wadeslists
> Oh, I don't know how I missed this, but there's a very convenient
> -[NSArray pathsMatchingExtensions:] method already declared in
> NSPathUtilities.h:
> http://developer.apple.com/library/mac/documentation/cocoa/reference/foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/doc/uid/2137-BBCHHAJJ
> 
> So your entire problem boils down to one method call.

The docs don't state whether it's case sensitive or not.  It also takes the 
list as an NSArray rather than an NSSet, which is suboptimal.

> 
>> // warning: typed in mail client
>> NSArray *validExtensions = [NSArray arrayWithObjects:@".tif", @".png",
>> @".eps", nil];
>> NSIndexSet *indexes = [myFilePaths
>> indexesOfObjectsWithOptions:NSEnumerationConcurrent passingTest:^(id
>> obj, NSUInteger idx, BOOL *stop) {
>>  NSString *filePath = (NSString *)obj;
>>  for (NSString *extension in validExtensions) {
>>if ([[string pathExtension] isEqualToString:extension])
>>  return YES;
>>  }
>> 


If you were to go this approach, which I wouldn't recommend given the existence 
of the convenience method above (assuming it's properly case-insensitive), do:

1) Use caseInsensitiveCompare:, not isEqualToString:.
2) Consider using an NSSet for the set of accepted extensions (though that will 
mean ensuring they're all e.g. lowercase, both when inserting the accepted 
values into the set and prior to checking for set membership).
___

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: Filter an array

2011-07-28 Thread Mike Abdullah
Further to earlier answers, bear in mind you've got no guarantee that file 
extensions are correct, or even exist. Plus of course, you might have both .jpg 
and .jpeg. You might well be better iterating through, finding the UTI of each 
file, and working from that.

On 28 Jul 2011, at 21:35, Chris Paveglio wrote:

> I have an array of file paths, and I need to filter them to return only files 
> with extensions I have in another array. So any files that end with {.tif, 
> .png, .eps} etc. 
> I'm looking at using: - (NSArray *)filteredArrayUsingPredicate:(NSPredicate 
> *)predicate
> Is this the best option for this kind of filter? Is there any other way, 
> aside from "doing it the long long way", i.e. enumerating over each's item's 
> pathExtension in array1 through each file extension in array2?
> Thanks,
> 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/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net

___

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

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

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

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


Return causes EXC_BAD_ACCESS

2011-07-28 Thread Mr. Gecko
I am unable to find out as to why I am receiving this problem, I can verify 
other parts of the code before it gets to the return and that the object I am 
returning does in-fact work as I am able to NSLog it and see the description of 
it. The basic idea of this code is to notify other objects to see if one exists 
with the same path and if it does, it will tell the object I am using to check 
where it is at by setFoundCookieJar:self. It seems to work, as I can see the 
value when logging it. This one problem is stopping the code I wrote from being 
usable.

If someone can explain why this is happening and give me a link to explanation 
on this signal and why it occurs as I have and a friend of mine has seen it in 
weird areas that seems like it should work from an understand of the code and 
playing around seems like it will work by logging out information. From my 
understanding, this should happen when you, for an example, try to access the 
pointer 0x18c95b0 whenever that belongs to another process. However, I also 
thought that the Mac has a copy of memory space for each process and therefore 
should not be able to access memory that it doesn't own unless the core os does 
so.

[notificationCenter postNotificationName:MGMCookieJarExists object:self 
userInfo:[NSDictionary dictionaryWithObject:cookiesPath 
forKey:MGMCookieJarKey]];
if (foundCookieJar!=nil) {
[self release];
self = nil;
return foundCookieJar;
}

Thanks for any help on this issue,
Mr. Gecko___

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: Return causes EXC_BAD_ACCESS

2011-07-28 Thread Dave DeLong
It kind of looks like foundCookieJar is an ivar, which means that "return 
foundCookieJar" is really going to be "return self->foundCookieJar".  Since you 
set "self" to "nil", you're trying to dereference a NULL pointer, which is a 
great way to crash your app.

HTH,

Dave

On Jul 28, 2011, at 2:33 PM, Mr. Gecko wrote:

> I am unable to find out as to why I am receiving this problem, I can verify 
> other parts of the code before it gets to the return and that the object I am 
> returning does in-fact work as I am able to NSLog it and see the description 
> of it. The basic idea of this code is to notify other objects to see if one 
> exists with the same path and if it does, it will tell the object I am using 
> to check where it is at by setFoundCookieJar:self. It seems to work, as I can 
> see the value when logging it. This one problem is stopping the code I wrote 
> from being usable.
> 
> If someone can explain why this is happening and give me a link to 
> explanation on this signal and why it occurs as I have and a friend of mine 
> has seen it in weird areas that seems like it should work from an understand 
> of the code and playing around seems like it will work by logging out 
> information. From my understanding, this should happen when you, for an 
> example, try to access the pointer 0x18c95b0 whenever that belongs to another 
> process. However, I also thought that the Mac has a copy of memory space for 
> each process and therefore should not be able to access memory that it 
> doesn't own unless the core os does so.
> 
> [notificationCenter postNotificationName:MGMCookieJarExists object:self 
> userInfo:[NSDictionary dictionaryWithObject:cookiesPath 
> forKey:MGMCookieJarKey]];
> if (foundCookieJar!=nil) {
>   [self release];
>   self = nil;
>   return foundCookieJar;
> }
> 
> Thanks for any help on this issue,
> Mr. Gecko___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
> 
> This email sent to davedel...@me.com

___

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

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

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

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


Re: Return causes EXC_BAD_ACCESS

2011-07-28 Thread Mr. Gecko
That makes lots of sense, never even expected that to happen. Adding a local 
variable and setting it to the value before releasing it and returning that 
variable fixes the issue. I am still looking to an link to explanation in 
detail as to why this happens. If it's as I said, then I do not think I need it.

On Jul 28, 2011, at 4:35 PM, Dave DeLong wrote:

> It kind of looks like foundCookieJar is an ivar, which means that "return 
> foundCookieJar" is really going to be "return self->foundCookieJar".  Since 
> you set "self" to "nil", you're trying to dereference a NULL pointer, which 
> is a great way to crash your app.
> 
> HTH,
> 
> Dave
___

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: Return causes EXC_BAD_ACCESS

2011-07-28 Thread Kyle Sluder
On Thu, Jul 28, 2011 at 2:45 PM, Mr. Gecko  wrote:
> That makes lots of sense, never even expected that to happen. Adding a local 
> variable and setting it to the value before releasing it and returning that 
> variable fixes the issue. I am still looking to an link to explanation in 
> detail as to why this happens. If it's as I said, then I do not think I need 
> it.

There's a very strong but unwritten expectation that self remains
valid for the entirety of a method implementation, except possibly in
-init.

ARC enforces this restriction: self is const in all non-init methods.

I'm not sure what your motivation is for calling [self release] here,
but no code should be doing this.

--Kyle Sluder
___

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

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

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

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


Re: Return causes EXC_BAD_ACCESS

2011-07-28 Thread Dave DeLong
Well, let's think about it.  "Instance variables" are only accessible as long 
as you have an instance, right?  You can't have an instance variable without an 
instance.  So if you set "self" to nil... then you no longer have an instance.  
Thus, you cannot access self's instance variables, because there is no self.

Sorry I don't have a doc link for you; perhaps someone more well-versed with 
the documentation search tools than I can find something relevant.  :)

Dave

On Jul 28, 2011, at 2:45 PM, Mr. Gecko wrote:

> That makes lots of sense, never even expected that to happen. Adding a local 
> variable and setting it to the value before releasing it and returning that 
> variable fixes the issue. I am still looking to an link to explanation in 
> detail as to why this happens. If it's as I said, then I do not think I need 
> it.
> 
> On Jul 28, 2011, at 4:35 PM, Dave DeLong wrote:
> 
>> It kind of looks like foundCookieJar is an ivar, which means that "return 
>> foundCookieJar" is really going to be "return self->foundCookieJar".  Since 
>> you set "self" to "nil", you're trying to dereference a NULL pointer, which 
>> is a great way to crash your app.
>> 
>> HTH,
>> 
>> Dave

___

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: Return causes EXC_BAD_ACCESS

2011-07-28 Thread Scott Ribe
On Jul 28, 2011, at 3:33 PM, Mr. Gecko wrote:

> From my understanding, this should happen when you, for an example, try to 
> access the pointer 0x18c95b0 whenever that belongs to another process. 
> However, I also thought that the Mac has a copy of memory space for each 
> process and therefore should not be able to access memory that it doesn't own 
> unless the core os does so.

No, not even close. It happens when you access a memory address that has not 
been mapped into your process' memory space. I've given you plenty of terms to 
google; go for it.

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




___

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

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

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

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


Re: Running Cocoa from a dynamic library

2011-07-28 Thread Stephen J. Butler
On Thu, Jul 28, 2011 at 1:14 PM, Jens Alfke  wrote:
> On Jul 27, 2011, at 8:02 AM, Guido Sales Calvano wrote:
>
>> Ogre3D however, uses a cocoa window to render on, and obviously I want user
>> input. But if I start ogre in a dynamic library ui events register 
>> incorrectly.
>
> It’s not the fact that it’s in a dynamic library that causes trouble (for 
> example, all system frameworks are in dynamic libraries!) It’s the fact that 
> you’re starting a generic Unix process (node.js server) and then trying to 
> turn it into a GUI app by calling AppKit in it, without going through the 
> usual AppKit initialization (NSApplicationMain). However, I don’t think 
> calling NSApplicationMain is the right thing for you to do, because (a) it 
> expects to be the first thing called when the process starts, and (b) it will 
> take over the main thread.
>
> I know that this can be done, though I don’t know the details of how. But 
> hopefully this will get you looking closer to the right place, or nudge 
> people who do know more to provide some answers.


NSApplicationLoad()?  Although that's meant to be called from Carbon
applications. I don't know that command line applications will work at
all.
___

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: NSFileManager - a cautionary tale

2011-07-28 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 7/28/11 2:05 PM, wadesli...@mac.com wrote:
> sudo fs_usage | grep 

No need to use grep... you can just:

sudo fs_usage 

(This is similar to the redundant "cat  | grep foo")


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOMeQoaOlrz5+0JdURAk2oAJ9pVF5JFeiYHWE1G/p4brMUh9sJaACdHlNo
nGubPfAtm+mjQqAaUjYeOec=
=PeSQ
-END PGP SIGNATURE-
___

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


Calculations in a tableview

2011-07-28 Thread Andre Masse
Hi,

For example, lets say I have a tableview with 3 columns: quantity, unit price 
and total. I want to calculate total using (quantity * unit price). Pretty 
simple using a datasource but I've no idea how to do that with bindings (using 
an NSArrayController).

Any pointer to an example of this would be greatly appreciated.

Thanks,

Andre Masse
___

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: Calculations in a tableview

2011-07-28 Thread Thomas Davie

On 28 Jul 2011, at 23:48, Andre Masse wrote:

> Hi,
> 
> For example, lets say I have a tableview with 3 columns: quantity, unit price 
> and total. I want to calculate total using (quantity * unit price). Pretty 
> simple using a datasource but I've no idea how to do that with bindings 
> (using an NSArrayController).
> 
> Any pointer to an example of this would be greatly appreciated.

To be honest, this, along with the many debugging issues of bindings is exactly 
why I still use data sources.

Bob___

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: Return causes EXC_BAD_ACCESS

2011-07-28 Thread Jens Alfke

On Jul 28, 2011, at 3:00 PM, Kyle Sluder wrote:

> I'm not sure what your motivation is for calling [self release] here,
> but no code should be doing this.

I disagree. There are a couple of reasons to call this:

- It’s pat of the failure path for -init methods. Before returning nil you need 
to call [self release] to avoid leaking.

- An object that performs some asynchronous task may want to retain itself when 
starting the task, and release itself when done, to make sure it won’t get 
dealloced before the task finishes.


Mr. Gecko wrote:
> I am still looking to an link to explanation in detail as to why this happens

If ‘foundCookieJar’ is an instance variable, than any time you refer to it in a 
method, the compiler actually implements it as “self->foundCookieJar”. From 
that, it should be pretty clear that if you set self to nil, the next reference 
to ‘self->foundCookieJar’ is a nil pointer access that’s going to crash.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: UI like Transmission BT

2011-07-28 Thread Wilker
I'm trying a lot to make the NSTableView + NSView but I just can't make it
work... I don't know the way to go, I was reading this doc here:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TableView/ViewBasedTables/ViewBasedTables.html#//apple_ref/doc/uid/1026i-CH15-SW2

But it don't explains too much... I created an xib file for my view, but I
don't know how to load it to be cell of the view... The doc says to use a
CustomView component inside cell, I dropped one, but I can't see how to link
it with my xib. You have any good tutorial about it guys?
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600



On Thu, Jul 28, 2011 at 1:30 PM, Corbin Dunn  wrote:

>
> On Jul 28, 2011, at 2:15 AM, Thomas Davie wrote:
>
> >
> > On 28 Jul 2011, at 09:16, Wilker wrote:
> >
> >> Hi Guys,
> >>
> >> Which components of XCode 4 I should use in order to make an UI like the
> >> Transmission BT (http://www.transmissionbt.com/)
> >>
> >> I mean the part of downloads, one below the other, its like each
> download is
> >> a view, but I don't know how to put them one below the order, and how to
> >> make background color cycle. I was looking on Collection View, but after
> >> reading doc it don't really seems to feet for me, I just need something
> >> simpler, one below the other, scroll when its bigger than screen.
> >
> > You have three options:
> > 1) Restrict yourself to 10.7 and use NSTableView with NSViews instead of
> NSCells.
>
> I vote for this option.
>
> corbin
>
>
___

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: Filter an array

2011-07-28 Thread Jens Alfke

On Jul 28, 2011, at 1:35 PM, Chris Paveglio wrote:

> I'm looking at using: - (NSArray *)filteredArrayUsingPredicate:(NSPredicate 
> *)predicate

I was going to suggest using a block to filter, but it seems that Foundation 
collections still don’t implement the standard functional operators like ‘map’ 
and ‘filter' found in lots of other languages. Which is too bad, since 
otherwise you could write it compactly as

NSArray* filtered = [paths filter: ^(NSString path){
return [validExtensions containsObject: 
path.pathExtension.lowercaseString];
}];

There’s -indexesOfObjectsWithOptions:passingTest:, as Kyle pointed out, but 
that adds another step of generating and using an index-set.

I found the lack of -map so annoying that I wrote a category method for it in 
my current project...

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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: UI like Transmission BT

2011-07-28 Thread Wilker
Sorry guys, my bad...

I tried to create a View Controller class by extending from NSView instead
of NSViewController...

Now its running fine :)

Just one last question, I'm using a table with a single column, how I make
this column fill 100% of table and follow the table size (in case of table
growl or reduce)?
---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Kajabi Consultant
+55 81 82556600



On Thu, Jul 28, 2011 at 8:14 PM, Wilker  wrote:

> I'm trying a lot to make the NSTableView + NSView but I just can't make it
> work... I don't know the way to go, I was reading this doc here:
> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TableView/ViewBasedTables/ViewBasedTables.html#//apple_ref/doc/uid/1026i-CH15-SW2
>
> But it don't explains too much... I created an xib file for my view, but I
> don't know how to load it to be cell of the view... The doc says to use a
> CustomView component inside cell, I dropped one, but I can't see how to link
> it with my xib. You have any good tutorial about it guys?
>
> ---
> Wilker Lúcio
> http://about.me/wilkerlucio/bio
> Kajabi Consultant
> +55 81 82556600
>
>
>
> On Thu, Jul 28, 2011 at 1:30 PM, Corbin Dunn  wrote:
>
>>
>> On Jul 28, 2011, at 2:15 AM, Thomas Davie wrote:
>>
>> >
>> > On 28 Jul 2011, at 09:16, Wilker wrote:
>> >
>> >> Hi Guys,
>> >>
>> >> Which components of XCode 4 I should use in order to make an UI like
>> the
>> >> Transmission BT (http://www.transmissionbt.com/)
>> >>
>> >> I mean the part of downloads, one below the other, its like each
>> download is
>> >> a view, but I don't know how to put them one below the order, and how
>> to
>> >> make background color cycle. I was looking on Collection View, but
>> after
>> >> reading doc it don't really seems to feet for me, I just need something
>> >> simpler, one below the other, scroll when its bigger than screen.
>> >
>> > You have three options:
>> > 1) Restrict yourself to 10.7 and use NSTableView with NSViews instead of
>> NSCells.
>>
>> I vote for this option.
>>
>> corbin
>>
>>
>
___

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


drawRect not getting called problem solved

2011-07-28 Thread Tom Jeffries
I appreciate all the comments on the problem I had with drawRect not
getting called.  I finally extracted the code that was not working and
put it in a new program, and it worked perfectly.  I'm still not sure
whether there was a problem in my code or if I unearthed a problem in
Cocoa, but I'm now adding the rest of the original program to the new
program, and the graphics are working.

I understand that people who program in only one environment want to
see code that matches the way they learned to program.  That causes
problems for those of us who work in multiple environments, some of
which have a whole different set of "rules".  However, maybe it's a
sign that software development is still at an early stage that some
environments insist on Data and others insist on data.  I do think
it's important to keep in mind the difference between code and data,
and some of the suggestions I got seemed to show some lack of clarity
in that area. Confusing the two may work in certain specific
environments, but it reflects a misunderstanding of the way computers
actually work.  I think it's important to have an awareness of the
difference.

Thanks again for your help.
___

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: drawRect not getting called problem solved

2011-07-28 Thread Jens Alfke

On Jul 28, 2011, at 5:31 PM, Tom Jeffries wrote:

> I do think
> it's important to keep in mind the difference between code and data,
> and some of the suggestions I got seemed to show some lack of clarity
> in that area. Confusing the two may work in certain specific
> environments, but it reflects a misunderstanding of the way computers
> actually work.  I think it's important to have an awareness of the
> difference.

Code and data interact in different ways at different levels, and the 
distinction isn’t always clear-cut. In some languages it’s very blurry indeed 
(LISP, shell scripts, machine code). Object-oriented languages have specific 
ways code and data combine, functional languages have others. It sounded from 
some of your earlier messages* like you may not be used to object-oriented 
languages (or maybe just used to very rigid ones like C++ or Java), so some 
things you interpreted as unclear might just reflect a different way of 
thinking than you’re used to.

—Jens

*(In particular, it seemed like you were using ‘function’ and ‘variable’ in 
ways that didn’t reflect what was actually going on in the program)

smime.p7s
Description: S/MIME cryptographic signature
___

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: Calculations in a tableview

2011-07-28 Thread Andre Masse
Well, I may end up doing this…

Thanks

Andre Masse


On 28/07/2011, at 18:52 , Thomas Davie wrote:

> 
> On 28 Jul 2011, at 23:48, Andre Masse wrote:
> 
>> Hi,
>> 
>> For example, lets say I have a tableview with 3 columns: quantity, unit 
>> price and total. I want to calculate total using (quantity * unit price). 
>> Pretty simple using a datasource but I've no idea how to do that with 
>> bindings (using an NSArrayController).
>> 
>> Any pointer to an example of this would be greatly appreciated.
> 
> To be honest, this, along with the many debugging issues of bindings is 
> exactly why I still use data sources.
> 
> Bob

___

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: drawRect not getting called problem solved

2011-07-28 Thread Graham Cox

On 29/07/2011, at 10:31 AM, Tom Jeffries wrote:

> I do think
> it's important to keep in mind the difference between code and data,
> and some of the suggestions I got seemed to show some lack of clarity
> in that area. Confusing the two may work in certain specific
> environments, but it reflects a misunderstanding of the way computers
> actually work.  I think it's important to have an awareness of the
> difference.


I'm not quite sure what you're referring to with this comment - looking back 
over the replies in the (former) thread about this doesn't make it very clear.

But if you are referring to object-oriented programming in general, where 
objects are code + data combined, you are swimming upstream there. All OOP 
"environments", languages really, start here - it's easier to program if code 
and data are combined and not kept separate. This is reflected in the fact that 
no major new language written post-early 80s uses a procedural approach rather 
than an object-oriented one. It doesn't matter how computers "really" work, 
what's important is having a usable abstraction that a programmer can use to be 
productive, and so far, OOP is proving to be immensely successful by that 
criterion. But, computers "really" don't work by separating code and data 
anyway - the whole Von-Neumann architecture that is just about every computer 
ever built was a breakthrough precisely because it stopped treating code and 
data as two different kinds of things and lumped them all together.

If your comment is more to do with the division of labour between different 
objects within your design, then sure, it's possible to go ahead and make a 
real mess if you aren't methodical. But Cocoa in particular is very 
conscientious when it comes to reinforcing the 'Model-View-Controller' (MVC) 
stratum, and every Cocoa developer is wise to follow its example.

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

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


Re: Return causes EXC_BAD_ACCESS

2011-07-28 Thread Graham Cox

On 29/07/2011, at 7:33 AM, Mr. Gecko wrote:

> From my understanding, this should happen when you, for an example, try to 
> access the pointer 0x18c95b0 whenever that belongs to another process.


No.

Memory is "virtual", the addresses you appear to be working with are not real 
(i.e. they don't refer to the real address of the physical RAM underneath). 
Instead, a bit of hardware translates these to the real addresses as needed at 
some level far below the perception of your program. You cannot access the 
virtual address space of any other process other than your own.

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

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


Freaking out a bit...

2011-07-28 Thread John Cate
applicationWillFinishLaunching: and applicationDidFinishLaunching: are not 
getting called. I checked the spelling, going so far as to copy and paste from 
documentation to code. (It worked pre-OS X 10.7). I made sure the delegate was 
set by NSLogging it. I even added the formal protocol tag. To top it off, my 
application is just opening the last document I used. I'm guessing that has 
something to do with the pList.lockfile.


How do I get the delegate methods to fire normally and how do I prevent this 
auto restore behavior?

Tony

___

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: Calculations in a tableview

2011-07-28 Thread Rajendran P
Try value transformers

Thanks
Rajendran P


On 7/29/11 6:18 AM, "Andre Masse"  wrote:

Well, I may end up doing this...

Thanks

Andre Masse


On 28/07/2011, at 18:52 , Thomas Davie wrote:

>
> On 28 Jul 2011, at 23:48, Andre Masse wrote:
>
>> Hi,
>>
>> For example, lets say I have a tableview with 3 columns: quantity, unit 
>> price and total. I want to calculate total using (quantity * unit price). 
>> Pretty simple using a datasource but I've no idea how to do that with 
>> bindings (using an NSArrayController).
>>
>> Any pointer to an example of this would be greatly appreciated.
>
> To be honest, this, along with the many debugging issues of bindings is 
> exactly why I still use data sources.
>
> Bob

___

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/rpichaim%40juniper.net

This email sent to rpich...@juniper.net

___

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

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

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

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


Re: Calculations in a tableview

2011-07-28 Thread Quincey Morris
On Jul 28, 2011, at 15:48, Andre Masse wrote:

> For example, lets say I have a tableview with 3 columns: quantity, unit price 
> and total. I want to calculate total using (quantity * unit price). Pretty 
> simple using a datasource but I've no idea how to do that with bindings 
> (using an NSArrayController).

Well, that's the problem right there. You seem to think bindings have something 
to do with array controllers. They don't. (Bindings and array controllers are 
often used together, of course, both on the "content" side of the array 
controller and on the "arrangedObjects" side, but that's just a case of two 
things being used to complement each other.)

When working with bindings, it helps to be very diligent in thinking in terms 
of properties.

If you're supplying a table view's cells via bindings, then you must have a 
model property for *each* column. In your case, your data model is (or 
includes) an array property (say, "invoiceItems"), whose elements are objects 
(of class, say, "InvoiceItem") with properties "quantity", "unitPrice" and 
"totalPrice". 

If the total is always calculated from the other two properties, it is 
typically a "derived" property (one whose value is derived on the fly, rather 
than actually stored), but aside from that implementation detail, there's no 
difference in how you use the properties to populate your table.

In code terms, the short answer to your question is:

>   + (NSSet) keyPathsForValuesAffectingTotalPrice {
>   return [NSSet setWithObjects: @"quantity", @"unitPrice", nil];
>   }
> 
>   - (NSInteger) totalPrice { // or whatever the correct data type is
>   return self.quantity * self.unitPrice;
>   }

The second method provides the derived property value. The first method 
provides KVO compliance.

So how does the array controller enter this picture at all? It's a glue object 
(aka "mediating controller") whose function is to sort and filter the model 
array property. It has no role in sourcing actual data to your table***.



*** It's certainly possible to *give* it a role, but I would argue that this is 
a terrible idea.


___

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: Calculations in a tableview

2011-07-28 Thread Steve Steinitz
Hi,

On 29 Jul 11, at 10:51am, cocoa-dev-requ...@lists.apple.com wrote:

> For example, lets say I have a tableview with 3 columns: quantity, unit price 
> and total. I want to calculate total using (quantity * unit price). Pretty 
> simple using a datasource but I've no idea how to do that with bindings 
> (using an NSArrayController).
> 
> Any pointer to an example of this would be greatly appreciated.

(Using Core Data with tables) I just write a method to calculate quantity * 
price and then bind the third column to that.

Cheers,

Steve___

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: Lion doesn't like tricky.key.paths in bindings?

2011-07-28 Thread Jerry Krinock

On 2011 Jul 24, at 09:05, Clark Cox wrote:

> Well, is the suggestion correct? That is, is there any way that the
> value of barDate could have changed without sending the appropriate
> KVO notification (did you, for example change the value of barDate
> without going through the setter?)

Thank you, Clark.  I've looked at and searched the code quite a bit, and am 
confident that I'm not accessing instance variables directly.  And there is 
definitely something different in Lion.

Has anyone else been successful binding to tricky.key.paths in Lion?  By 
"tricky", I mean that the last "word" in the key path is not an attribute but 
is in fact a method which formats a number or date into a string.  Example of a 
tricky key path:

 "someDateAttributeKey.someFormattingMethod"

where 
 someDateAttributeKey is an attribute whose value is an NSDate
 -someFormattingMethod is a method defined in a category of
 NSDate which returns a NSString.


___

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 trap with full screen in Lion

2011-07-28 Thread Gideon King
I just came across a bit of an issue with the full screen mode in Lion: if you 
have a view and use [[self window] windowController] to get at your window 
controller, it will return nil in full screen mode. The window gets swapped out 
with an NSToolbarFullScreenWindow, which doesn't have a window controller set. 
I haven't checked but assume this will also apply to things like delegates etc 
too. And if you were relying on something in a custom NSWindow subclass, that 
would be gone...

I have found that [[NSApp mainWindow] windowController] returns the right 
thing, which is sufficient for my needs at the moment, seeing as it's UI level 
and working on the current document.

I don't know whether there are any other issues with the full window but I 
thought it would be interesting to bring up this issue for discussion in case 
there are further implications.


Regards

Gideon








___

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: Lion doesn't like tricky.key.paths in bindings?

2011-07-28 Thread Kyle Sluder
On Thu, Jul 28, 2011 at 7:20 PM, Jerry Krinock  wrote:
>> Well, is the suggestion correct? That is, is there any way that the
>> value of barDate could have changed without sending the appropriate
>> KVO notification (did you, for example change the value of barDate
>> without going through the setter?)
>
> Thank you, Clark.  I've looked at and searched the code quite a bit, and am 
> confident that I'm not accessing instance variables directly.  And there is 
> definitely something different in Lion.
>
> Has anyone else been successful binding to tricky.key.paths in Lion?  By 
> "tricky", I mean that the last "word" in the key path is not an attribute but 
> is in fact a method which formats a number or date into a string.  Example of 
> a tricky key path:

If you're not returning precisely the same NSString instance every
time KVO thinks you should, then you are violating the rules and KVO
has every right to complain.

KVO doesn't do an -isEqual: on the result of your method. It does
pointer equality. Something changed on Lion that causes it to now care
that the return value of your method stays constant when it should.

If you want to use a transformer-type method, you implement
+keyPathsForValuesAffecting<> appropriately, that
way KVO knows when to ask for a pointer to a new NSString instance.

--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: Freaking out a bit...

2011-07-28 Thread Kyle Sluder
On Thu, Jul 28, 2011 at 6:20 PM, John Cate  wrote:
> applicationWillFinishLaunching: and applicationDidFinishLaunching: are not 
> getting called. I checked the spelling, going so far as to copy and paste 
> from documentation to code. (It worked pre-OS X 10.7). I made sure the 
> delegate was set by NSLogging it. I even added the formal protocol tag. To 
> top it off, my application is just opening the last document I used. I'm 
> guessing that has something to do with the pList.lockfile.

Why would it have anything to do with the plist lockfile?

You are experiencing the new Transparent Application Lifecycle and
Restore functions of Lion. You will need to update your application to
deal with them.

--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: A trap with full screen in Lion

2011-07-28 Thread Gideon King
Sorry - missed an important bit of info - this applies for a view that is in 
the toolbar. So far as I am aware, it doesn't apply to views in your main 
window (at least my views in my main window still appear to always return the 
right thing).
On 29/07/2011, at 12:38 PM, Gideon King wrote:

> I just came across a bit of an issue with the full screen mode in Lion: if 
> you have a view and use [[self window] windowController] to get at your 
> window controller, it will return nil in full screen mode. The window gets 
> swapped out with an NSToolbarFullScreenWindow, which doesn't have a window 
> controller set. I haven't checked but assume this will also apply to things 
> like delegates etc too. And if you were relying on something in a custom 
> NSWindow subclass, that would be gone...
> 
> I have found that [[NSApp mainWindow] windowController] returns the right 
> thing, which is sufficient for my needs at the moment, seeing as it's UI 
> level and working on the current document.
> 
> I don't know whether there are any other issues with the full window but I 
> thought it would be interesting to bring up this issue for discussion in case 
> there are further implications.
> 
> 
> Regards
> 
> Gideon
> 
> 
> 
> 
> 
> 
> 
> 

___

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: Calculations in a tableview

2011-07-28 Thread Andre Masse
Thanks a lot for the clarifications about the role of the NSArrayController. I 
somehow got confused about the whole binding thing, its not so muddy now. Now, 
the example I gave was a bad simplification of the real thing as the 
"totalPrice" is more a "proposedTotalPrice". It's based on a calculation but 
can/will be changed by the user.

So, what I need is a way to calculate a property, but let the user change it if 
he wants. For example, having 3 values  "a", "b" and "c" (a +  b = c). The user 
enters a value for "a" or "b", then "c" is calculated. If the user changes "c", 
it now lose its dependance on "a" and "b". This would be easy if the 3 values 
were in an NSTextField instead of a tableview as I could add an action to the 
first 2 fields and none to the third.

Is this can be done using bindings or should I stop fighting the framework and 
and use a datasource?

Thanks,

Andre Masse


On 28/07/2011, at 22:13 , Quincey Morris wrote:

> On Jul 28, 2011, at 15:48, Andre Masse wrote:
> 
>> For example, lets say I have a tableview with 3 columns: quantity, unit 
>> price and total. I want to calculate total using (quantity * unit price). 
>> Pretty simple using a datasource but I've no idea how to do that with 
>> bindings (using an NSArrayController).
> 
> Well, that's the problem right there. You seem to think bindings have 
> something to do with array controllers. They don't. (Bindings and array 
> controllers are often used together, of course, both on the "content" side of 
> the array controller and on the "arrangedObjects" side, but that's just a 
> case of two things being used to complement each other.)
> 
> When working with bindings, it helps to be very diligent in thinking in terms 
> of properties.
> 
> If you're supplying a table view's cells via bindings, then you must have a 
> model property for *each* column. In your case, your data model is (or 
> includes) an array property (say, "invoiceItems"), whose elements are objects 
> (of class, say, "InvoiceItem") with properties "quantity", "unitPrice" and 
> "totalPrice". 
> 
> If the total is always calculated from the other two properties, it is 
> typically a "derived" property (one whose value is derived on the fly, rather 
> than actually stored), but aside from that implementation detail, there's no 
> difference in how you use the properties to populate your table.
> 
> In code terms, the short answer to your question is:
> 
>>  + (NSSet) keyPathsForValuesAffectingTotalPrice {
>>  return [NSSet setWithObjects: @"quantity", @"unitPrice", nil];
>>  }
>> 
>>  - (NSInteger) totalPrice { // or whatever the correct data type is
>>  return self.quantity * self.unitPrice;
>>  }
> 
> The second method provides the derived property value. The first method 
> provides KVO compliance.
> 
> So how does the array controller enter this picture at all? It's a glue 
> object (aka "mediating controller") whose function is to sort and filter the 
> model array property. It has no role in sourcing actual data to your table***.
> 
> 
> 
> *** It's certainly possible to *give* it a role, but I would argue that this 
> is a terrible idea.
> 
> 

___

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: Calculations in a tableview

2011-07-28 Thread Quincey Morris
On Jul 28, 2011, at 20:00, Andre Masse wrote:

> Is this can be done using bindings or should I stop fighting the framework 
> and and use a datasource?

It can be done with bindings***. All you've done is clarified that "totalPrice" 
isn't a derived property after all. So, you make a regular property (with 
getter and setter), and initialize the instance variable that backs it to the 
default value (items * price).

Or, you can initialize the instance variable to a "not set" value (like 0 or 
NSNotFound, or something), but then you won't be able to just @synthesize the 
property -- you'll have to write code to return either the default or the 
explicit value, depending on the contents of the instance variable. (Or, you 
can have a BOOL instance variable that says whether the default has been 
overridden, but in that case you'll have to add code to the setter instead.)

And, incidentally, what you are trying to do is in no way "fighting" the 
framework. You're doing exactly what you're supposed to be doing. :)




*** Again, focus your thinking on *properties*. Ask yourself what properties 
your data model needs to support the user interaction, and it should become 
immediately clear what to do. Bindings are a way of hooking up (in this case) 
your UI to your data model's properties. They don't replace the data model 
design part of the process.


___

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


didReceivePTPEvent is not triggered with Canon T2i

2011-07-28 Thread Francis Lessard
I am trying to create an application that allows a user to take a picture from 
a camera device. I am usingImageCaptureCore.framework to do this by using the 
requestTakePicture method, and I've set a delegate to catch the 
didReceivePTPEvent message to tell me when the capture is complete.

If I try with my Canon PowerShot A80, didReceivePTPEvent is triggered, but when 
I use a Canon EOS Rebel T2i or any other professional camera device, 
didReceivePTPEvent is not triggered.

Does anyone know why didReceivePTPEvent is not triggered on some cameras?

Thanks for your help.___

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


MPMoviePlayerController Fast forward

2011-07-28 Thread Steve Kostrey
I've implemented MPMoviePlayerController (iPhone/iPad) and I'm playing videos 
without trouble but I'm not sure how to receive an event from the Fast forward 
overlay button.
I've tried everything the documentation suggests about remote control but I'm 
not sure that's the way.

I've tried the following code:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

- (BOOL)canBecomeFirstResponder {
  return YES; 
}

- (void)remoteControlReceivedWithEvent:(UIEvent *)event {

  if( event.type == UIEventTypeRemoteControl ) {
  NSLog(@"sub type: %d", event.subtype);
  }
}

Not sure where to place this (and when I place it in the header I get 
redefinition errors):

typedef enum {
  // available in iPhone OS 3.0
  UIEventSubtypeNone  = 0,

  // for UIEventTypeMotion, available in iPhone OS 3.0
  UIEventSubtypeMotionShake   = 1,

  // for UIEventTypeRemoteControl, available in iPhone OS 4.0
  UIEventSubtypeRemoteControlPlay = 100,
  UIEventSubtypeRemoteControlPause= 101,
  UIEventSubtypeRemoteControlStop = 102,
  UIEventSubtypeRemoteControlTogglePlayPause  = 103,
  UIEventSubtypeRemoteControlNextTrack= 104,
  UIEventSubtypeRemoteControlPreviousTrack= 105,
  UIEventSubtypeRemoteControlBeginSeekingBackward = 106,
  UIEventSubtypeRemoteControlEndSeekingBackward   = 107,
  UIEventSubtypeRemoteControlBeginSeekingForward  = 108,
  UIEventSubtypeRemoteControlEndSeekingForward= 109,
} UIEventSubtype;


Bottom line is I would love to receive the FF event. Has anyone successfully 
done this?



___

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: drawRect not getting called problem solved

2011-07-28 Thread Preston Sumner

On Jul 28, 2011, at 6:31 PM, Tom Jeffries wrote:

> I appreciate all the comments on the problem I had with drawRect not
> getting called.  I finally extracted the code that was not working and
> put it in a new program, and it worked perfectly.  I'm still not sure
> whether there was a problem in my code or if I unearthed a problem in
> Cocoa, but I'm now adding the rest of the original program to the new
> program, and the graphics are working.

I can't help but doubt it was a Cocoa bug. You admitted previously that you 
were new to OS X programming, and that is the most likely cause of the problem, 
I'm afraid.

> I understand that people who program in only one environment want to
> see code that matches the way they learned to program.  That causes
> problems for those of us who work in multiple environments, some of
> which have a whole different set of "rules".  However, maybe it's a
> sign that software development is still at an early stage that some
> environments insist on Data and others insist on data.  I do think
> it's important to keep in mind the difference between code and data,
> and some of the suggestions I got seemed to show some lack of clarity
> in that area. Confusing the two may work in certain specific
> environments, but it reflects a misunderstanding of the way computers
> actually work.  I think it's important to have an awareness of the
> difference.
> 
> Thanks again for your help.

With all due respect, assuming that those expecting a convention for a given 
environment must only be proficient in that environment is presumptive and a 
little rude. Conventions convey information. As you witnessed, it was difficult 
for people to understand what precisely your code was doing because you were 
violating several conventions that convey to the reader events that are 
occurring, like whether or not you're calling a method of a class or an 
instance of a class. That was important important in attempting to diagnose 
your problem.

Someone who works in multiple environments should be experienced enough to be 
more acutely aware of the usefulness of such conventions, especially when 
communicating with others. Attempting to shoehorn one's personal style across 
environments will only confuse those more experienced in each who are looking 
at your code.

The conversation that your "confusion" comment is in response to actually 
illustrated some major confusions on your part about sending messages to object 
references (the C pointer "myString" that you didn't consider to be a 
variable), the difference between a C function and an Objective-C method, and 
other object-oriented concepts the language is based on that are, I think, 
unnecessarily frustrating you.

Apple has an excellent Objective-C primer in their documentation:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html

Preston___

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


UIImageView subclasses

2011-07-28 Thread William Squires
Hi all!
  Here's what I've got: (Xcode 3.2.5 - iOS SDK 4)

A view controller that dynamically creates UIImageView subclass instances as 
subviews in it's awakeFromNib

According to the documentation, UIImageView subclasses do not enable user 
interaction by default, so

...
// Create a UIImageView that'll animate Number1.png through Number8.png, and 
load Number.png as the
// default (non-aminating) image
MyImageView *iv = [[MyImageView alloc] initWithBaseName:@"Number"];
[iv setUserInteractionEnabled:YES];
// ...
// Don't know what to do here!
// ...
[self.view addSubview:iv];
...

Okay, now what? How do I connect the "Touch Up Inside" of the UIImageView 
(subclass instance) to the

-(IBAction)customButtonTouched:(id)sender;

method of my view controller (the one that created the UIImageView subclass 
instances as subviews)

2nd question: how can I get first crack at the "Touch Up Inside" event (in the 
UIImageView subclass) before I pass it on to my view controller?

___

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

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

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

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


Re: UIImageView subclasses

2011-07-28 Thread Graham Cox

On 29/07/2011, at 3:24 PM, William Squires wrote:

> Okay, now what? How do I connect the "Touch Up Inside" of the UIImageView 
> (subclass instance) to the
> 
> -(IBAction)customButtonTouched:(id)sender;
> 
> method of my view controller (the one that created the UIImageView subclass 
> instances as subviews)
> 
> 2nd question: how can I get first crack at the "Touch Up Inside" event (in 
> the UIImageView subclass) before I pass it on to my view controller?


In both cases, override the method -touchesEnded:withEvent: and do what you 
want there. Alternatively, attach a UIGestureRecognizer and sets its delegate 
to the view - then that delegate method can do what it needs to do, including 
calling the controller to do its part. You might need to add an ivar (or 
property) for the controller if it's not next responder - I don't see that 
UIView has a reference automatically to its controller.

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

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


Drawing performance in CALayer

2011-07-28 Thread Graham Cox
In my iTunes visualizer, I'm using layers to draw many, many small rectangles 
(to represent segments of a spectrum analyser display). There can be up to 32 
bands x 40 segments x 2 channels = 2,560 segments, all redrawn 30 times per 
second or more.

One layer is used for one bar, which is 40 rectangles. In my override of 
-drawInContext: I draw these using NSRectFill() in a loop.

Am I right in thinking that using calls such as NSRectFill within a CALayer 
like this is really making OpenGL calls behind the scenes? If so it's probably 
going as fast as it can. On my middling iMac it's acceptably fast, but laptops 
start to show a bit of a slow-down.

I can think of ways to optimise this, but first I want to know whether this is 
truly the fastest way to draw a simple solid rectangle in this situation. If 
not, what's better?

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

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


Why Don't Cocoa's (Un)Archiving Methods return Errors?

2011-07-28 Thread Jerry Krinock
With each major update of Mac OS X, Apple updates more classes to return proper 
NSErrors, deprecating methods which either don't give errors or give outmoded 
error representations.

But what about NSKeyedArchiver and NSKeyedUnarchiver, in particular these 
methods…

+[NSKeyedArchiver archivedDataWithRootObject:]
+[NSKeyedUnarchiver unarchiveObjectWithFile:]

-unarchiveObjectWithFile: takes a file, for heaven's sake.  If someone has 
messed with the file, eek, it raises an exception.  I generally enclose these 
methods in @try{} to avoid that.  Very primitive!

Does anyone know why these methods not marked for deprecation?  Is there a 
reason why we don't we have 21st-century archive/unarchive methods that return 
errors instead of raise exceptions?

Thank you,

Jerry Krinock

___

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


What could cause a fast enumeration mutation error in updating tracking areas?

2011-07-28 Thread Gideon King
Hi, I have a problem where a few users of my program are getting the following 
exception:

0 CoreFoundation 0x7fff862df7b4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x7fff84b0ff03 objc_exception_throw + 45
2 CoreFoundation 0x7fff863375bf __NSFastEnumerationMutationHandler + 303
3 AppKit 0x7fff83ec8660 -[NSView trackingAreas] + 271
4 AppKit 0x7fff83f1d025 -[NSView(NSInternal) _updateTrackingAreas] + 249
5 CoreFoundation 0x7fff86259d6e CFArrayApplyFunction + 222
6 AppKit 0x7fff83f1d413 -[NSView(NSInternal) _updateTrackingAreas] + 1255
7 CoreFoundation 0x7fff86259d6e CFArrayApplyFunction + 222
8 AppKit 0x7fff83f1d413 -[NSView(NSInternal) _updateTrackingAreas] + 1255
9 CoreFoundation 0x7fff86259d6e CFArrayApplyFunction + 222
10 AppKit 0x7fff83f1d413 -[NSView(NSInternal) _updateTrackingAreas] + 1255
11 CoreFoundation 0x7fff86259d6e CFArrayApplyFunction + 222
12 AppKit 0x7fff83f1d413 -[NSView(NSInternal) _updateTrackingAreas] + 1255
13 CoreFoundation 0x7fff86259d6e CFArrayApplyFunction + 222
14 AppKit 0x7fff83f1d413 -[NSView(NSInternal) _updateTrackingAreas] + 1255
15 CoreFoundation 0x7fff86259d6e CFArrayApplyFunction + 222
16 AppKit 0x7fff83f1d413 -[NSView(NSInternal) _updateTrackingAreas] + 1255
17 CoreFoundation 0x7fff86259d6e CFArrayApplyFunction + 222
18 AppKit 0x7fff83f1d413 -[NSView(NSInternal) _updateTrackingAreas] + 1255
19 AppKit 0x7fff83f1ce28 _handleInvalidCursorRectsNote + 451
20 CoreFoundation 0x7fff8629eb37 __CFRunLoopDoObservers + 519
21 CoreFoundation 0x7fff8627a464 __CFRunLoopRun + 468
22 CoreFoundation 0x7fff86279dbf CFRunLoopRunSpecific + 575
23 HIToolbox 0x7fff854f774e RunCurrentEventLoopInMode + 333
24 HIToolbox 0x7fff854f7553 ReceiveNextEventCommon + 310
25 HIToolbox 0x7fff854f740c BlockUntilNextEventMatchingListInMode + 59
26 AppKit 0x7fff83ef1eb2 _DPSNextEvent + 708
27 AppKit 0x7fff83ef1801 -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] + 155
28 AppKit 0x7fff83eb768f -[NSApplication run] + 395
29 OmniAppKit 0x00010055c774 -[OAApplication run] + 132
30 AppKit 0x7fff83eb03b0 NSApplicationMain + 364
31 NovaMind5 0x00012018 start + 52
32 ??? 0x0002 0x0 + 2


But all the tracking areas I am adding are done in the initialization of the 
views or awakeFromNib, and not updated after that. I do use tracking rects and 
tooltip rects, and wonder whether they use tracking areas behind the scenes, 
and whether there are specific places in the code I need to avoid changing 
them. 

I haven't been able to reproduce the problem here, so can't catch it in the act 
so far.

Any suggestions as to what to look for?

Thanks

Gideon




___

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: Lion doesn't like tricky.key.paths in bindings?

2011-07-28 Thread Jerry Krinock

On 2011 Jul 28, at 19:42, Kyle Sluder wrote:

> KVO doesn't do an -isEqual: on the result of your method. It does
> pointer equality. Something changed on Lion that causes it to now care
> that the return value of your method stays constant when it should.

Thank you, Kyle.  For a while I thought it was "just me".

> If you want to use a transformer-type method, you implement
> +keyPathsForValuesAffecting<>

Yes, that's what I've done.  Less fuss than value transformers, unless you can 
re-use them.


___

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

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

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

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