Re: How to access iTunes using cocoa

2010-01-26 Thread has
Michael Ash wrote:

>>> I think a big hit comes from the time it takes to evaluate Apple event
>>> object specifiers. [...]
>> 
>> Complex AE object queries have the same benefit that SQL queries do: they
>> let the data source perform an efficient search. [...]
> 
> Would this actually matter in reality, though?
> 
> A quick experiment (on my 2006 Mac Pro) indicates that CFMessagePort
> has a round-trip latency of roughly 100us, and with 1MB messages can
> transfer about 500MB/sec.
> 
> On a more emperical level, some apps use Distributed Objects as an
> AppleScript alternative, and the first thing you notice when going
> from an AppleScript-based technique to a DO-based technique is that DO
> is way, way faster.

DO uses pointers, not queries, so that wouldn't surprise me, given that the AE 
bottleneck nowadays is query evaluation, not message passing. And there are 
other ways to achieve query-driven efficiencies in that sort of environment - 
e.g. F-Script's array-oriented programming model comes to mind.

Mind you, DO comes with its own set of problems, most of which step from its 
pretense that remote objects can be treated like local objects, so I'd be very 
leery of promoting it as the solution to AE's shortcomings:


http://jens.mooseyard.com/2009/07/the-subtle-dangers-of-distributed-objects/

It may be the answer lies somewhere in-between: an explicit network messaging 
API with the ability to perform [read-only?] queries, but which mostly uses 
safe pointer and one-message-one-object semantics for simplicity, speed and 
safety. Some sort of session/transaction management would be nice too (to avoid 
multiple clients manipulating objects at the same time). And no more 
four-char-codes, of course.

Regards,

has
-- 
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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: Ellipsis + Proper Expansion Frame + HScroll-Edit in 10.6 NSTableView (was "Clipped Tooltip")

2010-01-26 Thread Jerry Krinock

On 2010 Jan 26, at 10:07, Corbin Dunn wrote:

> Look up "expansion tool tips".

Thanks!

> For what it is worth, using a normal NSTexTFieldCell should always work -- 
> there is possibly something wrong with the way you have it setup (like 
> allowing wrapping, or something). 

Yes and no.  The value of -wraps is what counts, but I didn't do it.  (That's 
why I made the demo project.)  Out of the box, [[NSTextFieldCell alloc] init] 
has -wraps = YES.  This works fine in Mac OS 10.5, but in Mac OS 10.6, it 
causes the expansion frame to not bound its text (which yesterday I called 
"clipped").

The NSTextFieldCell returned by -[NSTableColumn dataCell] has -wraps = NO.  
That's why it works.

However, setting wraps:NO causes the ellipsis to not appear in the normal 
drawing, and/or causes the text to not scroll to the left when you bump into 
the right edge while editing.

Now, let me summarize -- I have three requirements:

1.  Properly-drawn expansion frame.
2.  Ellipsis appears when text overflows during normal drawing.
3.  When editing, text should scroll left when you bump into the right edge.

I considered three attributes of NSCell:

-wraps
-scrollable
-truncatesLastVisibleLine

Setting these to all eight possibilities (some are not allowed, since setWraps: 
sometimes affects -scrollable and vice versa), I found that there is no 
combination which satisfies all three requirements.

So then I tried overriding three methods:

drawWithFrame:inView:
drawWithExpansionFrame:inView:
editWithFrame:inView:editor:delegate:event:

so that I could change the values of the three attributes before.  But I am 
still unable to find the magic formula.

However, I know there is a magic formula somewhere, because when I use the 
default cell returned by -[NSTableColumn dataCell], all three requirements are 
satisfied.  Statically, I see that it sets all three attributes to NO.  But 
when I try this with a raw NSTextFieldCell, only requirement 1 is satisfied.

Maybe there is another attribute involved -- NSCell has several dozen more.  
Anybody got a good guess?

___

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: Change background color of UITabBarItem and UITabBar

2010-01-26 Thread Angelica Grace Tanchico

Hi Greg,

Thanks for this information. It did change the color of the TabBar.
But the other question is still unanswered. Is it possible to change
the TabBarItem's image colors? Instead of default gray (when not selected) 
and blue (when selected)? How?

Thanks! Really appreciate it! 


Regards,
Angie



> Is it possible to change color of UITabBar instead of the default color black?
> And also is it possible to change background color of UITabBarItem's 
> background
> color instead of default color blue? If yes, how?
 
There is no API for changing the UITabBar.  Yet, you can subclass the 
TabBarController and override the viewDidLoad method.  For example,
 
@interface UITabBarController (private)
- (UITabBar *)tabBar;
@end
 
@implementation CustomUITabBarController
 
- (void)viewDidLoad {
[super viewDidLoad];

CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48);
UIView *v = [[UIView alloc] initWithFrame:frame];
[v setBackgroundColor:[UIColor redColor]];
[v setAlpha:0.5];
[[self tabBar] addSubview:v];
[v release];
}
 
@end
 
This would set a red tint to the tab bar.  Check on stackoverflow.com for many 
more examples.  Keep in mind the above example modifies the tabBar of the 
controller, which is specifically mentioned in the documentation not to mess 
with.  So, use at your own risk. 
 
Greg
 
  
_
Hotmail: Free, trusted and rich email service.
https://signup.live.com/signup.aspx?id=60969___

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: Global in NSApplication

2010-01-26 Thread Graham Cox

On 27/01/2010, at 4:43 PM, BareFeet wrote:

> I just wanted to check if there's a simpler way. I guess not.


The singleton pattern Jens suggested is simpler. I can't think of any simpler 
way:

+ (Debug*)  sharedDebug
{
static Debug* s_debug = nil;

if( s_debug == nil )
s_debug = [[self alloc] init];

return s_debug;
}


Then whenever you need the debug object, just call:

[Debug sharedDebug];

The first time it's needed it will be created.

--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: Global in NSApplication

2010-01-26 Thread BareFeet
Yes, I'm familiar with categories, but didn't mention it because it's  
so similar to subclassing.


I just wanted to check if there's a simpler way. I guess not.

Thanks,
Tom
BareFeet
Sent from my iPhone

On 27/01/2010, at 1:17 PM, Murat Konar  wrote:

Read up on categories. Then make the instance of your Debug class a  
static variable in your category implementation file, and use a  
method you added to NSApplication via your category to return it.




_murat


On Jan 26, 2010, at 6:05 PM, BareFeet wrote:


Hi all,

I've created a "Debug" class in my app, which contains an instance  
variable and several methods. I want to add this to my application  
but can't see how.


I can add it to MyDocument class like this:

- (id)init
{
 self = [super init];
 if (self) {
  // other stuff
 debug = [Debug new];
 }
 return self;
}

- (void) dealloc
{
  // other stuff
  [debug release];
  [super dealloc];
}

But I want a global instance for the application as a whole. How do  
I do this? Do I have to subclass NSApplication just to create a  
global variable?


I want to be able to call it from any class in my app, such as:

[[NSApp debug] myMethod];

Please reply to the list.

Thanks,
Tom
BareFeet

--
Comparison of SQLite GUI tools:
http://www.tandb.com.au/sqlite/compare/?ml


___

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: What is the equivalent of SetSystemUIMode() in Leopard and above?

2010-01-26 Thread Charles Srstka
On Jan 26, 2010, at 10:39 PM, Jesper Storm Bache wrote:

> I don't have the entire thread on this machine so I apologize if I am 
> repeating someone else.
> 
> When you are ready do say "10.6 and above", then you can consider using
>   [NSApplication setPresentationOptions]
> In the meantime SetSystemUIMode works well in both 32 and 64 bit binaries.
> 
> Jesper Storm Bache

Or you could just do something like this:

if(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5)
{
[NSApp setPresentationOptions:whatever];
}
else
{
SetSystemUIMode(whatever);
}

You could also use if([NSApp 
respondsToSelector:@selector(setPresentationOptions:)) if you prefer. I like to 
explicitly test for the version number though, so that once I *am* ready to say 
“10.6 and above”, it’s easy to search for and remove all the compatibility 
cruft that’s in there to make older versions work.

Charles___

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

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

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

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


Re: Context menu on NSOutlineView, which row is active/selected?

2010-01-26 Thread Kyle Sluder
On Tue, Jan 26, 2010 at 9:09 PM, David Melgar  wrote:
> How should I determine the row that the right click occurred on?

Take a look at -[NSTableView clickedRow]. Remember to look at the superclass.

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


Context menu on NSOutlineView, which row is active/selected?

2010-01-26 Thread David Melgar
I have a menu set as the Menu outlet of an NSOutlineView to use as a context 
menu (right click) on a row.

When the menu is chosen on a row, the chosen action on my target (my 
OutlineView controller) is invoked as expected.

In my view controller, I had been assuming that the row the right click 
occurred would show up as a selected row. But it does not always. It appears to 
be a separate state.

How should I determine the row that the right click occurred on?

This is 10.6.2 BTW.

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: Global in NSApplication

2010-01-26 Thread Jens Alfke
Even easier, use the Singleton design pattern and implement a  
+sharedInstance class method in your class. This is how existing  
singletons like NSFileManager work.


--Jens   {via iPhone}


On Jan 26, 2010, at 6:17 PM, Murat Konar  wrote:

Read up on categories. Then make the instance of your Debug class a  
static variable in your category implementation file, and use a  
method you added to NSApplication via your category to return it.




_murat


On Jan 26, 2010, at 6:05 PM, BareFeet wrote:


Hi all,

I've created a "Debug" class in my app, which contains an instance  
variable and several methods. I want to add this to my application  
but can't see how.


I can add it to MyDocument class like this:

- (id)init
{
  self = [super init];
  if (self) {
   // other stuff
  debug = [Debug new];
  }
  return self;
}

- (void) dealloc
{
   // other stuff
   [debug release];
   [super dealloc];
}

But I want a global instance for the application as a whole. How do  
I do this? Do I have to subclass NSApplication just to create a  
global variable?


I want to be able to call it from any class in my app, such as:

[[NSApp debug] myMethod];

Please reply to the list.

Thanks,
Tom
BareFeet

--
Comparison of SQLite GUI tools:
http://www.tandb.com.au/sqlite/compare/?ml

___

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/murat%40pixar.com

This email sent to mu...@pixar.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/jens%40mooseyard.com

This email sent to j...@mooseyard.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: What is the equivalent of SetSystemUIMode() in Leopard and above?

2010-01-26 Thread Jesper Storm Bache
I don't have the entire thread on this machine so I apologize if I am repeating 
someone else.

When you are ready do say "10.6 and above", then you can consider using
[NSApplication setPresentationOptions]
In the meantime SetSystemUIMode works well in both 32 and 64 bit binaries.

Jesper Storm Bache

On Jan 26, 2010, at 8:13 PM, Kiel Gillard wrote:

> On 27/01/2010, at 3:03 PM, Arun wrote:
> 
>> I wanted to use SetSystemUIMode() to hide the dock item and menu of my
>> application. Do you know how can we achieve using the same?
> 
> Please see the LSBackgroundOnly Info.plist key:
> 
> 
> Kiel
> 
>> On Wed, Jan 27, 2010 at 2:04 AM, Sean McBride wrote:
>> 
>>> On 1/25/10 5:17 PM, Arun said:
>>> 
 Are there any cocoa equivalent API's for SetSystemUIMode() available in
 Leopard 10.5 and above?
 I want to hide dock and menu item at run time in my application.
>>> 
>>> SetSystemUIMode works well for me in 10.5 and above.  Is it causing
>>> problems for you?
>>> 
>>> --
>>> 
>>> Sean McBride, B. Eng s...@rogue-research.com
>>> Rogue Researchwww.rogue-research.com
>>> Mac Software Developer  Montréal, Québec, Canada
>>> 
>>> 
>>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/kiel.gillard%40gmail.com
>> 
>> This email sent to kiel.gill...@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/jsbache%40adobe.com
> 
> This email sent to jsba...@adobe.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: What is the equivalent of SetSystemUIMode() in Leopard and above?

2010-01-26 Thread Kiel Gillard
On 27/01/2010, at 3:03 PM, Arun wrote:

> I wanted to use SetSystemUIMode() to hide the dock item and menu of my
> application. Do you know how can we achieve using the same?

Please see the LSBackgroundOnly Info.plist key:


Kiel

> On Wed, Jan 27, 2010 at 2:04 AM, Sean McBride wrote:
> 
>> On 1/25/10 5:17 PM, Arun said:
>> 
>>> Are there any cocoa equivalent API's for SetSystemUIMode() available in
>>> Leopard 10.5 and above?
>>> I want to hide dock and menu item at run time in my application.
>> 
>> SetSystemUIMode works well for me in 10.5 and above.  Is it causing
>> problems for you?
>> 
>> --
>> 
>> Sean McBride, B. Eng s...@rogue-research.com
>> Rogue Researchwww.rogue-research.com
>> Mac Software Developer  Montréal, Québec, Canada
>> 
>> 
>> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/kiel.gillard%40gmail.com
> 
> This email sent to kiel.gill...@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: What is the equivalent of SetSystemUIMode() in Leopard and above?

2010-01-26 Thread Arun
I wanted to use SetSystemUIMode() to hide the dock item and menu of my
application. Do you know how can we achieve using the same?

On Wed, Jan 27, 2010 at 2:04 AM, Sean McBride wrote:

> On 1/25/10 5:17 PM, Arun said:
>
> >Are there any cocoa equivalent API's for SetSystemUIMode() available in
> >Leopard 10.5 and above?
> >I want to hide dock and menu item at run time in my application.
>
> SetSystemUIMode works well for me in 10.5 and above.  Is it causing
> problems for you?
>
> --
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com
> Mac Software Developer  Montréal, Québec, Canada
>
>
>
___

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

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

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

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


Re: Launch process as root from cocoa app

2010-01-26 Thread Charles Srstka
On Jan 25, 2010, at 9:18 PM, Nick Zitzmann wrote:

> 
> On Jan 25, 2010, at 12:57 AM, Nyxem wrote:
> 
>> 1 - Using the authorizationRef object of my SFAuthorizationView and call 
>> AuthorizationExecuteWithPrivileges() ("/bin/launchctl load 
>> /Library/LaunchDaemons/com.mydaemon.plist")
>>  --> Failed. daemon not launched as root, but as current user.
> 
> As you've figured out, AEWP() launches apps with root privileges, but it 
> doesn't run them _as_ root. If you need to launch an app as root for whatever 
> reason via AEWP(), then search the archives for a workaround, because I'm 
> pretty sure I've posted at least one workaround for this years ago...
> 
> Nick Zitzmann
> 

It launches the process with an *effective* UID of root. You should be able to 
make it run as root by using the setuid() function.

However, a better way to go would probably be to use the BetterAuthSample code.

Charles___

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

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

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

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


Re: Global in NSApplication

2010-01-26 Thread Murat Konar
Read up on categories. Then make the instance of your Debug class a  
static variable in your category implementation file, and use a method  
you added to NSApplication via your category to return it.




_murat


On Jan 26, 2010, at 6:05 PM, BareFeet wrote:


Hi all,

I've created a "Debug" class in my app, which contains an instance  
variable and several methods. I want to add this to my application  
but can't see how.


I can add it to MyDocument class like this:

- (id)init
{
   self = [super init];
   if (self) {
// other stuff
debug = [Debug new];
   }
   return self;
}

- (void) dealloc
{
// other stuff
[debug release];
[super dealloc];
}

But I want a global instance for the application as a whole. How do  
I do this? Do I have to subclass NSApplication just to create a  
global variable?


I want to be able to call it from any class in my app, such as:

[[NSApp debug] myMethod];

Please reply to the list.

Thanks,
Tom
BareFeet

--
Comparison of SQLite GUI tools:
http://www.tandb.com.au/sqlite/compare/?ml

___

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/murat%40pixar.com

This email sent to mu...@pixar.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


Global in NSApplication

2010-01-26 Thread BareFeet
Hi all,

I've created a "Debug" class in my app, which contains an instance variable and 
several methods. I want to add this to my application but can't see how.

I can add it to MyDocument class like this:

- (id)init
{
self = [super init];
if (self) {
// other stuff
debug = [Debug new];
}
return self;
}

- (void) dealloc
{
// other stuff
[debug release];
[super dealloc];
}

But I want a global instance for the application as a whole. How do I do this? 
Do I have to subclass NSApplication just to create a global variable?

I want to be able to call it from any class in my app, such as:

[[NSApp debug] myMethod];

Please reply to the list.

Thanks,
Tom
BareFeet

 --
Comparison of SQLite GUI tools:
http://www.tandb.com.au/sqlite/compare/?ml

___

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: How to access iTunes using cocoa

2010-01-26 Thread Michael Ash
On Tue, Jan 26, 2010 at 3:57 PM, Jens Alfke  wrote:
>
> On Jan 26, 2010, at 12:45 PM, has wrote:
>
>> I think a big hit comes from the time it takes to evaluate Apple event
>> object specifiers. The cost-benefit tradeoff of having a complex,
>> query-driven IPC system is much poorer on OS X, both in terms of performance
>> and ease of implementation (one of the reason so many apps have lousy AE
>> interfaces is because they're so damn hard to implement). The main
>> bottleneck on OS 7-9 was the OS-level messaging system; in OS X, it's
>> evaluating those complicated messages in the target application process.
>
> Complex AE object queries have the same benefit that SQL queries do: they
> let the data source perform an efficient search. No one would claim that
> MySQL's bottleneck is SQL parsing, or that it would be faster to let clients
> just iterate over table rows one by one! iTunes may not have as much data in
> it as a big database, bit it's still expensive to iterate over 10,000 tracks
> via IPC. It would be even worse for scripting the Finder, which operates on
> orders of magnitude more objects.

Would this actually matter in reality, though?

A quick experiment (on my 2006 Mac Pro) indicates that CFMessagePort
has a round-trip latency of roughly 100us, and with 1MB messages can
transfer about 500MB/sec.

On a more emperical level, some apps use Distributed Objects as an
AppleScript alternative, and the first thing you notice when going
from an AppleScript-based technique to a DO-based technique is that DO
is way, way faster.

There's certainly some theoretical niceness to the idea of being able
to send over a complex query and have the search be performed within
the app that already has the data, rather than simply making requests
and having to transfer all the data across before searching it. But on
a practical level, with Apple Events, the breakeven point seems to be
a quantity of data beyond what you'll find on most Macs.

Mike
___

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


AppleEvent memory leak

2010-01-26 Thread Rainer Standke

Hello,

I have an app that sends and receives AppleEvents to and from Final  
Cut Pro. The AppleEvent part of my code is closely modeled after the  
sample code provided by Apple. Really: I barely modified the code.  
When I look at Leaks I am told that for each transaction (sending or  
receiving an AE) a little memory is leaked, about 400 bytes each. The  
leaks seem to happen fairly deep in the framework, not in my own code.


How should I deal with this?

Thanks,

Rainer
___

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: Garbage Collection Docs Puzzle

2010-01-26 Thread John Engelhart
On Tue, Jan 26, 2010 at 4:51 PM, Sean McBride wrote:

> On 1/25/10 4:49 PM, Robert Clair said:
>
> >The garbage collection docs section on the interior pointer issue shows
> >this example:
> >
> >NSData *myData = [someObject getMyData];
> >[myData retain];
> >const uint8_t *bytes = [myData bytes];
> >NSUInteger offset = 0, length = [myData length];
> >
> >while (offset < length) {
> >  // bytes remains valid until next message sent to myData
> >}
> >[myData release];
>
> My favourite solution is this one:
> 
>
> It's been working well for me.


I've gone the 'volatile' route:

NSData * volatile myData = [someObject getMyData];
// [myData retain];  Removed, no need w/ volatile.
const uint8_t *bytes = [myData bytes];
NSUInteger offset = 0, length = [myData length];

while (offset < length) {
  // bytes remains valid until next message sent to myData
}
// [myData release]; Removed, no need w/ volatile.
___

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: Need help figuring out poor Core Data performance

2010-01-26 Thread Sean McBride
On 1/26/10 12:15 PM, Eyal Redler said:

>I'm working on a NSPersistentDocument based application. My data model
>is quite simple, the main entity contains a few strings, ints and
>dates and there is an array (one to many relationship) of another
>simple entity.
>The document window contains an NSTableView that displays all the main
>entities (using an NSArrayController)
>Everything seems to be working ok except that when I open a large
>document (20k records) for the first time in a session (after a
>restart), it takes a few minutes of spinning wheel for the data to
>show. If I close the document and then re-open I usually get an
>instant response. The format is sqlite.
>Following is an Activity Monitor sample taken during this long
>process. I also tried to monitor this using Instruments and saw
>nothing interesting - only one fetch.
>I'm really stuck with this, I would appreciate any ideas or pointers...

Instrument.app has features specifically for Core Data-related
performance measurements.  I've never used them seriously, so can't
really comment further.  Also, note that the Instruments docs have not
been updated for 10.6 (still! :() so that complicates learning.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

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


Re: NSString category name collision?

2010-01-26 Thread Greg Parker
On Jan 26, 2010, at 3:19 PM, Sean McBride wrote:
> On 1/26/10 4:08 PM, jonat...@mugginsoft.com said:
>> I added a name space prefix to my method definition and the exception
>> departed.
> 
> You can add the following env var to debug these problems btw:
> OBJC_PRINT_REPLACED_METHODS.

Use OBJC_PRINT_REPLACED_METHODS=YES. Some versions of the runtime ignore any 
value other than YES.


-- 
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: NSString category name collision?

2010-01-26 Thread Sean McBride
On 1/26/10 4:08 PM, jonat...@mugginsoft.com said:

>The docs say:
>
>A category cannot reliably override methods declared in another category
>of the same class.
>This issue is of particular significance since many of the Cocoa classes
>are implemented using categories.
>A framework-defined method you try to override may itself have been
>implemented in a category, and so which implementation takes precedence
>is not defined.
>
>Is this just one of the things we have to put up with as the price for
>dynamism or can this problem be pre-empted?

Yes.

>I added a name space prefix to my method definition and the exception
>departed.

You can add the following env var to debug these problems btw:
OBJC_PRINT_REPLACED_METHODS.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

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


Re: simple cocoa browser, 'Invalid parameter not satisfying: aString != nil'

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 2:43 PM, Ariel Feinerman wrote:

it`s interesting, but do you think what it will be better solution  
to use NSOpenPanel to change file`s attributes instead of NSBrowser?


NSOpenPanel.

—Jens___

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

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

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

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


Re: Problems Fading Out Music

2010-01-26 Thread Chunk 1978
sorry, you're correct.  i had an error in the code so it was wrongly
implemented.  it does indeed work with negative values.  thanks again.

On Tue, Jan 26, 2010 at 5:35 PM, Graham Cox  wrote:
>
> On 27/01/2010, at 9:24 AM, Graham Cox wrote:
>
>>
>> On 27/01/2010, at 9:18 AM, Chunk 1978 wrote:
>>
>>> i just realized that this formula doesn't work with negative numbers.
>>> for example:  shifting a pitch down one octave over a duration from
>>> 0.0 to -0.5, or panning a source with a duration from center at 0.0 to
>>> the left -1.0.
>>>
>>> any advice?
>>
>>
>> Yes it does. You must have made a mistake implementing it.
>
>
> I just realised why you think it doesn't. It's not the DURATION that needs to 
> be negative, it's the values. Time only ever progresses in one direction, as 
> far as we know, therefore the time values are always +ve. The value may 
> freely be negative, which after all is what you are controlling.
>
> --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: Debugging auto_zone_resurrection_error in Core Data using GCD

2010-01-26 Thread Benjamin Rister
Because this isn’t already thorny enough, let me note that adding a [startDate 
self] below the dispatch_sync in the first example doesn’t fix the problem. 
This shows that it’s surviving long enough to at least reach the 
dispatch_sync() call, and in fact malloc_history shows this:

> ALLOC 0x200028960-0x20002896f [size=16]: thread_102787000 |thread_start | 
> _pthread_start | __NSThread__main__ | -[MyThread main] | 
> -[__NSOperationInternal start] | -[MyOperation main] | +[NSDate date] | 
> +[__NSCFDate __new:] | __CFAllocateObject | 
> _internal_class_createInstanceFromZone | auto_zone_allocate_object 
> 
> FREE  0x200028960-0x20002896f [size=16]: thread_102787000 |thread_start | 
> _pthread_start | __NSThread__main__ | -[MyThread main] | 
> -[__NSOperationInternal start] | objc_collect | auto_collect | 
> Auto::ThreadLocalCollector::collect(bool) | 
> Auto::ThreadLocalCollector::process_local_garbage(bool) | 
> Auto::ThreadLocalCollector::scavenge_local(unsigned long, unsigned long*) 

In other words, it’s being collected after -main has returned, as part of 
-[NSOperation start]’s cleanup.

Also new interesting data is that even in the -doThatThingTo:attachValue: 
instances, the resurrected garbage pointer is still an NSDate from the *other* 
example. So it seems like there’s some sort of a delayed response, like Core 
Data is storing a weak-but-nonzeroing pointer to the NSDate somewhere, the 
object is collected, and later mucking in the MOC exposes the dangling pointer.

I remain thoroughly mystified…

Thanks for any assistance,
Benjamin Rister


On Jan 26, 2010, at 10:57 AM, Benjamin Rister wrote:

> I’m getting an auto_zone_resurrection_error from inside Core Data. Because 
> this is following switching from locking a MOC on different threads (which 
> was working fine) to dispatching blocks to a GCD queue, my suspicion 
> naturally tends towards a multithreading violation. However, I’ve been over 
> it a million times and just can’t find by inspection any cases of doing 
> anything in the MOC (including its MOs, obviously) besides on that queue. 
> Using the debug suffix when loading frameworks (to try to enable Core Data’s 
> multithreading asserts) dies elsewhere for no apparent reason, not to mention 
> that I don’t actually see a _debug version in Core Data.framework, nor see a 
> download to obtain one from connect.apple.com like there was for 10.5.
> 
> However, there’s also a suspicious trend in the places that this happens of 
> it appearing that an object assigned to a local variable or method parameter 
> outside of a dispatch_sync() is being collected before its use in the block. 
> In other words, the block’s reference may not be keeping the object alive. 
> For instance:
> 
> - (void)main {
>   NSDate* startDate = [NSDate date];
> 
>   /* lots of stuff */
> 
>   dispatch_sync(dispatch_get_main_queue(), ^{
>   if(![self isCancelled]) {
>   MyManagedObject* myMO = self.aRelationship.itsMO;
>   ourItem.numericalValue = /* a number; this works fine, 
> so it seems the MO is okay*/;
>   ourItem.aDate = startDate; /* problem occurs here, and 
> Instruments suggests startDate is the resurrected pointer */
>   
>   /* ... */
>   }
>   });
> }
> 
> So,
> - What’s the current mechanism for enabling Core Data’s multithreading 
> asserts?
> - Is there a typical, non-multithreading cause for 
> auto_zone_resurrection_errors inside Core Data?
> - Or, are there any known bugs with GC and blocks (or a bug of mine in the 
> code snippet I gave) causing this?
> 
> 
> Some more details, if needed:
> 
> malloc: resurrection error for block 0x2000281c0 while assigning 
> 0x20003aa00[40] = 0x2000281c0
> garbage pointer stored into reachable memory, break on 
> auto_zone_resurrection_error to debug
> (gdb) bt
> #0  0x7fff8862dc44 in auto_zone_resurrection_error ()
> #1  0x7fff88628f09 in check_resurrection ()
> #2  0x7fff8862adac in auto_zone_set_write_barrier ()
> #3  0x7fff80749625 in objc_assign_strongCast_gc ()
> #4  0x7fff80251104 in -[NSManagedObject(_NSInternalMethods) 
> _newPropertiesForRetainedTypes:andCopiedTypes:preserveFaults:] ()
> #5  0x7fff80251deb in -[NSManagedObject(_NSInternalMethods) 
> _newAllPropertiesWithRelationshipFaultsIntact__] ()
> #6  0x7fff80251d4e in 
> -[NSManagedObjectContext(_NSInternalChangeProcessing) 
> _establishEventSnapshotsForObject:] ()
> #7  0x7fff80251c00 in _PFFastMOCObjectWillChange ()
> #8  0x7fff80251b15 in _PF_ManagedObject_WillChangeValueForKeyIndex ()
> #9  0x7fff802519d2 in _sharedIMPL_setvfk_core ()
> #10 0x7fff80255a0e in _svfk_3 ()
> #11 0x0001fd0e in __-[MyOperation 
> doThatThingTo:attachValue:]_block_invoke_1 (.block_descriptor=0x1006c6440)
> #12 0x7fff82873f98 in _dispatch_barrier_sync_f_slow_invoke ()
> #13 0x7fff8285287a in _dispatch_queue_drai

Re: simple cocoa browser, 'Invalid parameter not satisfying: aString != nil'

2010-01-26 Thread Ariel Feinerman
it`s interesting, but do you think what it will be better solution to use
NSOpenPanel to change file`s attributes instead of NSBrowser?

I try to compile
http://developer.apple.com/mac/library/samplecode/SimpleCocoaBrowser/index.html
one
is not 10.5 compatible (it is important) if set up USE_ITEM_BASED_API 0
gdb shows following:

[Session started at 2010-01-27 00:32:48 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18 20:40:51 UTC
2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys001
Loading program into debugger…
Program loaded.
run
[Switching to process 926]
Running…
2010-01-27 00:32:48.732 SimpleBrowser[926:a0f] *** Assertion failure in
-[NSBrowserCell _objectValue:forString:errorDescription:],
/SourceCache/AppKit/AppKit-1038.25/AppKit.subproj/NSCell.m:1531
2010-01-27 00:32:48.736 SimpleBrowser[926:a0f] An uncaught exception was
raised
2010-01-27 00:32:48.736 SimpleBrowser[926:a0f] Invalid parameter not
satisfying: aString != nil
2010-01-27 00:32:48.741 SimpleBrowser[926:a0f] *** Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid
parameter not satisfying: aString != nil'
*** Call stack at first throw:
(
0   CoreFoundation  0x7fff84885444
__exceptionPreprocess + 180
1   libobjc.A.dylib 0x7fff88aeb0f3
objc_exception_throw + 45
2   CoreFoundation  0x7fff84885267 +[NSException
raise:format:arguments:] + 103
3   Foundation  0x7fff82b7bd66
-[NSAssertionHandler
handleFailureInMethod:object:file:lineNumber:description:] + 198
4   AppKit  0x7fff81a1bb5a -[NSCell
_objectValue:forString:errorDescription:] + 168
5   AppKit  0x7fff81a1ba21 -[NSCell
setStringValue:] + 45
6   SimpleBrowser   0x00011620 -[AppController
browser:willDisplayCell:atRow:column:] + 320
7   AppKit  0x7fff81cb517f -[NSBrowser
_loadCell:atRow:col:inMatrix:] + 471
8   AppKit  0x7fff81e29235 -[NSMatrix
drawRect:] + 1707
9   AppKit  0x7fff81aedfae -[NSView
_drawRect:clip:] + 3390
10  AppKit  0x7fff81aecc21 -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 1325
11  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
12  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
13  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
14  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
15  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
16  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
17  AppKit  0x7fff81c20259 -[NSBrowser
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 81
18  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
19  AppKit  0x7fff81aecf8b -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 2199
20  AppKit  0x7fff81aeb2f3 -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 767
21  AppKit  0x7fff81aeae17 -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 254
22  AppKit  0x7fff81ae76bf -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2683
23  AppKit  0x7fff81a60f37 -[NSView
displayIfNeeded] + 969
24  AppKit  0x7fff81a28f87 -[NSWindow
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] + 1050
25  AppKit  0x7fff81a28b1c -[NSWindow
orderWindow:relativeTo:] + 94
26  AppKit  0x7fff819f4a2c -[NSIBObjectData
nibInstantiateWithOwner:topLevelObjects:] + 1726
27  AppKit  0x7fff819f2b49 loadNib + 226
28  AppKit  0x7fff819f2059
+[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
29  AppKit  0x0

Re: tab view look

2010-01-26 Thread Wesley Smith
thanks~
this looks like exactly what I was looking for.
wes

On Tue, Jan 26, 2010 at 2:24 PM, Dave DeLong  wrote:
> http://www.positivespinmedia.com/dev/PSMTabBarControl.html
>
> Cheers,
>
> Dave
>
> On Jan 26, 2010, at 3:23 PM, Wesley Smith wrote:
>
>> I've been looking around for examples on how to get tab view too look
>> like they do on Terminal, Safari, etc.  Is there any example code
>> around?  I've not found any or really any references as to how to
>> provide a custom look to tabs.
>>
>> thanks,
>> wes
>
> ___
>
> 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/wesley.hoke%40gmail.com
>
> This email sent to wesley.h...@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: Problems Fading Out Music

2010-01-26 Thread Graham Cox

On 27/01/2010, at 9:24 AM, Graham Cox wrote:

> 
> On 27/01/2010, at 9:18 AM, Chunk 1978 wrote:
> 
>> i just realized that this formula doesn't work with negative numbers.
>> for example:  shifting a pitch down one octave over a duration from
>> 0.0 to -0.5, or panning a source with a duration from center at 0.0 to
>> the left -1.0.
>> 
>> any advice?
> 
> 
> Yes it does. You must have made a mistake implementing it.


I just realised why you think it doesn't. It's not the DURATION that needs to 
be negative, it's the values. Time only ever progresses in one direction, as 
far as we know, therefore the time values are always +ve. The value may freely 
be negative, which after all is what you are controlling.

--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: tab view look

2010-01-26 Thread Dave DeLong
http://www.positivespinmedia.com/dev/PSMTabBarControl.html

Cheers,

Dave

On Jan 26, 2010, at 3:23 PM, Wesley Smith wrote:

> I've been looking around for examples on how to get tab view too look
> like they do on Terminal, Safari, etc.  Is there any example code
> around?  I've not found any or really any references as to how to
> provide a custom look to tabs.
> 
> thanks,
> wes


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: Problems Fading Out Music

2010-01-26 Thread Graham Cox

On 27/01/2010, at 9:18 AM, Chunk 1978 wrote:

> i just realized that this formula doesn't work with negative numbers.
> for example:  shifting a pitch down one octave over a duration from
> 0.0 to -0.5, or panning a source with a duration from center at 0.0 to
> the left -1.0.
> 
> any advice?


Yes it does. You must have made a mistake implementing it.

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


tab view look

2010-01-26 Thread Wesley Smith
I've been looking around for examples on how to get tab view too look
like they do on Terminal, Safari, etc.  Is there any example code
around?  I've not found any or really any references as to how to
provide a custom look to tabs.

thanks,
wes
___

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: Problems Fading Out Music

2010-01-26 Thread Chunk 1978
i just realized that this formula doesn't work with negative numbers.
for example:  shifting a pitch down one octave over a duration from
0.0 to -0.5, or panning a source with a duration from center at 0.0 to
the left -1.0.

any advice?

On Thu, Jan 7, 2010 at 7:48 PM, Chunk 1978  wrote:
> graham, thanks for your patients and for the detailed response!  i was
> able to immediately solve my broken logic after reading it.
>
> thanks again.
>
> On Thu, Jan 7, 2010 at 7:19 PM, Graham Cox  wrote:
>>
>> On 08/01/2010, at 6:17 AM, Chunk 1978 wrote:
>>
>>> ok i'll use NSTimer instead of performSelector:withObject:afterDelay,
>>> it should be easier to track this way.  however, i'm still having an
>>> issue with executing logic for the callback method:
>>>
>>> so i set the timer to fire ever 0.15 seconds with this:
>>>
>>> currentVolume =+ targetVolume / (fadeDuration / 0.15);
>>>
>>> this makes sense to me but it doesn't work.
>>>
>>> i see in your example you have callback which you said is used for
>>> both fading in and fading out
>>>
>>> float vol = [fi level1] + ([fi delta] * ( t / [fi time]));
>>>
>>> in comparing the two, i believe i'm missing the entire end of the
>>> logic: * ( t / [fi time])), but i can't really figure out what [fi
>>> time] is...
>>>
>>> ughhh...
>>
>>
>> Well, maybe it'll help to just review linear scaling-over-time arithmetic.
>>
>> You want to take a quantity from a value v0 to a new value v1 in a period of 
>> time d. To do this, the time d is broken down into a series of discrete 
>> steps. We are not concerned with precisely how many steps, as long as there 
>> are enough to make the transition smooth. That's why the timer, which is 
>> what is doing the breaking up of d into steps, is simply set to run at some 
>> sufficiently fast constant rate. However, this rate does need to be 
>> considerably faster than d so that there are at least several steps - if 
>> it's too slow the result will be that the value changes abruptly to the end 
>> value as soon as it runs. My code uses 1/30th of a second as the timer rate, 
>> which is a reasonable starting point. If you want more smoothness, go 
>> faster. I think you are setting your timer to the value d; that won't work.
>>
>> At any point in time t between the start time, t0 and the end time, t1, we 
>> need to know the value of v(t). At t0, v(t) = v0. At t1, v(t) = v1.
>>
>> If we arrange the value t to scale linearly from 0 to 1, it's easy to map 
>> that to a second quantity that goes from v0 to v1.
>>
>> v = v0 + (( v1 - v0 ) * t )
>>
>> So now all we need to do is to arrange for our desired timespan to be 
>> normalised to the range 0..1
>>
>> To do that, we must know the start time, t0. So at the start of the run we 
>> make a note of it - it's simply the current time.
>>
>> To scale the actual elapsed time into the range 0..1, is simply:
>>
>> t = ( tc - t0 ) / d
>>
>> where tc is the current time and d is the desired total run time.
>>
>> Substitute this into the first equation:
>>
>> v = v0 + (( v1 - v0 ) * (( tc - t0 ) / d ))
>>
>> The value v is the instantaneous value of (whatever). In your case it's the 
>> desired volume. Note that this works no matter what rate you set the timer 
>> to, and whether v0 is greater or less than v1. Does it work? Let's try some 
>> numbers. If our desired fade time is 5 seconds, and we are going from full 
>> volume (1.0 ) to silence (0.0), and the callback is called at the halfway 
>> point (here the actual timestamp values are just made up):
>>
>> v = 1.0 + (( 0.0 - 1.0 ) * (( 125.5 - 123 ) / 5.0 )) = 1.0 + -1.0 * ( 2.5 / 
>> 5.0 ) = 1.0 - 0.5  = 0.5
>>
>> Yes it does - at the halfway mark in time, the volume is half of what it was.
>>
>> We also know when to stop - as soon as t >= 1.0, we're done.
>>
>> My code doesn't quite appear to implement this equation, because it 
>> precalculates some of the terms, such as v1 - v0, but in fact this saves no 
>> useful time which is why I wouldn't bother doing it that way now - just keep 
>> it direct and simple.
>>
>> If you want a non-linear ramp, the best place to do that is after 
>> calculating the value t in the range 0..1. You can convert that into a new 
>> range 0..1 that is not linear. Because you've normalised the range to 0..1 
>> regardless of the value of d or anything else, this can be a simple 
>> conversion function of the form t' = f(t).
>>
>> hope this helps,
>>
>> --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: Garbage Collection Docs Puzzle

2010-01-26 Thread Sean McBride
On 1/25/10 4:49 PM, Robert Clair said:

>The garbage collection docs section on the interior pointer issue shows
>this example:
>
>NSData *myData = [someObject getMyData];
>[myData retain];
>const uint8_t *bytes = [myData bytes];
>NSUInteger offset = 0, length = [myData length];
>
>while (offset < length) {
>  // bytes remains valid until next message sent to myData
>}
>[myData release];

My favourite solution is this one:


It's been working well for me.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 12:45 PM, has wrote:

I think a big hit comes from the time it takes to evaluate Apple  
event object specifiers. The cost-benefit tradeoff of having a  
complex, query-driven IPC system is much poorer on OS X, both in  
terms of performance and ease of implementation (one of the reason  
so many apps have lousy AE interfaces is because they're so damn  
hard to implement). The main bottleneck on OS 7-9 was the OS-level  
messaging system; in OS X, it's evaluating those complicated  
messages in the target application process.


Complex AE object queries have the same benefit that SQL queries do:  
they let the data source perform an efficient search. No one would  
claim that MySQL's bottleneck is SQL parsing, or that it would be  
faster to let clients just iterate over table rows one by one! iTunes  
may not have as much data in it as a big database, bit it's still  
expensive to iterate over 10,000 tracks via IPC. It would be even  
worse for scripting the Finder, which operates on orders of magnitude  
more objects.


—Jens___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread has
Jens Alfke wrote:

> On Jan 26, 2010, at 11:13 AM, has wrote:
> 
>> The Apple Event Object Model was optimized for System 7, where IPC  
>> was extremely expensive
> 
> I know; I was on the AppleEvents engineering team at the time :)
> 
> IPC is still extremely expensive, by the way, although not quite as  
> much so. The actual OS-level process switch is faster, but there is  
> still a lot of work involved in marshalling and unmarshalling data.

I think a big hit comes from the time it takes to evaluate Apple event object 
specifiers. The cost-benefit tradeoff of having a complex, query-driven IPC 
system is much poorer on OS X, both in terms of performance and ease of 
implementation (one of the reason so many apps have lousy AE interfaces is 
because they're so damn hard to implement). The main bottleneck on OS 7-9 was 
the OS-level messaging system; in OS X, it's evaluating those complicated 
messages in the target application process. Apple missed an opportunity in not 
designing Cocoa Scripting to be simple, fast, robust and dumb. (But perhaps 
that's an opportunity for some third-party developers with good knowledge of 
server-side Apple events to step in...?)


>> so generally works best if you can use a few complex commands rather  
>> than lots of simple commands.
> 
> Agreed. The problem is that iTunes doesn't implement the complex  
> commands well. A lot of them either fail, or are implemented using  
> linear search instead of querying the database.
> 
> For example, you can't get properties of multiple items:
>   album of every track of every playlist whose artist is "The Beatles"
> fails with error "Handler only handles single objects". Instead you  
> have to remove the "album of" part, get back a list of object  
> specifiers, and loop over them getting the album names. Which of  
> course involves lots of IPC calls.

Or you could factor it so that you get a list of playlist references, then 
iterate over that. Mind you, all tracks should be in your main library 
playlist, so you really only should need to query that, which iTunes can 
manage. (Another iTunes wrinkle to watch for: if a playlist contains no 
matching tracks, iTunes will return an error rather than an empty list; so be 
prepared to deal with that.)


> There are other cases of 'whose' queries that take extremely long to  
> run, depending on the size of your library, because they do a linear  
> search. Try this:
>   id of every track whose played count is 1234
> On my 2.4GHz MacBook Pro this takes 15 seconds to run, with iTunes  
> consuming 100% CPU. (I do have 10,000 tracks in my library.) By  
> comparison, creating a smart playlist in iTunes with the same criteria  
> is instantaneous.

Apple have put little apparent effort into maintaining and updating iTunes' AE 
support over the years. (And iTunes is probably one of Apple's most heavily 
scripted apps.) So it wouldn't surprise me if the GUI is taking full advantage 
of the underlying database's capabilities while the AE interface isn't. But 
that's a rant for the AppleScript list. For your particular example, I would 
try grabbing all track ids and all played counts, then iterating over them 
yourself. I've not tried it here, but it might go a bit faster.

But aside from grumbling about Cocoa Scripting, we're getting OT for cocoa-dev. 
If anyone wants to discuss this stuff further, we should take it to the 
AppleScript-users list:

http://lists.apple.com/mailman/listinfo/applescript-users

Regards,

has
-- 
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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: What is the equivalent of SetSystemUIMode() in Leopard and above?

2010-01-26 Thread Sean McBride
On 1/25/10 5:17 PM, Arun said:

>Are there any cocoa equivalent API's for SetSystemUIMode() available in
>Leopard 10.5 and above?
>I want to hide dock and menu item at run time in my application.

SetSystemUIMode works well for me in 10.5 and above.  Is it causing
problems for you?

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

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

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

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


Re: NSTabView

2010-01-26 Thread Kyle Sluder
On Tue, Jan 26, 2010 at 11:42 AM, David Blanton  wrote:
> I want to see all the tab items ... are there multiple rows?

No. The HIG answers your questions:

http://developer.apple.com/Mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGControls/XHIGControls.html#//apple_ref/doc/uid/TP3359-DontLinkElementID_111

"Note: Multiple rows of tabs are not supported in Mac OS X."

"If you have too many tabs to fit into a window properly, it’s
acceptable, although not highly recommended, to use instead a pop-up
menu to change the contents of a group box"

This is yet another reason why dynamic UIs are a Bad Idea(TM).

--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: How to access iTunes using cocoa

2010-01-26 Thread Paul Sanders
Cool!  Thank you, that sounds just the ticket.  I'll try it.  I 
have to admit I haven't put a lot of effort into this.

Paul Sanders.

- Original Message - 
From: "Jens Alfke" 
To: "Paul Sanders" 
Cc: "Matt Neuburg" ; "Ramesh P" 
; 
Sent: Tuesday, January 26, 2010 7:37 PM
Subject: Re: How to access iTunes using cocoa



On Jan 26, 2010, at 11:18 AM, Paul Sanders wrote:

> OK, thanks guys.  My script is pretty simple-minded: it just
> retrieves each track in turn and compares the artist and title
> with what I am looking for.  We're way off-topic now, but is
> there a better way?  I'm trying to avoid adding the same track
> to the library twice. Thanks.


tell app "iTunes"
first track whose name is "." and artist is ""
end

This will instantly return the track if it exists, or an 
error -1728
(not found).

—Jens 



___

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

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

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

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


Re: NSTabView

2010-01-26 Thread David Blanton
Ok, so there is no flag to set.  So how would one deal with the  
situation I described?

I want to see all the tab items ... are there multiple rows?
Any help or suggestions, please.

-db


On Jan 25, 2010, at 11:46 PM, Scott Anguish wrote:



On Jan 25, 2010, at 10:34 PM, David Blanton wrote:

I have a fixed size NSTabView that displays 4 NSTabViewITems very  
nicely.


It is possible that the application may want to add more  
NSTabViewItems.


Is there a flag to set (somewhere) so that added items will not be  
truncated to the view but display >> like Safari indicating more  
items and then displaying them in a menu?


No.



___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 11:18 AM, Paul Sanders wrote:


OK, thanks guys.  My script is pretty simple-minded: it just
retrieves each track in turn and compares the artist and title
with what I am looking for.  We're way off-topic now, but is
there a better way?  I'm trying to avoid adding the same track
to the library twice. Thanks.



tell app "iTunes"
first track whose name is "." and artist is ""
end

This will instantly return the track if it exists, or an error -1728  
(not found).


—Jens___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 11:13 AM, has wrote:

The Apple Event Object Model was optimized for System 7, where IPC  
was extremely expensive


I know; I was on the AppleEvents engineering team at the time :)

IPC is still extremely expensive, by the way, although not quite as  
much so. The actual OS-level process switch is faster, but there is  
still a lot of work involved in marshalling and unmarshalling data.


so generally works best if you can use a few complex commands rather  
than lots of simple commands.


Agreed. The problem is that iTunes doesn't implement the complex  
commands well. A lot of them either fail, or are implemented using  
linear search instead of querying the database.


For example, you can't get properties of multiple items:
album of every track of every playlist whose artist is "The Beatles"
fails with error "Handler only handles single objects". Instead you  
have to remove the "album of" part, get back a list of object  
specifiers, and loop over them getting the album names. Which of  
course involves lots of IPC calls.


There are other cases of 'whose' queries that take extremely long to  
run, depending on the size of your library, because they do a linear  
search. Try this:

id of every track whose played count is 1234
On my 2.4GHz MacBook Pro this takes 15 seconds to run, with iTunes  
consuming 100% CPU. (I do have 10,000 tracks in my library.) By  
comparison, creating a smart playlist in iTunes with the same criteria  
is instantaneous.


—Jens___

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

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

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

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


Re: [iPhone] Implementing VOIP for iPhone App

2010-01-26 Thread Shawn Rutledge
On Mon, Jan 25, 2010 at 1:50 PM, Michael Ash  wrote:
> I think that the term "VoIP" is a red herring here. Yes, technically
> you're taking voice audio and sending it over IP, but VoIP normally
> refers to real-time interactive usage like internet telephony. You're
> just sending audio data to a server and getting some kind of response,

I assumed the voice recognition was for voice dialing or some kind of
interactive voice response system.

Anyway it seems like it would be better to go with a standards-based
approach, e.g. the iPhone app should be a SIP client or an Asterisk
client, and then I think you can easily build the voice-response stuff
on an Asterisk server, as some kind of plugin.  I'm not an expert on
those details but I know this kind of stuff gets done from time to
time, so there is probably plenty of stuff you can reuse rather than
re-inventing the wheel.

But then, I'm thinking as if the output of this class project is
supposed to be a useful piece of engineering and build upon what
exists already.  Could be wrong...  sometimes the profs like you to
reinvent the wheel just to learn from experience.  In 1994 I had a
class in "multimedia information systems" and the class project was to
build a computer-based magazine or newspaper replacement.  I threw
together a quick GUI (table of contents and navigation stuff) in
Toolbook and used HTML for the content, which was quite easy, and the
prof was taken aback... he had said when we started the project that
there was a Unix box available to do the project on, and thought we
were going to actually start with xlib or Motif or some such and build
the whole thing from scratch, which I thought was utterly pointless.
My grade turned out OK anyhow (maybe I got a B for that class, I
forgot).  The web was sortof new at that time, but all the cool kids
had web pages already and I thought it was kindof pathetic that a prof
who specializes in multimedia wouldn't have understood by then that it
was the short-term future of media consumption, and taking that as a
given, could've thought of a more appropriate assignment to build on
top of it.  OTOH I didn't really learn anything from that experience;
if I'd slaved away with Motif to build some kind of pointless one-off
app from scratch, at least I would've learned Motif along the way.
The real world is often pragmatic though, like I was... why do it over
again if you can reuse it.
___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread Paul Sanders
OK, thanks guys.  My script is pretty simple-minded: it just
retrieves each track in turn and compares the artist and title
with what I am looking for.  We're way off-topic now, but is
there a better way?  I'm trying to avoid adding the same track
to the library twice. Thanks.

Paul Sanders.

Sorry Jens, meant to post that to the list, not to you 
privately.

- Original Message - 
From: "Jens Alfke" 
To: "Matt Neuburg" 
Cc: "Paul Sanders" ; "Ramesh P" 
; 
Sent: Tuesday, January 26, 2010 6:51 PM
Subject: Re: How to access iTunes using cocoa



On Jan 26, 2010, at 10:17 AM, Matt Neuburg wrote:

> NSAppleScript is your slowest
> choice because it slows way down as you loop and access memory 
> (such
> as
> lists). Scripting Bridge and objc-appscript do all the heavy 
> lifting
> in
> Objective-C and just throw Apple events at the target, so they 
> are
> inherently much faster, and your bottlenecks are then your 
> choice of
> Apple
> event and how long the target takes to process each Apple 
> event.

AppleScript isn't fast, but you'd have to scale up to much, much
larger data sets to see a real slowdown. I've done a fair bit of
iTunes scripting using [NS]AppleScript, and when the scripts 
have run
slowly, it's always been iTunes itself at fault. (Its AE object
resolution support is pretty naively written and doesn't 
implement any
of the fast-querying shortcuts, instead just doing linear 
searches
over the whole library.) So it wouldn't matter what technology 
you
used to send the events, because all the time is spent waiting 
for
iTunes to send a reply.

—Jens 



___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread has
Jens Alfke wrote:

> On Jan 26, 2010, at 9:41 AM, Paul Sanders wrote:
> 
>> I use Cocoa's NSAppleScript class. This seems to work fine on Tiger, Leopard 
>> and Snow Leopard.
> 
> Yup, it just has the limitation that you have to run the script 
> synchronously, which sucks since many iTunes commands can take a long time. 
> There's no workaround to this that I've been able to find, since 
> NSAppleScript is not thread-safe.

AppleScript and NSAppleScript are thread-safe in 10.6.

As for slowness, iTunes may not be a speed demon when it has many tens of 
thousands of tracks to wade through, but in a lot of cases the performance 
problems are primarily due to inefficient design in your own code. The Apple 
Event Object Model was optimized for System 7, where IPC was extremely 
expensive, so generally works best if you can use a few complex commands rather 
than lots of simple commands.

e.g. This is dog slow because it sends 3*N+1 Apple events (where N is the 
number of tracks), each of which takes time for iTunes to process:

set the_result to {}
tell application "iTunes"
repeat with track_ref in every track of library playlist 1
set end of the_result to {name, album, artist} of track_ref
end repeat
end tell
the_result

whereas this returns the same data (albeit in a different arrangement) using 
just 3 Apple events, so is blazing fast by comparison:

tell application "iTunes"
set the_result to {name, album, artist} of every track of playlist 1
end tell

Apple event IPC is based on RPC + first-class queries, not OOP as most folks 
assume (a rough analogy would be XPath queries over XML-RPC). If you try to 
apply OO idioms to it when moving large numbers of values between processes, 
performance will suck even by IPC standards.

Similarly, if you want to filter for specific tracks, you'll get much better 
performance if you can formulate a more complex query for iTunes to resolve 
rather than pull out all of the data and search it yourself:

tell application "iTunes"
make new user playlist with properties {name:"Post"}
duplicate (every track of library playlist 1 whose album = "Post" and 
artist = "Björk") to playlist "Post"
end tell

If you're curious, running that through ASTranslate formats each Apple event in 
objc-appscript syntax (which is handy as a starting point for developing your 
own ObjC code, and avoiding off-topic moderation:):

#import "ITGlue/ITGlue.h"
ITApplication *itunes = [ITApplication applicationWithName: @"iTunes"];
ITMakeCommand *cmd = [[[itunes make] new_: [ITConstant userPlaylist]] 
   withProperties: [NSDictionary dictionaryWithObject: 
  @"Post" forKey: [ITConstant name]]];
id result = [cmd send];

#import "ITGlue/ITGlue.h"
ITApplication *itunes = [ITApplication applicationWithName: @"iTunes"];
ITReference *ref = itunes libraryPlaylists] at: 1] tracks] byTest: 
 [[[ITIts album] equals: @"Post"] AND: 
  [[ITIts artist] equals: @"Björk"]]];
ITDuplicateCommand *cmd = [[ref duplicate] to: 
  [[itunes playlists] byName: @"Post"]];
id result = [cmd send];


HTH

has
-- 
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.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: How to access iTunes using cocoa

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 10:17 AM, Matt Neuburg wrote:


NSAppleScript is your slowest
choice because it slows way down as you loop and access memory (such  
as
lists). Scripting Bridge and objc-appscript do all the heavy lifting  
in

Objective-C and just throw Apple events at the target, so they are
inherently much faster, and your bottlenecks are then your choice of  
Apple

event and how long the target takes to process each Apple event.


AppleScript isn't fast, but you'd have to scale up to much, much  
larger data sets to see a real slowdown. I've done a fair bit of  
iTunes scripting using [NS]AppleScript, and when the scripts have run  
slowly, it's always been iTunes itself at fault. (Its AE object  
resolution support is pretty naively written and doesn't implement any  
of the fast-querying shortcuts, instead just doing linear searches  
over the whole library.) So it wouldn't matter what technology you  
used to send the events, because all the time is spent waiting for  
iTunes to send a reply.


—Jens___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread Otavio
On Tue, Jan 26, 2010 at 7:50 AM, Laurent Cerveau  wrote:
> You can use the scripting bridge framework which will send AppleEvent in a 
> nice encapsulated way for you to iTunes

+1

Check this doc 


> laurent
>
> On Jan 26, 2010, at 10:48 AM, Ramesh P wrote:
>
>> Hi,
>> Is it possible to access iTunes from cocoa application?  Is there any open
>> source framework for accessing iTunes?
>>
>> Thanks in advance,
>> Ramesh.P
>> ___
>>
>> 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/lcerveau%40me.com
>>
>> This email sent to lcerv...@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/otavio%40horadomac.com
>
> This email sent to ota...@horadomac.com
>



-- 
OtavioCC
http://twitter.com/otaviocc
http://www.horadomac.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


Need help figuring out poor Core Data performance

2010-01-26 Thread Eyal Redler

Hi,

I'm working on a NSPersistentDocument based application. My data model  
is quite simple, the main entity contains a few strings, ints and  
dates and there is an array (one to many relationship) of another  
simple entity.
The document window contains an NSTableView that displays all the main  
entities (using an NSArrayController)
Everything seems to be working ok except that when I open a large  
document (20k records) for the first time in a session (after a  
restart), it takes a few minutes of spinning wheel for the data to  
show. If I close the document and then re-open I usually get an  
instant response. The format is sqlite.
Following is an Activity Monitor sample taken during this long  
process. I also tried to monitor this using Instruments and saw  
nothing interesting - only one fetch.

I'm really stuck with this, I would appreciate any ideas or pointers...

Thanks in advance,


Eyal Redler

"If Uri Geller bends spoons with divine powers, then he's doing it the  
hard way."

--James Randi
www.eyalredler.com





1765 Thread_2507
  1765 start
1765 main
  1765 NSApplicationMain
1765 -[NSApplication run]
  1765 -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:]

1765 _DPSNextEvent
  1765 BlockUntilNextEventMatchingListInMode
1765 ReceiveNextEventCommon
  1765 RunCurrentEventLoopInMode
1765 CFRunLoopRunInMode
  1765 CFRunLoopRunSpecific
1765 __NSFireDelayedPerform
  1765 -[NSInvocation invokeWithTarget:]
1765 -[NSInvocation invoke]
  1765 __invoking___
1765 -[NSController  
_controllerEditor:didCommit:contextInfo:]

  1765 _NSSendCommitEditingSelector
1765 - 
[NSObjectController(NSManagedController)  
_executeFetch:didCommitSuccessfully:actionSender:]
  1765 - 
[NSObjectController(NSManagedController) fetchWithRequest:merge:error:]
1765 - 
[NSArrayController(NSManagedController)  
_performFetchWithRequest:merge:error:]
  1765 -[_NSManagedProxy  
fetchObjectsWithFetchRequest:error:]
1765 - 
[NSManagedObjectContext executeFetchRequest:error:]
  1765 - 
[NSPersistentStoreCoordinator(_NSInternalMethods)  
executeRequest:withContext:]
1765 -[NSSQLCore  
executeRequest:withContext:]
  1765 - 
[NSSQLCore objectsForFetchRequest:inContext:]
1765  
newFetchedRowsForFetchPlan_MT
  1765 - 
[NSSQLiteConnection fetchResultSet:usingFetchPlan:]
1765  
_execute
  1765  
sqlite3_step
1765  
sqlite3Step
   
1764 sqlite3VdbeExec
 
1306 sqlite3VdbeMemFromBtree
   
1306 accessPayload
1306 
 sqlite3PagerAcquire
  1305 
 pread$UNIX2003
1305 
 pread$UNIX2003
  1 
 sqlite3PagerAcquire
 
455 sqlite3BtreeNext
   
455 sqlite3BtreeNext
455 
 sqlite3PagerAcquire
  454 
 pread$UNIX2003
454 
 pread$UNIX2003
  1 
 sqlite3PagerAcquire
3  
sqlite3VdbeExec
  1  
sqlite3Step

1765 Thread_2603
  1765 thread_start
1765 _pthread_start
  1765 minion_duties2
   

Re: How to access iTunes using cocoa

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 9:41 AM, Paul Sanders wrote:

I use Cocoa's NSAppleScript class.  This seems to work fine on  
Tiger, Leopard and Snow Leopard.


Yup, it just has the limitation that you have to run the script  
synchronously, which sucks since many iTunes commands can take a long  
time. There's no workaround to this that I've been able to find, since  
NSAppleScript is not thread-safe.


an efficient way to find a track by artist and title would be nice -  
scanning large libraries in AppleScript is very slow.


Not to veer off-topic into AppleScript, but iTunes' "search" command  
is a fast way to find tracks, though awkward to use.


—Jens___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread Matt Neuburg
On or about 1/26/10 9:41 AM, thus spake "Paul Sanders"
:

> Should I be scared of the 'false timeout' bug?

You should if you're doing the kind of thing that triggers it. Looping in
NSAppleScript over many tracks, you're almost certain to hit it. But the
same thing is likely to happen even with the Scripting Bridge. On the other
hand, appscript in all its flavours has now worked around it.

http://db.tidbits.com/article/10643

> Mostly I just want to add
> tracks to the iTunes Music Library, although an efficient way to find a track
> by artist and title would be nice - scanning large libraries in AppleScript is
> very slow.

Well, everything depends upon (1) what you mean by "large", (2) what you
mean by "scan", and (3) what language you use. NSAppleScript is your slowest
choice because it slows way down as you loop and access memory (such as
lists). Scripting Bridge and objc-appscript do all the heavy lifting in
Objective-C and just throw Apple events at the target, so they are
inherently much faster, and your bottlenecks are then your choice of Apple
event and how long the target takes to process each Apple event. There is
almost always a way to be faster but it may take some experiment and
tweaking. See my comments on this point in my iTunes "Orphans" example for
appscript (it uses rb-appscript, which is Ruby; I would expect an
Objective-C version might be faster):

http://www.apeth.com/rbappscript/10examples.html#orphans

By the way, another nice thing I forgot to mention about objc-appscript is
that it can easily be run in a background thread, so even if your operation
*is* time-consuming (because the bottlenecks I mentioned above are
unavoidable), the user is not necessarily oppressed by this fact. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring & Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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: simple file browser

2010-01-26 Thread Corbin Dunn

On Jan 26, 2010, at 10:10 AM, Jens Alfke wrote:

> 
> On Jan 26, 2010, at 10:03 AM, Corbin Dunn wrote:
> 
>> Jens/Andrew --- the SnowLeopard documentation is incorrect; it was added in 
>> 10.6, but "retro-published" to 10.4. So, it is available in 10.4 and higher.
> 
> It's definitely not in the headers of the 10.5 SDK.

No, and it won't be; we don't modify old SDKs.

> Are you saying that the method was added to the class in 10.4 but not made 
> public till 10.6? So it would be kosher in 10.4/5 to declare it in a category 
> on NSSavePanel and call it?

Yes -- that is correct. The availability macro in 10.6 states that it is 
available on 10.4 and higher. 

Another way to access it is to build with the 10.6 SDK but set MIN/MAX target 
as 10.4, but the category is the easiest solution.

-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: simple file browser

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 10:03 AM, Corbin Dunn wrote:

Jens/Andrew --- the SnowLeopard documentation is incorrect; it was  
added in 10.6, but "retro-published" to 10.4. So, it is available in  
10.4 and higher.


It's definitely not in the headers of the 10.5 SDK. Are you saying  
that the method was added to the class in 10.4 but not made public  
till 10.6? So it would be kosher in 10.4/5 to declare it in a category  
on NSSavePanel and call it?


—Jens___

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

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

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

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


Re: NSString category name collision?

2010-01-26 Thread Sherm Pendley
On Tue, Jan 26, 2010 at 12:28 PM, Jens Alfke  wrote:
>
> Yes. To avoid these kinds of collisions, if you add a category method to an
> external class you should add some sort of hopefully-unique prefix to its
> name.

CocoaDev has a list of prefixes many people are using. Since it's a
wiki, you can add your own to the list:



sherm--

-- 
Cocoa programming in Perl:
http://www.camelbones.org
___

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: 10.6 Clips Tooltip if you return NSTextFieldCell in -dataCellForRow:

2010-01-26 Thread Corbin Dunn
Jerry,

http://developer.apple.com/mac/library/documentation/cocoa/reference/ApplicationKit/Classes/NSCell_Class/Reference/NSCell.html

Look up "expansion tool tips".

Managing Expansion Frames
• – expansionFrameWithFrame:inView:
• – drawWithExpansionFrame:inView:

For what it is worth, using a normal NSTexTFieldCell should always work -- 
there is possibly something wrong with the way you have it setup (like allowing 
wrapping, or something). 

Short answers inline:


On Jan 25, 2010, at 10:48 PM, Jerry Krinock wrote:

> I've been overriding -[NSTableColumn dataCellForRow:], returning a variation 
> on NSTextFieldCell for years.  However I just discovered that, in OS 10.6.2, 
> this breaks the tooltip which shows the entire text when you hover over a 
> truncated cell.  (This tooltip feature was added in OS 10.5.)  Here's how it 
> looks:
> 
> http://sheepsystems.com/engineering/ClippedToolTip.png [1]
> 
> Here's the demo project:
> 
> http://sheepsystems.com/engineering/ClippedToolTip.zip
> 
> No problem either way in Mac OS X 10.5.  Snow Leopard AppKit Release Notes 
> don't mention anything about these tooltips.
> ...

> * Why in the world would Cocoa be invoking -dataCellForRow in order to 
> display a tooltip?  It always uses the same yellow box format with the same 
> font.  The tooltip should have no interest whatsoever in the data cell.  But 
> it's apparently getting the answer that it wants, a width of 343.968!

Because it is showing an expansion of the clipped cell; it is different than a 
normal tooltip.


> 
> * How in the world does -[super dataCell] know that the required width of the 
> text in this particular cell is 343.968?  It does not even know the row or 
> column, much less the data object value.

See the methods I mention above.

-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: simple file browser

2010-01-26 Thread Corbin Dunn
Jens/Andrew --- the SnowLeopard documentation is incorrect; it was added in 
10.6, but "retro-published" to 10.4. So, it is available in 10.4 and higher. 

--corbin

On Jan 25, 2010, at 5:57 PM, Andrew Merenbach wrote:

> On Jan 25, 2010, at 4:12 PM, Jens Alfke wrote:
> 
>> 
>> On Jan 25, 2010, at 3:17 PM, Corbin Dunn wrote:
>> 
>>> Instead, just call: [savePanel setShowsHiddenFiles:YES].
>> 
>> There's no such method in the 10.5 SDK; was it added in 10.6?
>> 
>> —Jens___
>> 
> 
> Looks like--in the NSSavePanel class ref on my Snow Leopard install:
> 
>> setShowsHiddenFiles:
>> Specifies whether the panel displays files that are normally hidden from the 
>> user.
>> 
>> - (void)setShowsHiddenFiles:(BOOL)flag
>> 
>> Parameters
>> flag
>> If YES, the panel displays hidden files; if NO, it does not.
>> 
>> Availability
>>  • Available in Mac OS X v10.6 and later.
>> See Also
>>  • – showsHiddenFiles
>> Declared In
>> NSSavePanel.h
> 
> Cheers,
>   Andrew

___

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: NSString category name collision?

2010-01-26 Thread jonat...@mugginsoft.com
On 26 Jan 2010, at 17:28, Jens Alfke wrote:

> 
> On Jan 26, 2010, at 8:08 AM, jonat...@mugginsoft.com wrote:
> 
>> Is this just one of the things we have to put up with as the price for 
>> dynamism or can this problem be pre-empted?
>> I added a name space prefix to my method definition and the exception 
>> departed.
> 
> Yes. To avoid these kinds of collisions, if you add a category method to an 
> external class you should add some sort of hopefully-unique prefix to its 
> name. In my Mooseyard software I use the same prefix I use for my class names 
> ("MY") only lowercased, with an underscore — e.g. -[NSString my_rot13].
> 
Thanks Jens.

That's a point of good practice that I don't currently follow. Once bitten etc.

Jonathan


___

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: How to access iTunes using cocoa

2010-01-26 Thread Paul Sanders
I use Cocoa's NSAppleScript class.  This seems to work fine on Tiger, Leopard 
and Snow Leopard.  

Should I be scared of the 'false timeout' bug?  Mostly I just want to add 
tracks to the iTunes Music Library, although an efficient way to find a track 
by artist and title would be nice - scanning large libraries in AppleScript is 
very slow.

And check out Doug's AppleScripts for iTunes - there's some interesting stuff 
in there.

Paul Sanders.

- Original Message - 
From: "Matt Neuburg" 
To: "Ramesh P" 
Cc: 
Sent: Tuesday, January 26, 2010 5:27 PM
Subject: Re: How to access iTunes using cocoa


On Tue, 26 Jan 2010 15:18:38 +0530, Ramesh P 
said:
>Hi,
>Is it possible to access iTunes from cocoa application?  Is there any open
>source framework for accessing iTunes?

I use objc-appscript for this. It has some advantages over Apple's Scripting
Bridge (for one thing, it's backwards compatible to 10.4; for another, it is
not subject to the 10.6 Apple event "false timeout" bug).

http://appscript.sourceforge.net/objc-appscript/index.html

m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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/p.sanders%40alpinesoft.co.uk

This email sent to p.sand...@alpinesoft.co.uk
___

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: NSString category name collision?

2010-01-26 Thread Jens Alfke


On Jan 26, 2010, at 8:08 AM, jonat...@mugginsoft.com wrote:

Is this just one of the things we have to put up with as the price  
for dynamism or can this problem be pre-empted?
I added a name space prefix to my method definition and the  
exception departed.


Yes. To avoid these kinds of collisions, if you add a category method  
to an external class you should add some sort of hopefully-unique  
prefix to its name. In my Mooseyard software I use the same prefix I  
use for my class names ("MY") only lowercased, with an underscore —  
e.g. -[NSString my_rot13].


—Jens___

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

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

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

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


Re: How to access iTunes using cocoa

2010-01-26 Thread Matt Neuburg
On Tue, 26 Jan 2010 15:18:38 +0530, Ramesh P 
said:
>Hi,
>Is it possible to access iTunes from cocoa application?  Is there any open
>source framework for accessing iTunes?

I use objc-appscript for this. It has some advantages over Apple's Scripting
Bridge (for one thing, it's backwards compatible to 10.4; for another, it is
not subject to the 10.6 Apple event "false timeout" bug).

http://appscript.sourceforge.net/objc-appscript/index.html

m.

-- 
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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


NSString category name collision?

2010-01-26 Thread jonat...@mugginsoft.com
I have defined a category on NSString which includes the following signature.

- (NSString *)stringByReplacingCharactersInSet:(NSCharacterSet *) set 
withString:(NSString *) string 

On occasion I encounter the exception listed below where an OSAKit private 
method calls the same method (and triggers the exception).

Is this a collision between my category method and one presumably/perhaps 
defined by the OSAKit?

The docs say:

A category cannot reliably override methods declared in another category of the 
same class.
This issue is of particular significance since many of the Cocoa classes are 
implemented using categories. 
A framework-defined method you try to override may itself have been implemented 
in a category, and so which implementation takes precedence is not defined.

Is this just one of the things we have to put up with as the price for dynamism 
or can this problem be pre-empted?

I added a name space prefix to my method definition and the exception departed.

*** -[NSCFString rangeOfCharacterFromSet:options:range:]: Range or index out of 
bounds

-[NSString rangeOfCharacterFromSet:options:range:] (in Foundation) 133
-[NSMutableString(Mugginsoft) replaceCharactersInSet:withString:] (in 
MGSKosmicTask) (NSString_Mugginsoft.m:220)
-[NSString(Mugginsoft) stringByReplacingCharactersInSet:withString:] (in 
MGSKosmicTask) (NSString_Mugginsoft.m:203)
[OSADictionary(OSAPrivate) anchorFromName:] (in OSAKit) 53
-[OSADictionary(OSAPrivate) parseData:error:] (in OSAKit) 1180


Regards

Jonathan Mitchell

Developer
http://www.mugginsoft.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


Debugging auto_zone_resurrection_error in Core Data using GCD

2010-01-26 Thread Benjamin Rister
I’m getting an auto_zone_resurrection_error from inside Core Data. Because this 
is following switching from locking a MOC on different threads (which was 
working fine) to dispatching blocks to a GCD queue, my suspicion naturally 
tends towards a multithreading violation. However, I’ve been over it a million 
times and just can’t find by inspection any cases of doing anything in the MOC 
(including its MOs, obviously) besides on that queue. Using the debug suffix 
when loading frameworks (to try to enable Core Data’s multithreading asserts) 
dies elsewhere for no apparent reason, not to mention that I don’t actually see 
a _debug version in Core Data.framework, nor see a download to obtain one from 
connect.apple.com like there was for 10.5.

However, there’s also a suspicious trend in the places that this happens of it 
appearing that an object assigned to a local variable or method parameter 
outside of a dispatch_sync() is being collected before its use in the block. In 
other words, the block’s reference may not be keeping the object alive. For 
instance:

- (void)main {
NSDate* startDate = [NSDate date];

/* lots of stuff */

dispatch_sync(dispatch_get_main_queue(), ^{
if(![self isCancelled]) {
MyManagedObject* myMO = self.aRelationship.itsMO;
ourItem.numericalValue = /* a number; this works fine, 
so it seems the MO is okay*/;
ourItem.aDate = startDate; /* problem occurs here, and 
Instruments suggests startDate is the resurrected pointer */

/* ... */
}
});
}

So,
- What’s the current mechanism for enabling Core Data’s multithreading asserts?
- Is there a typical, non-multithreading cause for 
auto_zone_resurrection_errors inside Core Data?
- Or, are there any known bugs with GC and blocks (or a bug of mine in the code 
snippet I gave) causing this?


Some more details, if needed:

malloc: resurrection error for block 0x2000281c0 while assigning 
0x20003aa00[40] = 0x2000281c0
garbage pointer stored into reachable memory, break on 
auto_zone_resurrection_error to debug
(gdb) bt
#0  0x7fff8862dc44 in auto_zone_resurrection_error ()
#1  0x7fff88628f09 in check_resurrection ()
#2  0x7fff8862adac in auto_zone_set_write_barrier ()
#3  0x7fff80749625 in objc_assign_strongCast_gc ()
#4  0x7fff80251104 in -[NSManagedObject(_NSInternalMethods) 
_newPropertiesForRetainedTypes:andCopiedTypes:preserveFaults:] ()
#5  0x7fff80251deb in -[NSManagedObject(_NSInternalMethods) 
_newAllPropertiesWithRelationshipFaultsIntact__] ()
#6  0x7fff80251d4e in -[NSManagedObjectContext(_NSInternalChangeProcessing) 
_establishEventSnapshotsForObject:] ()
#7  0x7fff80251c00 in _PFFastMOCObjectWillChange ()
#8  0x7fff80251b15 in _PF_ManagedObject_WillChangeValueForKeyIndex ()
#9  0x7fff802519d2 in _sharedIMPL_setvfk_core ()
#10 0x7fff80255a0e in _svfk_3 ()
#11 0x0001fd0e in __-[MyOperation 
doThatThingTo:attachValue:]_block_invoke_1 (.block_descriptor=0x1006c6440)
#12 0x7fff82873f98 in _dispatch_barrier_sync_f_slow_invoke ()
#13 0x7fff8285287a in _dispatch_queue_drain ()
#14 0x7fff82853127 in _dispatch_queue_serial_drain_till_empty ()
#15 0x7fff82885e4c in _dispatch_main_queue_callback_4CF ()
...

This is another method that this typically, but not always, dies in. It’s in an 
NSOperation:

- (void)doThatThingTo:(id)anIdentifier attachValue:(CodableClass*)codableObject 
{
dispatch_sync(dispatch_get_main_queue(), ^{
if(![self isCancelled]) {
MyManagedObject* myMO = /* find the MO that 
anIdentifier leads us to; may create it if necessary */;
myMO.numericalValue = /* a number; this assignment 
works fine and never has caused any problems, so myMO seems in good shape. */;
myMO.transformableValue = codableObject; /* this is 
where the problem always seems to happen. */

/* ... */
}
});
}


When in the executable info I use the debug suffix when loading frameworks, I 
don’t get into any real part of the program, but end up with SIGABRT in the 
first -[NSUserDefaults standardUserDefaults] call registering defaults.

Program received signal:  “SIGABRT”.
(gdb) bt
#0  0x0001001358f2 in __kill ()
#1  0x0001001358e4 in kill ()
#2  0x0001001fbefc in raise ()
#3  0x000100225acf in abort ()
#4  0x00010027d0c2 in _dispatch_abort ()
#5  0x0001001152f5 in dispatch_source_set_cancel_handler ()
#6  0x7fff87e47fff in ___CFMachPortCreateWithPort2_block_invoke_1 ()
...
#11 0x7fff87e47b5b in CFMachPortCreate ()
#12 0x7fff87e479b1 in _CFXNotificationCenterCreate ()
...
#16 0x7fff87e44b1b in CFPreferencesCopyAppValue ()
#17 0x7fff874875ef in -[NSUserDefaults(NSUserDefaults) initWithUser:] ()
#18 0x00

Re: Centering a window on the *current* screen, not the *main* screen

2010-01-26 Thread Glenn L. Austin
On Jan 26, 2010, at 2:34 AM, Graham Cox wrote:

>> I could write my own code to position the window, but I don't know how
>> to reproduce the recommended position of the centered window, which is
>> slightly above the center.
> 
> 
> Traditionally, this has been at a position leaving one third of the space 
> above and two thirds below, though I'm not sure if that's still currently the 
> exact placing.

Except that this is really "alertPosition" -- not really "centered" (which has 
other connotations).

At least there's now a single message to move the window to a "centered" 
position.

-- 
Glenn L. Austin, Computer Wizard and Race Car Driver <><




___

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: Change background color of UITabBarItem and UITabBar

2010-01-26 Thread Greg Reichow
> 
> Is it possible to change color of UITabBar instead of the default color black?
> And also is it possible to change background color of UITabBarItem's 
> background
> color instead of default color blue? If yes, how?

There is no API for changing the UITabBar.  Yet, you can subclass the 
TabBarController and override the viewDidLoad method.  For example,

@interface UITabBarController (private)
- (UITabBar *)tabBar;
@end

@implementation CustomUITabBarController

- (void)viewDidLoad {
[super viewDidLoad];

CGRect frame = CGRectMake(0.0, 0.0, self.view.bounds.size.width, 48);
UIView *v = [[UIView alloc] initWithFrame:frame];
[v setBackgroundColor:[UIColor redColor]];
[v setAlpha:0.5];
[[self tabBar] addSubview:v];
[v release];
}

@end

This would set a red tint to the tab bar.  Check on stackoverflow.com for many 
more examples.  Keep in mind the above example modifies the tabBar of the 
controller, which is specifically mentioned in the documentation not to mess 
with.  So, use at your own risk. 

Greg
___

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: Centering a window on the *current* screen, not the *main* screen

2010-01-26 Thread Gregory Weston
Oleg Krupnov wrote:

> Anyway, it's an annoyance that the [NSWindow center] uses [NSScreen
> mainScreen] instead of [NSWindow screen]. I'd consider it a bug of
> AppKit, indeed.

No, just a philosophical difference regarding the meaning and, more 
importantly, intent of "centering" a window. And it predates AppKit. The goal 
isn't really to physically center a window on the screen. It's to position it 
in a defined location that is a focus of user attention. Consider the docs:

"You typically use this method to place a window—most likely an alert 
dialog—where the user can’t miss it. This method is invoked automatically when 
a panel is placed on the screen by the runModalForWindow: method of the 
NSApplication class."

Why? Because:

"Such a placement carries a certain visual immediacy and 
importance."___

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: BIG Thread problem (theorical).. need some advice.

2010-01-26 Thread Gustavo Pizano
Aha, so if I understood good, you use Notifications instead, so when the 
LoadDelegate finish it post the notifications, and then my controller which I 
should have added to listen to  a given notification and perform the given 
selector,  can get the dictionary having for sure it has some data which was 
instantiated in the loadFrame delegate method of webView.. am I right?

Gustavo?


On Jan 26, 2010, at 2:13 PM, Louis Gerbarg wrote:

> On Tue, Jan 26, 2010 at 7:52 AM, Gustavo Pizano  
> wrote:
> 
> I duno if its the best solution but it works.. Im open to hear other 
> approaches...
> 
> 
> This isn't a threading issue, everything is happening on a single thread. The 
> issue is that you have a synchronous API that depends on an asynchronous API 
> underneath. You have correctly deduced that one way to handle this is to spin 
> in a loop (in this case an event loop) waiting for the asynchronous API to 
> complete so you can return the data. In many cases that is a reasonable 
> solution, though if you get several of these things nested together or are 
> using weird runloop modes you can start to have some very complex behaviors. 
> You also potentially need to make sure any code in the call stack leading up 
> to that runloop reentrant, depending on exactly what you are doing.
> 
> Personally, I prefer to make my design asynchronous all the way up and down 
> the stack. So instead of implementing something like:
> 
> -(NSDictionary *)pListWithWebElements;
> 
> I might do:
> 
> - (void) updatePListWebElements; //Exact same IMP except it doesn't return 
> anything
> 
> and then in the load delegate:
> 
> #pragma mark LoadFrameDelegate.
> -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame{
>   //Your original code
>   
> 
>   [[NSNotificationCenter defaultCenter] 
> postNotificationName:@"PListWithWebElementsLoaded" object:self];
> }
> 
> which would then fire an NSNotification at the time it was updated, and I 
> would just register a notification handler to deal with it. Depending on the 
> exact nature and complexity of what is going on it may also be apropriate to 
> implement your own delegate protocol and make calls into the delegate just 
> like the system does with your delegates.
> 
> Louis 
> 

___

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: Centering a window on the *current* screen, not the *main* screen

2010-01-26 Thread Andreas Mayer


Am 26.01.2010 um 11:34 Uhr schrieb Graham Cox:

Traditionally, this has been at a position leaving one third of the  
space above and two thirds below, though I'm not sure if that's  
still currently the exact placing.




Yup, that's what the Human Interface Guidelines say:

http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/XHIGWindows.html#/ 
/apple_ref/doc/uid/2961-BACFHDHE


"For nondocument windows, the preference is to open new windows  
horizontally centered as shown in Figure 14-32. The vertical position  
should be visually centered: The distance from the bottom of the  
window to the top of the Dock (if it’s at the bottom of the screen)  
should be approximately twice the distance as that from the bottom of  
the menu bar to the top of the window."



Andreas___

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: BIG Thread problem (theorical).. need some advice.

2010-01-26 Thread Louis Gerbarg
On Tue, Jan 26, 2010 at 7:52 AM, Gustavo Pizano  wrote:

>
> I duno if its the best solution but it works.. Im open to hear other
> approaches...
>
>
This isn't a threading issue, everything is happening on a single thread.
The issue is that you have a synchronous API that depends on an asynchronous
API underneath. You have correctly deduced that one way to handle this is to
spin in a loop (in this case an event loop) waiting for the asynchronous API
to complete so you can return the data. In many cases that is a reasonable
solution, though if you get several of these things nested together or are
using weird runloop modes you can start to have some very complex behaviors.
You also potentially need to make sure any code in the call stack leading up
to that runloop reentrant, depending on exactly what you are doing.

Personally, I prefer to make my design asynchronous all the way up and down
the stack. So instead of implementing something like:

-(NSDictionary *)pListWithWebElements;

I might do:

- (void) updatePListWebElements; //Exact same IMP except it doesn't return
anything

and then in the load delegate:

#pragma mark LoadFrameDelegate.
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame{
  //Your original code
  

  [[NSNotificationCenter defaultCenter]
postNotificationName:@"PListWithWebElementsLoaded"
object:self];
}

which would then fire an NSNotification at the time it was updated, and I
would just register a notification handler to deal with it. Depending on the
exact nature and complexity of what is going on it may also be apropriate to
implement your own delegate protocol and make calls into the delegate just
like the system does with your delegates.

Louis
___

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: BIG Thread problem (theorical).. need some advice.

2010-01-26 Thread Gustavo Pizano
I did a solution like this

-(NSDictionary *)pListWithWebElements{
if(_exporter == nil){
_exporter = [[XWSC2WExporter alloc] init];
}

NSString * htmlString  = [_exporter 
generateExportedHTMLFromLayouts:_layoutsArray];
if(_webController == nil){
_webController = [[XWSPreviewWebController alloc] 
initWithWindowNibName:@"XWSPreviewWeb"];
[_webController set_parentController:self];
}   
[_webController showWindow:self];
[_webController set_htmlString:htmlString];
flagLoad = NO;

while ( !flagLoad && [[ NSRunLoop currentRunLoop ] 
runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]){
NSLog(@"WAITING");
}

return pListWithWebElements;
}

#pragma mark LoadFrameDelegate.
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame{
WebArchive * wa = [[frame dataSource] webArchive];
NSData * data = [wa data];
// uses toll-free bridging for data into CFDataRef and CFPropertyList 
into NSDictionary
CFPropertyListRef plist =  
CFPropertyListCreateFromXMLData(kCFAllocatorDefault, (CFDataRef)data,

   
kCFPropertyListMutableContainersAndLeaves,

   NULL);
// we check if it is the correct type and only return it if it is
if ([(id)plist isKindOfClass:[NSDictionary class]])
{
[self setPListWithWebElements:[(NSDictionary *)plist 
autorelease]];
}
else
{
// clean up ref
CFRelease(plist);
}

flagLoad = YES;
}


I duno if its the best solution but it works.. Im open to hear other 
approaches...

thanks 
Gustavo


On Jan 26, 2010, at 12:56 PM, Gustavo Pizano wrote:

> Hello all.
> I have this situation:
> I have a WebView which mainFrame Im loading form a NSString,  then Im 
> implementing the delegate :
> 
> -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;
> 
> to check when the frame finish loading I can generate a pList to return to 
> the caller. BUT this method its called only when the frame did load, as it 
> says., and Im returning the dicitonary before this method its even called.
> 
> this is what I have
> 
> -(NSDictionary *)pListWithWebElements{
>   if(_exporter == nil){
>   _exporter = [[XWSC2WExporter alloc] init];
>   }
>   
>   NSString * htmlString  = [_exporter 
> generateExportedHTMLFromLayouts:_layoutsArray];
>   if(_webController == nil){
>   _webController = [[XWSPreviewWebController alloc] 
> initWithWindowNibName:@"XWSPreviewWeb"];
>   [_webController set_parentController:self];
>   }   
>   [_webController showWindow:self];
>   [_webController set_htmlString:htmlString];
>   
>   return pListWithWebElements;
> }
> 
> #pragma mark LoadFrameDelegate.
> -(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame{
>   WebArchive * wa = [[frame dataSource] webArchive];
>   NSData * data = [wa data];
>   // uses toll-free bridging for data into CFDataRef and CFPropertyList 
> into NSDictionary
>   CFPropertyListRef plist =  
> CFPropertyListCreateFromXMLData(kCFAllocatorDefault, (CFDataRef)data,
>   
>
> kCFPropertyListMutableContainersAndLeaves,
>   
>NULL);
>   // we check if it is the correct type and only return it if it is
>   if ([(id)plist isKindOfClass:[NSDictionary class]])
>   {
>   [self setPListWithWebElements:[(NSDictionary *)plist 
> autorelease]];
>   }
>   else
>   {
>   // clean up ref
>   CFRelease(plist);
>   }
>   
> }
> 
> so form the first methohd when I reach the return statement, the ivar its nil 
> because it hasn't been initialized by the webframeload delegate.
> 
> What do I need to do to return the ivar initialized? this is my first time 
> encounter with a multithreading problem, Im totaly new to this topic, but I 
> undertand that I must somehow wait for one thread to finish to be able to 
> return the data on the main thread... am I wrong?
> 
> Also I dunno if this shall be here or in WebKit so please if you feel it 
> shouldn't be here let me know and I post it in the webKit dev List
> 
> Thanks a lot
> 
> Regards
> 
> Gustavo Pizano
> 

___

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

Please do not post adm

Re: Centering a window on the *current* screen, not the *main* screen

2010-01-26 Thread Oleg Krupnov
Thanks Graham,

>
> You need to consider what this really means. For example, what if a window is 
> placed so appears on more than one monitor at the same time?
>
> Actually, NSWindow already works this out - its -screen method returns the 
> screen it mostly is placed on (i.e. contains the largest intersected area). 
> That's handy.
>

I have actually considered this, and yes, I want my window to center
on the screen returned by [NSWindow screen].

>> I could write my own code to position the window, but I don't know how
>> to reproduce the recommended position of the centered window, which is
>> slightly above the center.
>
>
> Traditionally, this has been at a position leaving one third of the space 
> above and two thirds below, though I'm not sure if that's still currently the 
> exact placing.
>

You are right, except that, according to my experiment, it is one
fourth above and three fourths below.

I have written that code and it works identical to [NSWindow center],
as far as I can see. But maybe there are still caveats I'm unaware of.

Anyway, it's an annoyance that the [NSWindow center] uses [NSScreen
mainScreen] instead of [NSWindow screen]. I'd consider it a bug of
AppKit, indeed.

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


BIG Thread problem (theorical).. need some advice.

2010-01-26 Thread Gustavo Pizano
Hello all.
I have this situation:
I have a WebView which mainFrame Im loading form a NSString,  then Im 
implementing the delegate :

-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame;

to check when the frame finish loading I can generate a pList to return to the 
caller. BUT this method its called only when the frame did load, as it says., 
and Im returning the dicitonary before this method its even called.

this is what I have

-(NSDictionary *)pListWithWebElements{
if(_exporter == nil){
_exporter = [[XWSC2WExporter alloc] init];
}

NSString * htmlString  = [_exporter 
generateExportedHTMLFromLayouts:_layoutsArray];
if(_webController == nil){
_webController = [[XWSPreviewWebController alloc] 
initWithWindowNibName:@"XWSPreviewWeb"];
[_webController set_parentController:self];
}   
[_webController showWindow:self];
[_webController set_htmlString:htmlString];

return pListWithWebElements;
}

#pragma mark LoadFrameDelegate.
-(void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame{
WebArchive * wa = [[frame dataSource] webArchive];
NSData * data = [wa data];
// uses toll-free bridging for data into CFDataRef and CFPropertyList 
into NSDictionary
CFPropertyListRef plist =  
CFPropertyListCreateFromXMLData(kCFAllocatorDefault, (CFDataRef)data,

   
kCFPropertyListMutableContainersAndLeaves,

   NULL);
// we check if it is the correct type and only return it if it is
if ([(id)plist isKindOfClass:[NSDictionary class]])
{
[self setPListWithWebElements:[(NSDictionary *)plist 
autorelease]];
}
else
{
// clean up ref
CFRelease(plist);
}

}

so form the first methohd when I reach the return statement, the ivar its nil 
because it hasn't been initialized by the webframeload delegate.

What do I need to do to return the ivar initialized? this is my first time 
encounter with a multithreading problem, Im totaly new to this topic, but I 
undertand that I must somehow wait for one thread to finish to be able to 
return the data on the main thread... am I wrong?

Also I dunno if this shall be here or in WebKit so please if you feel it 
shouldn't be here let me know and I post it in the webKit dev List

Thanks a lot

Regards

Gustavo Pizano

___

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: Centering a window on the *current* screen, not the *main* screen

2010-01-26 Thread Graham Cox

On 26/01/2010, at 9:10 PM, Oleg Krupnov wrote:

> Now how do I center a window on the screen it currently shows on, on a
> multi-monitor Mac?

You need to consider what this really means. For example, what if a window is 
placed so appears on more than one monitor at the same time?

Actually, NSWindow already works this out - its -screen method returns the 
screen it mostly is placed on (i.e. contains the largest intersected area). 
That's handy.


> I could write my own code to position the window, but I don't know how
> to reproduce the recommended position of the centered window, which is
> slightly above the center.


Traditionally, this has been at a position leaving one third of the space above 
and two thirds below, though I'm not sure if that's still currently the exact 
placing.

--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: How to hide dock item and application menu?

2010-01-26 Thread Andreas Mayer


Am 25.01.2010 um 23:24 Uhr schrieb Jens Alfke:


This is not
useful to me as my req is to provide the option to user to hide/ 
unhide dock

and menu item.


You can't change that while your app is running. You have to modify  
your own Info.plist and then relaunch.


Well, you can transform a background-only application into a  
foreground application:


http://developer.apple.com/mac/library/documentation/Carbon/Reference/Process_Manager/Reference/reference.html#/ 
/apple_ref/c/func/TransformProcessType


This works as expected since 10.5.

http://www.cocoadev.com/index.pl?TransformProcessType


Andreas
___

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


Centering a window on the *current* screen, not the *main* screen

2010-01-26 Thread Oleg Krupnov
Hi,

It seems that [NSWindow center] centers the window on the *main* screen.

Now how do I center a window on the screen it currently shows on, on a
multi-monitor Mac?

I could write my own code to position the window, but I don't know how
to reproduce the recommended position of the centered window, which is
slightly above the center.

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: How to access iTunes using cocoa

2010-01-26 Thread Laurent Cerveau
You can use the scripting bridge framework which will send AppleEvent in a nice 
encapsulated way for you to iTunes

laurent

On Jan 26, 2010, at 10:48 AM, Ramesh P wrote:

> Hi,
> Is it possible to access iTunes from cocoa application?  Is there any open
> source framework for accessing iTunes?
> 
> Thanks in advance,
> Ramesh.P
> ___
> 
> 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/lcerveau%40me.com
> 
> This email sent to lcerv...@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


How to access iTunes using cocoa

2010-01-26 Thread Ramesh P
Hi,
Is it possible to access iTunes from cocoa application?  Is there any open
source framework for accessing iTunes?

Thanks in advance,
Ramesh.P
___

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


Change background color of UITabBarItem and UITabBar

2010-01-26 Thread Angelica Grace Tanchico

Hello, 

Is it possible to change color of UITabBar instead of the default color black?
And also is it possible to change background color of UITabBarItem's background
color instead of default color blue? If yes, how?

Thanks in advance!

-Angie
  
_
New Windows 7: Simplify what you do everyday. Find the right PC for you.
http://windows.microsoft.com/shop___

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