re: CoreData database sharing and migration

2010-03-18 Thread Ben Trumbull
> On 17/3/10, cocoa-dev-requ...@lists.apple.com wrote:
> 
>> Do you mean "more than one application simultaneously on more than one 
>> physical computer over NFS/AFP/SMB" ?  Don't do that.
> 
> When did that become the official policy, Ben?

The short answer is in 10.6.

The longer answer is that there are two classes of problems, one for NFS and 
one for AFP/SMB.  

For NFS, the protocol does not reliably allow for clients to maintain their 
local file caches coherently with the server in real time.  Only the newest NFS 
servers even respect file cache coherency around byte range file locks **at 
all**.  Unfortunately, the latest protocol doesn't mesh well with SQLite or 
most other existing incrementally updated file formats.   Many deployed NFS 
servers and clients only provide on "close to open" coherency.  File 
modification timestamps on NFS severs may (or may not) provide accuracy better 
than 1.0 seconds.  And so forth.  There's also no good way to perform a cache 
bypassing file read on OSX or selectively evict ranges of files from the local 
file cache by hand.  We churned on this for a while with various teams, and 
there wasn't a good solution for multiple machines simultaneously accessing an 
SQLite db file (or most other incrementally updated binary file formats).  By 
"good" I mean a solution that worked reliably and didn't make other more 
important things work less well.  

NFS is just not a free Oracle.  Software that wants real time distributed cache 
coherency needs to use IPC and mange the problem themselves.   It is trivial to 
write a program that writes to a file on NFS and sends the same update to its 
clone on another machine via IPC and for its clone to verify that NFS cache 
coherency indeed fails regularly (e.g. file read bytes != IPC read bytes).  
This is what I mean by real time distributed cache coherency.

For AFP & SMB, the problem is different.  These FS do not support POSIX 
advisory byte range locks at all.  They only support mandatory locks.  
Consequently, they never cache data read from files with any existing locks at 
all.  No file caching means all the I/O is slow.  Painfully slow.  AFP over 
Airport without file caching is bad.  The I/O throughput on a file free of 
locks on AFP is close to 100x better than a file with a single byte locked that 
isn't even anywhere near where you are reading.  For nearly all Mac OS X 
customers (sadly not you) achieving a near 100x performance boost when 
accessing database files on an AFP or SMB mount (like their home directory in 
educational deployments) is pretty huge. 

So we focused on making the experience that could work well work even better.  
10.6 is a significantly better network FS client as Apple applications like 
Mail don't slam the servers with byte range lock requests all the time (good 
for NFS), and on AFP also gets to use local file caching.

To address both sets of problems on all network FS, we enforce a single 
exclusive lock on the server for the duration the application has the database 
open.  Closing the database connection (or logging out) allows another machine 
to take its turn.  This behavior was supposed to be opt in for Core Data apps, 
but on 10.6.2 is not.

> I'm doing that with some success.  For the past three years, my 
> client's point of sale system has been connecting from five 
> machines to a single database on a Synology network drive over 
> afp.  I had to write some code to periodically get the latest 
> values from the database during idle time.  That was a little 
> complicated but its working well now.

It can work technically on AFP.  However, the distributed cache coherency 
problem is avoided by these network FS because they don't do any file caching 
on files with locks.  Your server set up and networking hardware is pretty 
sophisticated compared to most so the performance is adequate.  As an engineer, 
I would wish AFP over VPN over Airport was the more uncommon deployment 
scenario, but sadly not.

> There are mysterious but harmless optimistic locking errors once 
> in a while where no attributes appear have changed -- just to 
> keep me on my toes, along with an occasional real data collision 
> (two staff members carelessly editing the same object) but we've 
> had no real issues in a year or so.

Those mysterious updates are probably version numbers being bumped because the 
object's participation in a to-many relationship, either outgoing or incoming, 
changed.

> However, 10.6.2 has a bug where only one machine can connect to 
> a Core Data store (its likely a sqlite-level connection issue -- 
> but I'm not sure).

ADC did pass your bug report along to us, and it is a backward binary 
compatibility issue, and a regression from 10.6.0.  It will be fixed in a 
future update.  You'll get the 10.5 performance characteristics, however.

> So, for a while we were down to one 
> machine.  I eventually had to roll the five machines back to 
> Leopard.  That remains a PR nig

NSBrowser and tab order

2010-03-18 Thread Andrew James
I have a nib file set up in Interface Builder with a window containing a single 
NSBrowser.

I have set the NSBrowser as the window's initialFirstResponder... but for some 
reason when the window is displayed the NSBrowser does not receive keyboard 
focus and will not receive keyboard focus until I click on it.

I'm hoping I'm missing something trivially easy.

Cheers,
--aj


  
___

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

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


Nview setWantLayer method breaks my custom button cell

2010-03-18 Thread Gustavo Pizano
Hello.

I have a Custom Button Cell, and its corresponding CustomButton, When I use 
these component in any other cell they work perfect, when I click the button, 
my NSButonCell's overrode method
- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView 
*)controlView{
makes the drawing of the button when the user clicks it, so it change to the 
proper theme color.

Now I set up a view with a layer from a NSTextField label, and added a bloom 
animation like these. taken form apple docs, and then I set the view to [self 
setWantLayer:YES];

CIFilter * filter = [CIFilter filterWithName:@"CIBloom"];

[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:3.0f] 
forKey:@"inputRadius"];
[filter setName:@"pulseFilter"];
[modTitleLayer setFilters:[NSArray 
arrayWithObjects:filter,nil]];

// The selectionLayer shows a subtle pulse as it
// is displayed. This section of the code create the pulse 
animation
// setting the filters.pulsefilter.inputintensity to range from 
0 to 2.
// This will happen every second, autoreverse, and repeat 
forever
CABasicAnimation* pulseAnimation = [CABasicAnimation animation];
pulseAnimation.keyPath = @"filters.pulseFilter.inputIntensity";
pulseAnimation.fromValue = [NSNumber numberWithFloat: 0.0];
pulseAnimation.toValue = [NSNumber numberWithFloat: 1.0];
pulseAnimation.duration = 1.0;
pulseAnimation.repeatCount = 1e100f;
pulseAnimation.autoreverses = YES;
pulseAnimation.timingFunction = [CAMediaTimingFunction 
functionWithName:

 kCAMediaTimingFunctionEaseInEaseOut];
[modTitleLayer addAnimation:pulseAnimation 
forKey:@"pulseAnimation"];

But my highlight method does no custom drawing, actually its being called, but 
it does nothing.

any ideas what might be happening? maybe something missing in the higlighl 
method?
this is what Im doing there: Using a gloss drawing thanks for Cocoa with love 
and Mat Gallagher

if(flag){
NSGraphicsContext *graphicsContext = [NSGraphicsContext 
currentContext];
[graphicsContext saveGraphicsState];
NSBezierPath * path = [NSBezierPath 
bezierPathWithRoundedRect:NSInsetRect(cellFrame,1.0, 1.0) xRadius:10.0 
yRadius:10.0];
[path addClip];

DrawGlossGradient(
  [graphicsContext 
graphicsPort],
  [NSColor 
colorWithCalibratedRed:0.0 green:0.1522 blue:0.4130 alpha:1.0],
  cellFrame);
//[self setBackgroundColor:[NSColor 
colorWithCalibratedRed:(CGFloat)0.3 green:(CGFloat)0.3 blue:(CGFloat)0.3 
alpha:(CGFloat)0.3]];
 

//[_higLightGradient drawInBezierPath:path 
relativeCenterPosition:NSZeroPoint];
//[_higLightGradient drawInBezierPath:path angle:90.0];
[graphicsContext restoreGraphicsState];
if(_fontMask == NSBoldFontMask){
//  cellFrame.origin.y += 5.0f; //This is the 
Bold font mask value
}

[super drawWithFrame:cellFrame inView:controlView];

}
else {
[self setBackgroundColor:nil];
}

if after setting up the animation I place [self setWantLayer:NO]  the highlight 
method draws the color of the button when pressed.

Thanks in advance


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: Deprecated APIs

2010-03-18 Thread charisse napeÿfffff1as
Hello,

I already found the cause of my problem. The api I used for 10.6 has a 
NS_BLOCKS_AVAILABLE condition that is why my app crashes. Its not because of my 
OS Version conditions


Please close this issue.





From: Greg Parker 
To: Steve Christensen 
Cc: cocoa-dev@lists.apple.com
Sent: Thursday, February 25, 2010 4:04:35
Subject: Re: Deprecated APIs

On Feb 24, 2010, at 11:36 AM, Steve Christensen wrote:
> On Feb 24, 2010, at 11:04 AM, Bill Bumgarner wrote:
>> On Feb 23, 2010, at 8:57 PM, Steve Christensen wrote:
 That code uses blocks, though, which implies that it will be compiled 
 using a later version of Objective-C. Will that code really run on older 
 versions of OS X?
>>> 
>>> The compile-time conditional assumes that you're building against the 10.6 
>>> SDK (or later). Obviously if you're going to support both cases, you'll 
>>> need to use a compiler configuration that is compatible with all the OS 
>>> versions you plan to support.
>> 
>> There are symbols *sometimes* emitted by compilation of blocks that won't be 
>> available on prior releases of Mac OS X and, thus, will cause a dyld error 
>> on launch on those platforms.
>> 
>> Be careful.
> 
> Is this the case even if you're weak-linking against 10.6, i.e., you're 
> setting the deployment target to 10.4? And is this a blocks-specific issue? I 
> don't recall ever having problems with other cases when I wanted to call a 
> newer API method conditional on the OS version.

In the blocks case, the symbol references are in the Objective-C metadata and 
the guts of the block itself. Currently it's Officially Unsupported, even with 
weak linking. In practice, it may or may not work, depending on exactly what 
your code looks like and whether I've forgotten anything. 

On some architectures, weak-linking to an Objective-C class means the 
Objective-C metadata will have a NULL pointer in it at runtime when the class 
is absent. On some OS versions, the Objective-C runtime will crash if it sees 
those NULL pointers. Providing better support for this is in progress, but of 
course that won't help the existing old OS versions.

If you can verify that the app launches on all OS versions and all 
architectures you care about, and you're very careful not to do anything at all 
with any block object on the wrong OS, then you might be safe.


-- 
Greg Parkergpar...@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/cnapenas%40yahoo.com

This email sent to cnape...@yahoo.com



  Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com. 
http://mail.promotions.yahoo.com/newdomains/aa/
___

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

Please do not post 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: User-space threads and NSAutoreleasePool

2010-03-18 Thread Jean-Daniel Dupas

Le 18 mars 2010 à 07:41, BJ Homer a écrit :

> On Wed, Mar 17, 2010 at 11:47 PM, Greg Guerin  wrote:
>> 
>> Two main questions come to mind:
>> 
>> Q1. What are you trying to accomplish?
>> Q2. Why do you think this would work?
>> 
>> More on Q1:  You said you need user-space threads, but you gave no reason
>> or rationale.  If it's because you need 500 threads, then why do you need
>> 500 threads?  Exactly what are you trying to accomplish?
>> 
> 
> Q1: What am I trying to accomplish?
> 
> In this particular case, I'm working on an application that sends very large
> HTTP PUT requests over an HTTP connection in a pipelined fashion. For
> performance reasons, the server prefers to delay acknowledgement of these
> files until it can process them in large groups. (Before it can send an ack,
> it must update a database. Doing 400-500 single updates is far slower than
> doing one transaction updating 400-500 records.) Hence, we pipeline the HTTP
> requests, starting transfer of the second before the first one is finished.
> There are a large number of servers that don't handle pipelining, but we'll
> only we talking to one particular server, and we know it does.
> NSURLConnection does not (according to various mailing list messages)
> implement pipelining, allegedly due to the lack of server support. There's
> some suggestion that CFHTTPStream does support pipelining, but there's
> little to no documentation about it, and I don't know if it will handle 500
> at once.
> 
> If you can use user-space threads, this becomes simple; you send the first
> file, and then when you're waiting for the ACK, you swap out and let another
> file start sending. When the ack is received, the first user-thread is
> rescheduled. We've developed an extremely high-performance cross-platform
> library that handles all the scheduling directly. Then we've built another
> library around that that handles all the particulars of our server protocol.
> 
> At the moment, I'm converting our OS X client to use this library. That's my
> immediate motivation; if I can use an existing library, I'll save a large
> amount of time, get a big performance boost, and have less code to test. To
> a large extent, it is already working.
> 

That's why non-blocking/async API where developed. I don't see what prevent you 
to use one single thread and kevent like API (except that you would not be able 
to reuse the existing library).

>> More on Q2: The ucontext(3) functions appear to me to be more intended for
>> signal-handling, specifically for alt-signal-stack handling.  The nature of
>> signals is that they eventually return (nested), they don't work in a
>> round-robin or any other scheduling.  That's not a question, just prep.  The
>> question is this: Are you sure the Objective-C runtime is compatible with
>> ucontext user-threads?  There are lots of things you can't do in
>> signal-handlers, not even handlers written in plain C (ref: man sigaction,
>> the list of safe functions).  If you can't call malloc() in a signal-handler
>> (and I'm pretty sure you can't), what do you expect to happen with your
>> Objective-C user-threads, since object allocation is tied to malloc()?

Not only object allocation, but also message sending, as in case of cache miss 
while sending a message, the runtime may allocate additional cache space to 
store informations. You cannot safely use obj-c in signal handler.


-- Jean-Daniel




___

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

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

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

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


re: Multiple validation errors. Why?

2010-03-18 Thread Ben Trumbull
> I have a core data application. One entity is "Hit". This entity typically 
> has no instances when the application starts, and gets populated during the 
> execution of the program. All of the instances appear to be OK when viewed in 
> a TableView. Some or all instances may get deleted before the application 
> quits. If any instances remain when the app quits, I get a "multiple 
> validation errors occured" message. The console has no error messages. In 
> debugging, I have gone so far as supplying no data at all when adding any 
> instances, so they get created with default values only. Still I get the 
> error message. Some attributes are strings, some are 16 bit integers, and 
> some are 32 bit integers. The string defaults are empty strings, and the 
> integer defaults are zero. I am creating Hit instances with this method

The NSError has an -userInfo dictionary with at least some answers to your 
questions in it.

- Ben

___

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

Please do not post 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: User-space threads and NSAutoreleasePool

2010-03-18 Thread Manfred Schwind
> The problem is that when you call swapcontext() to switch the user-thread
> running on a kernel-thread, the NSAutoreleasePool stack is not swapped out.
> It remains rooted in thread-local storage. As a result, serious problems
> result. Let me give an example.
> 
> - (void)doStuff {
>  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
>  // do some stuff that calls swapcontext()
>  [pool drain];
> }
> 
> -doStuff calls swapcontext(), trusting that the other user-thread will
> eventually call swapcontext() and restore the flow to this user-thread.
> 
> Further, assume that the second user-thread also allocates an autorelease
> pool before returning. Despite being on separate user-threads, there is
> still only one kernel-thread. Since the autorelease pool stack is in
> (kernel-)thread-local storage, the second user-thread's pool goes on top of
> the same stack:
> 
> Autorelease pool stack: pool_from_uthread1 -> pool_from_uthread2
> 
> Now, when we swap back to the first user-thread, it will release its
> autorelease pool. This, naturally, releases the second pool as well. When we
> swap back to the second user-thread, anything that was autoreleased is now
> dead and gone.

In my opinion, the only solution is NOT to have any additional 
Autorelease-Pools "active" when switching the context.
As far as I understand user space contexts, you have total control about when a 
context switch happens. And you also have total control about your local 
Autorelease-Pools in your code. So just don't "span" Autorelease-Pools over a 
context switch:

- (void)doStuff {
 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
 // do some stuff
 [pool drain]; // make sure not to have additional Autorelease-Pool

 // do some stuff that calls swapcontext()

 pool = [[NSAutoreleasePool alloc] init]; // now you can have one again
 // do some stuff
 [pool drain];
}

Depending on the complexity of your app this may be a bit tricky to find. But 
"local" Autorelease-Pools are usually kept around small amounts of code. Just 
don't switch contexts while inside these code areas. ;-)

Regards,
Mani
--
http://mani.de - friendly software
iVolume - listen to music hands-free
LittleSecrets - the encrypted notepad
Sahara - sand in your pocket
Watchdog - baffle the curious

___

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

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


Detecting if you're being debugged

2010-03-18 Thread Peter Hudson

Technical Q&A QA1361
Detecting the Debugger

Does this code report on my app being debugged by any third party,  
even when the app has been stripped of symbols ?

Would it work irrespective of the debugging tool used ?

Peter

___

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

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

2010-03-18 Thread Manfred Schwind
> Still, CGFloat is a pain when using the 64 to 32 bit truncation warning
> and doing something like:
> 
> NSRect foo = NSMakeRect (1.0, 2.0, ...)
> 
> it will warn building as 32 bit since it's implicitly converting double
> to float.  You could do:
> 
> NSRect foo = NSMakeRect ((CGFloat)1.0, (CGFloat)2.0, ...)
> 
> But that's too ugly IMHO.  My solution is:
> 
> NSRect foo = NSMakeRect (1.0f, 2.0f, ...)
> 
> which has no warnings in 32 nor 64.  It would be nice if we could write
> something like:
> 
> NSRect foo = NSMakeRect (1.0cg, 2.0cg, ...)

You can do it e.g. this way:

#define CGF(x) ((CGFloat)(x))
...
NSRect foo = NSMakeRect (CGF(1), CGF(2), CGF(4.5), ...)

Mani
--
http://mani.de - friendly software
iVolume - listen to music hands-free
LittleSecrets - the encrypted notepad
Sahara - sand in your pocket
Watchdog - baffle the curious

___

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

Please do not post 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: NSBrowser and tab order

2010-03-18 Thread Corbin Dunn
Aj -- I believe this was a bug fixed in 10.6; maybe 10.5. What OS are you on?

The work around is to set it up in awakeFromNib.

corbin

On Mar 18, 2010, at 1:15 AM, Andrew James wrote:

> I have a nib file set up in Interface Builder with a window containing a 
> single NSBrowser.
> 
> I have set the NSBrowser as the window's initialFirstResponder... but for 
> some reason when the window is displayed the NSBrowser does not receive 
> keyboard focus and will not receive keyboard focus until I click on it.
> 
> I'm hoping I'm missing something trivially easy.

___

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

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

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

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


Re: Multiple validation errors. Why?

2010-03-18 Thread Sean McBride
On Wed, 17 Mar 2010 21:05:06 -0700, Lynn Barton said:

>the app quits, I get a "multiple validation errors occured" message. The
>console has no error messages.

Stick this in your app delegate:

- (NSError*)application:(NSApplication*)application
   willPresentError:(NSError*)error
{
if (error)
{
NSDictionary* userInfo = [error userInfo];
NSLog (@"encountered the following error: %@", userInfo);
Debugger();
}

return error;
}

--

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


altering IKSaveOptions?

2010-03-18 Thread Brian Postow
I have an ImageKit program that needs to be able to save images, so I'm using 
the IKSaveOptions accessory view, to allow the user to choose a file type, etc.

However, I want to remove some of the options, and add a checkbox to the panel 
for TIFFs. Alternatively, I want to add a type of file.  However I can't figure 
out how to do this. I assume I'm going to have to subclass off of IKSaveOptions 
and over-ride something,  but I can't find any sample code or documentation 
that tells me how to do this.

thanks


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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

Please do not post 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: User-space threads and NSAutoreleasePool

2010-03-18 Thread Michael Ash
On Wed, Mar 17, 2010 at 11:11 PM, BJ Homer  wrote:
> Okay, so that's the setup. Obviously, the problem is that the two user-space
> threads are sharing an autorelease pool stack that is intended to be
> thread-local. My question, then, is whether there exists a way to get and
> set the autorelease pool stack, so that before calling swapcontext(), I
> could put it in a state appropriate for this user-level thread? I assume it
> is being stored in thread-local storage, but it's not in the NSThread
> threadDictionary, which means it's probably set using pthread_setspecific.
> Accessing that value would require the key used to store it, but naturally I
> don't have access to that. So is there some existing function call that
> allows such access?

I did some experimenting with this sort of thing back in the 10.4
days, using custom userspace threading code (but it should be pretty
much the same as this library call). I came to the conclusion that it
was impractical.

Cocoa keeps around a lot of thread-specific state. In addition to
autorelease pools, you also have exception handlers, graphics
contexts, and possibly others. You also have implicit thread-specific
state like runloops and various non-reentrant code that may be calling
yours when you switch to another user-level thread. And Cocoa assumes
on a pretty deep level that the only threading you're doing is
pthreads, and things built on top of pthreads like NSThread.

In short, I think you're doomed. Any code you call in your user-level
threads needs to be minimally aware of them and compatible with them
(at least to the extent of not assuming pthreads), so you can't just
call arbitrary libraries. I'm afraid Cocoa falls into that category.

Since you mention in another message that this is portable,
cross-platform code, why do you need to call Cocoa from the user-level
threads at all? Separate your code into cross-platform code that does
this swapcontext stuff, and Mac-specific code that doesn't, and you
should be good.

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


Re: NSBrowser and tab order

2010-03-18 Thread Keary Suska
On Mar 18, 2010, at 8:40 AM, Corbin Dunn wrote:

> Aj -- I believe this was a bug fixed in 10.6; maybe 10.5. What OS are you on?
> 
> The work around is to set it up in awakeFromNib.

Is there any way to tab into an NSBrowser in 10.4? It seems that once the 
browser loses focus, you can't get focus except by clicking...

> On Mar 18, 2010, at 1:15 AM, Andrew James wrote:
> 
>> I have a nib file set up in Interface Builder with a window containing a 
>> single NSBrowser.
>> 
>> I have set the NSBrowser as the window's initialFirstResponder... but for 
>> some reason when the window is displayed the NSBrowser does not receive 
>> keyboard focus and will not receive keyboard focus until I click on it.
>> 
>> I'm hoping I'm missing something trivially easy.


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

___

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

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

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

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


Re: User-space threads and NSAutoreleasePool

2010-03-18 Thread Jens Alfke


On Mar 18, 2010, at 8:35 AM, Michael Ash wrote:


Cocoa keeps around a lot of thread-specific state. In addition to
autorelease pools, you also have exception handlers, graphics
contexts, and possibly others.


Yup. I quickly ran into this in 2008 when experimenting with  
implementing coroutines (which use the same ucontext stuff.)  
Lightweight threads/coroutines can be very useful for highly scalable  
systems — that's one reason there's a lot of hype about Erlang these  
days — but you can't graft them on top of a runtime that doesn't know  
about them and already has its own threading support.


I haven't had a chance yet to use the Grand Central / dispatch-queue  
stuff in 10.6, but I believe that it offers some similar  
functionality, like being able to create huge numbers of concurrent  
operations without having each one create a kernel thread.


—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: Threads Question

2010-03-18 Thread Matt Neuburg
On Wed, 17 Mar 2010 10:36:40 -0400, Philippe Sismondi 
said:
>Because the length of time that this secondary task takes is highly variable, I
want to be able to cancel its processing from the main app. So, I want to launch
the secondary task in a separate thread to keep the main runloop responsive.
(This is of course a very common GUI issue.)

This is not a direct answer to your question, but my experience is that
using NSOperationQueue and some form of NSOperation is a very good way to
implement this. I use this approach any time I want a lengthy, cancellable
process that leaves the GUI responsive. It keeps the threading issues very
clear, and because the operation and the operation queue are ordinary
objects, they can be retained and you can return to them at any time, which
makes it very easy to collect the results when the operation ends, or to
cancel the operation in the middle (in response to the user cancelling, for
example).

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


Re: Detecting if you're being debugged

2010-03-18 Thread Kyle Sluder
On Thu, Mar 18, 2010 at 4:48 AM, Peter Hudson  wrote:
> Does this code report on my app being debugged by any third party, even when
> the app has been stripped of symbols ?

It does precisely what it claims to do: asks the kernel if the
P_TRACED flag is set on your process, which means a debugger has used
the kernel to attach to your process.

> Would it work irrespective of the debugging tool used ?

If you think this is going to help you avoid piracy, it's not. OS X
has a flag (PT_DENY_ATTACH) that the kernel checks for when a debugger
asks to attach to a process. If that flag is set, the kernel refuses
to allow the debugger to attach. iTunes famously does this to prevent
people from inspecting the operations of the DRM system. It's a
trivial matter to patch the kernel to not respect this flag, and it
would be equally trivial to patch the kernel to not inform you of a
debugger's presence even if you asked.

Barring that, I'd just run your app in a virtual machine and examine
it directly.

--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: NSTrackingArea Problem

2010-03-18 Thread Richard Somers

Submitted this issue, Apple Bug ID# 7767875.

--Richard

___

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

Please do not post 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: Detecting if you're being debugged

2010-03-18 Thread Jonathan del Strother
On 18 March 2010 18:03, Kyle Sluder  wrote:
> On Thu, Mar 18, 2010 at 4:48 AM, Peter Hudson  wrote:
>> Does this code report on my app being debugged by any third party, even when
>> the app has been stripped of symbols ?
>
> It does precisely what it claims to do: asks the kernel if the
> P_TRACED flag is set on your process, which means a debugger has used
> the kernel to attach to your process.
>
>> Would it work irrespective of the debugging tool used ?
>
> If you think this is going to help you avoid piracy, it's not. OS X
> has a flag (PT_DENY_ATTACH) that the kernel checks for when a debugger
> asks to attach to a process. If that flag is set, the kernel refuses
> to allow the debugger to attach. iTunes famously does this to prevent
> people from inspecting the operations of the DRM system. It's a
> trivial matter to patch the kernel to not respect this flag, and it
> would be equally trivial to patch the kernel to not inform you of a
> debugger's presence even if you asked.


Can't you just set a breakpoint on ptrace() that just automatically
returns 0, or has that stopped working?  I used to use that trick to
debug my iTunes visualizer, no kernel hacking needed.
___

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

Please do not post 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: Directory to save file in NSSavePanel

2010-03-18 Thread Corbin Dunn

On Mar 17, 2010, at 10:40 PM, Nikhil Khandelwal wrote:

> Thanks a lot for your help.
> I implemented the behavior by using "runmodalForDirectory: file:". In this I 
> took a bool variable which is false for first time and then true once save 
> panel is opened. For first time I used "setDirectory:@'Documents'" and if 
> user  changed the location then "[savepanel directory]" and it is working 
> fine for me on 10.5 and 10.6.
> 

Well -- you shouldn't have to do that. It should just work if you use 'nil'. If 
you are just using a BOOL, it will make it happen the first time the app 
launches, every time. It won't persist across app launches. I think the problem 
you are running into is the user defaults. Try using nil, and moving aside your 
com.whatever.plist from the Preferences directory for testing.

corbin



> Thanks once again.
> ---Nikhil
> 
> 
> -Original Message-
> From: Corbin Dunn [mailto:corb...@apple.com]
> Sent: Wednesday, March 17, 2010 10:43 PM
> To: Matt Neuburg
> Cc: Nikhil Khandelwal; cocoa-dev@lists.apple.com
> Subject: Re: Directory to save file in NSSavePanel
> 
> 
> On Mar 17, 2010, at 9:39 AM, Matt Neuburg wrote:
> 
>> On Wed, 17 Mar 2010 13:40:35 +0530, Nikhil Khandelwal
>>  said:
>> 
>>> I am using NSSavePanel in my application. I am using "runModal" on this to
>>> show the save panel. The default location it shows to save the file is
>>> "Desktop" which I want to change to "Document". I tried 
>>> "runModalForDirectory"
>>> as well however it uses the given file path as save location always. 
>>> Basically
>>> I want NSSavePanel to use "Documents" as default save location and if user
>>> change the location while saving the file, next time NSSavePanel should 
>>> shows
>>> the changed location to save the file.
>> 
>> If you're willing to be Snow Leopard only, a combination of directoryURL and
>> setDirectoryURL might work. It's a little tricky otherwise because Mac OS X
>> does automatically remember the last place the user saved, so the idea is to
>> stay out of its way in that case. That info is kept in your user defaults so
>> you might be able to examine it. m.
> 
> Actually, the behavior Nikhi requested is the default behavior if you pass 
> 'nil' for the directory in the runModalForDirectory methods (or use it for 
> setDirectoryURL:)
> 
> If you are using nil, it should default to Documents the first time. If it 
> didn't, then you probably need to wipe some user defaults (possibly in the 
> global domain and for the app).
> 
> 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


Manually adding objects to NSArrayController

2010-03-18 Thread Jenny M
Hi all, I'm having a problem adding the appropriate objects to an
NSArrayController. For some strange object model reasons, I will
probably need to set this by hand, but I'm having issues.

Back to my silly object discussions... before, it was about an
NSTreeController which I did get resolved, but now it's about an Array
Controller.

Alpha >> has multiple Betas >> has multiple Deltas
I need an NSPopUpButton to contain all of the Deltas for the one
Alpha. Right now the NSPopUpButton is bound alright to the
NSArrayController. The default NSArrayController setup seems to
automatically pull *all* Delta types, NOT just the ones that exist
under that Alpha, so I'm trying to do it manually.

What I tried to do is reference the NSArrayController in my code, and
manually add all objects to the array controller, and that's where I'm
failing. On the surface it seems to work fine, because my log
statements indicate that I'm iterating through and adding only the
small subset of Deltas. But the array controller isn't being set with
the content!

Here's a code snippet:
getDeltas Method{}
...make nsmutable set of deltas...
[deltasController addObjects:[deltaItems allObjects]];
NSLog(@"number of items in array: %u", [deltaItems count]); // this
returns 3
NSLog(@"number of items in array controller: %u", [[deltasController
arrangedObjects] count]); // this returns 0

So the deltaItems array is fine, but calling addObjects on the array
controller is not *actually* setting! I also tried the setContent
method with the same results.

Also interestingly, when I go back to the parent item and try to see
how many items the array controller has (with the same log statement
as the second one above), it returns null, not 0. So is it somehow not
initialized yet in the method I'm working in??

Any help is appreciatedthanks
___

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

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


AddressBook framework with remote contacts?

2010-03-18 Thread A.M.
Hello,

We are interested in using the AddressBook framework (specifically, the people 
picker view) but we haven't found a way with the CocoaPeoplePicker code example 
to show remote contacts (via LDAP, Exchange, or CardDAV) under 10.6. Does the 
Address Book framework not support remote contacts? 

It seems that AppleScript will not search any remote contact databases either. 
Is there any way we can allow the user to pick a contact in a shared contact 
database?

Cheers,
M___

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

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


Printing an NSDocument

2010-03-18 Thread Brian Postow
I'm trying to print a document. The document is an array of NSImageReps, or a 
single NSPDFImageRep, which has multiple pages. I'm having trouble figuring out 
how to use the NSPrintOperation class to print this.  

The NSPrintOperation seems to need an NSView to print. Do I need to manually 
add each image into the view at a calculated position and then let it do the 
pagination? that seems like it isn't in the spirit of Cocoa... is there some 
technique that I'm missing?

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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

Please do not post 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: User-space threads and NSAutoreleasePool

2010-03-18 Thread Ben Trumbull
> The problem is that when you call swapcontext() to switch the user-thread
> running on a kernel-thread, the NSAutoreleasePool stack is not swapped out.
> It remains rooted in thread-local storage. As a result, serious problems
> result. Let me give an example.
> 
> - (void)doStuff {
>  NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
>  // do some stuff that calls swapcontext()
>  [pool drain];
> }

That doesn't work correctly with regular threads, pthreads, GCD or any other 
concurrency pattern.  The autorelease pool needs to be pushed and popped within 
the context of the asynchronous subtask.  The original thread of control needs 
its own pool, and you cannot rely upon autorelease to keep objects alive across 
asynchronous task boundaries.  You will need to be careful to ensure that the 
sending thread transfers ownership of a retain to the receiving thread which 
releases it.  Not autoreleases it.

It would need to conceptually be:

- (void)doStuff {
 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
// some stuff Before
[pool drain];

 // do some stuff that calls swapcontext(), and has it's only scoped 
autorelease pool

pool = [[NSAutoreleasePool alloc] init];
// some more stuff After
 [pool drain];
}

Object you want to keep alive across drains should be retained and later 
released.  

Autorelease pools are cheap.  Make more.  A lot more.  If you have places where 
that doesn't work with coroutines then don't leak important objects into 
autorelease pools.  Either don't create them that way, or retain them again, 
and release them after you can verify the autorelease pool was destroyed.

> Using kernel-level
> threads is, naturally, simpler, but due to the cost of kernel-level context
> switches, they don't scale well. (You just can't run 500 threads at once
> very well.) User-space threads require more programmer attention, certainly,
> but also allow certain programming models that can't be done otherwise. For
> example, they can be used for coroutines, cooperative threading, or all
> sorts of esoteric-yet-sometimes-useful effects.

That's true, but I'm not sure it's relevant for the "I wish I had 500 threads 
to handle this web server communication" task.  There are a lot of different 
ways to organize the tasks as inert data that can be processed cooperatively by 
a set of active worker threads.

The mental model of each task being its own little world and a thread is nice, 
but it's also artificial.  You can reorganize the relationship between active 
workers and command data.  Nothing is stopping you from that except a 
preconception that tasks and threads must have a 1:1 correspondence.

You could create a finite state machine to process a queue of the tasks as 
inert command structures and firing up 8 of those finite state machines on 
their own dedicated normal threads on your Mac Pro.  The semantic effect will 
be similar to user threads, yet you won't run into all these crazy problems.  
Destroying thread local storage and its affect on autorelease pools is just 
your first problem stuffing Cocoa into swapcontext()

This point from Mike is particularly apt:

> Since you mention in another message that this is portable,
> cross-platform code, why do you need to call Cocoa from the user-level
> threads at all? Separate your code into cross-platform code that does
> this swapcontext stuff, and Mac-specific code that doesn't, and you
> should be good.

You could use a sandboxing approach like Safari and have your cross platform 
code run in a background CLI and talk to the GUI app over IPC.  No Cocoa in the 
CLI and no user threads in the GUI app.  

Pretty sure, though, you'd get better performance conceptually restructuring 
the task / actor relationship.  The cooperative finite state machine approach 
along with a prioritized queue can provide soft real time performance with 
thousands of task objects ... every second.  That's basically what some older 
MMORPG servers did before people went wild with distributed computing.

- Ben

___

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

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

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

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


Hit testing on NSTextField with custom cells

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

But if I substitute my subclass in for an NSTextField's NSTextFieldCell, I 
never get the hit. How can I get this to work?

___

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

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

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

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


Re: NSBrowser and tab order

2010-03-18 Thread Andrew James
Yup you got it.  I actually tracked down an Apple doc in regards to that last 
evening.

I did go ahead and set it up correctly in awakeFromNib as follows:

// DUE to NSBrowser bug in regards to its implementation
// of acceptsFirstResponder, forcibly load it and then
// make it the first responder
[ midiInBrowser loadColumnZero ];
[ [ selfwindow ] makeFirstResponder: midiInBrowser ];

I did have a bit of a research project in that setInitialResponder did not 
result in desired behavior but makeFirstResponder did.  From the little bit I 
could glean from setInitialResponder it seems like this call merely "caches" an 
NSResponder to be set via makeFirstResponder at a later date.

Given that, I can only assume that within awakeFromNib, I'd passed the "later 
date" where setInitialResponder could "cache" usefully.

Always a learning experience. :)

Cheers,
--aj




From: Corbin Dunn 
To: Andrew James 
Cc: list-cocoa-dev 
Sent: Thu, March 18, 2010 7:40:06 AM
Subject: Re: NSBrowser and tab order

Aj -- I believe this was a bug fixed in 10.6; maybe 10.5. What OS are you on?

The work around is to set it up in awakeFromNib.

corbin

On Mar 18, 2010, at 1:15 AM, Andrew James wrote:

> I have a nib file set up in Interface Builder with a window containing a 
> single NSBrowser.
> 
> I have set the NSBrowser as the window's initialFirstResponder... but for 
> some reason when the window is displayed the NSBrowser does not receive 
> keyboard focus and will not receive keyboard focus until I click on it.
> 
> I'm hoping I'm missing something trivially easy.


  
___

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

Please do not post 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 Instantiate a Table View in existing View?

2010-03-18 Thread Dave

Hi All,

This is a newbie question and sorry if it sounds obvious, but I've  
been playing around for ages trying to figure out how to add a table  
view into my App.


I have an App with a View Controller with one button on it. I created  
a new Table View by selecting New File in XCode and selecting a  
UIViewController subclass, I select the "UITableViewController  
subclass" and "With XIB for user interface" options. This creates a  
new .h, .m and .xib file. My question is now what? In my existing  
View controller I have one button and I want to add the TableView so  
it appears beneath the button.


Thanks a lot.
All the Best
Dave



___

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

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

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

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


Using Set/Array KVC operators

2010-03-18 Thread Sam Krishna
Hi all,

I have two arrays of NSDictionaries that I'm trying to "uniquely merge" by 
making sure that no two dictionaries have duplicate contents. I came up with 
one solution, but I wanted to see if the community had an answer that involved 
using one of the KVC array operators.

Here's the original code:

  // Get the array of dictionaries
  NSArray *tempArray = [currentItem objectForKey:contactKey];
  
  // Walk it
  for (NSDictionary *d in tempArray)
  {
// Create the predicate and filter contacts_ based on it
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"email = 
%@", [d objectForKey:emailKey]];
NSArray *filteredArray = [contacts_ 
filteredArrayUsingPredicate:predicate];

// If there's 0 results in the filtered array, add the current 
dictionary to contacts_
if ([filteredArray count] == 0)
{
  [contacts_ addObject:d];
}
  }
}

What I'm specifically looking for is a way to compress the above code into a 
line or two using the KVC array operators, specifically either 
@distinctUnionOfArrays or @distinctUnionOfObjects to uniquely merge the two 
arrays of dictionaries together. I'm trying to uniquely filter based on the 
email key of the dictionaries, and it would be great to flatten alll this code 
out.

Any ideas?

TIA!

Namaste Playfully,

Sam
-
If he listens in faith,
finding no fault, a man is free
and will attain the cherished worlds
of those who act in virtue.

___

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

Please do not post 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: Printing an NSDocument

2010-03-18 Thread Jenny M
Sorry, no answer, I'm just having a similar issue. I need to print
columns of text, and all the examples I see indicate a manual creation
and placement of EACH line of text in an NSRect inside the view. ...
Is there really no better way to place objects in the view?

Jenny



On Mar 18, 12:47 pm, Brian Postow  wrote:
> I'm trying to print a document. The document is an array of NSImageReps, or a 
> single NSPDFImageRep, which has multiple pages. I'm having trouble figuring 
> out how to use the NSPrintOperation class to print this.  
>
> The NSPrintOperation seems to need an NSView to print. Do I need to manually 
> add each image into the view at a calculated position and then let it do the 
> pagination? that seems like it isn't in the spirit of Cocoa... is there some 
> technique that I'm missing?
>
> Brian Postow
> Senior Software Engineer
> Acordex Imaging Systems
>
> ___
>
> Cocoa-dev mailing list (cocoa-...@lists.apple.com)
>
> Please do not post 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/cocoa-dev-garchive-9...
>
> This email sent to cocoa-dev-garchive-98...@googlegroups.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: Threads Question

2010-03-18 Thread Scott Cherf
Thanks to Phi for pointing out that I didn't cc the list on this reply -- Scott.

On Mar 17, 2010, at 7:36 AM, Philippe Sismondi wrote:

> 
> Because the length of time that this secondary task takes is highly variable, 
> I want to be able to cancel its processing from the main app. So, I want to 
> launch the secondary task in a separate thread to keep the main runloop 
> responsive. (This is of course a very common GUI issue.)
> 

I don't have any experience with threads but it sounds like you just want to 
run another process (ghostscript?) in the background and get notification when 
it completes, with the option of stopping it if the operator thinks it's taking 
too long?

If so, download the Moriarty tutorial/example (you can find it with Xcode under 
Help -> Developer Documentation). It lays out how to do that and also shows you 
how to communicate with the process while it's 
running.___

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

Please do not post 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: Detecting if you're being debugged

2010-03-18 Thread Peter Hudson

Thanks Jeremy, Kyle and Jonathon for your comments.

___

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

Please do not post 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: Manually adding objects to NSArrayController

2010-03-18 Thread Scott Anguish
Modify the model, not the controller.

so the model object that holds the array should be called with

mutableArrayForKey:

passing the array variable key.

then mutate the array you get back.. that will be KVO compliant and the changes 
will be reflected in your controller, and then your view.


On Mar 18, 2010, at 3:10 PM, Jenny M wrote:

> Alpha >> has multiple Betas >> has multiple Deltas
> I need an NSPopUpButton to contain all of the Deltas for the one
> Alpha. Right now the NSPopUpButton is bound alright to the
> NSArrayController. The default NSArrayController setup seems to
> automatically pull *all* Delta types, NOT just the ones that exist
> under that Alpha, so I'm trying to do it manually.

___

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

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


Weird release problem on iPhone code

2010-03-18 Thread William Squires
I have some code like below in a UITableView delegate (specifically,  
the one that fires when you touch a tableview row):


...
NSDictionary *store = [self.stores objectAtIndex:indexPath.row];

// store name is like "NOBLE FINANCE" or "CUSTOMER CREDIT" or such;  
i.e. two strings seperated by a space

NSString *temp = [store objectForKey:kKeyStoreName];
NSString *temp2 = [store objectForKey:kKeyCity];
NSArray *storeComponents = [temp componentsSeperatedByDelimiter:@" "];
NSString *temp3 = [NSString stringWithFormat:"%@ %@",  
[storeComponents objectAtIndex:0], temp2];

cell.label.text = temp3;
// [temp3 release];
// [storeComponents release];
// [temp2 release];
// [temp release];
// [store release];
...

  If I uncomment any of the object releases above, the app crashes  
in the simulator, and all the call-stack items are gray (non-user  
code). But if I don't release them, they'll leak memory, won't they,  
since iPhone OS doesn't have GC?
  Note that I've verified that 'store' is actually an NSDictionary,  
and temp, temp2, and temp3 are non-NIL at the time they're released.


___

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

Please do not post 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: Weird release problem on iPhone code

2010-03-18 Thread Jens Alfke

On Mar 18, 2010, at 8:43 PM, William Squires wrote:

>  If I uncomment any of the object releases above, the app crashes in the 
> simulator, and all the call-stack items are gray (non-user code). But if I 
> don't release them, they'll leak memory, won't they, since iPhone OS doesn't 
> have GC?

No. You don’t own any references to those objects, because you didn’t get them 
from methods like ‘alloc’, ‘retain’ or ‘copy’. You should reread the memory 
management guidelines…

—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: Weird release problem on iPhone code

2010-03-18 Thread Noah Desch

You don't own any of those objects so you should not be releasing them.

See:
http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/Articles/mmRules.html

-Noah


On Mar 18, 2010, at 11:43 PM, William Squires wrote:

> I have some code like below in a UITableView delegate (specifically, the one 
> that fires when you touch a tableview row):
> 
> ...
> NSDictionary *store = [self.stores objectAtIndex:indexPath.row];
> 
> // store name is like "NOBLE FINANCE" or "CUSTOMER CREDIT" or such; i.e. two 
> strings seperated by a space
> NSString *temp = [store objectForKey:kKeyStoreName];
> NSString *temp2 = [store objectForKey:kKeyCity];
> NSArray *storeComponents = [temp componentsSeperatedByDelimiter:@" "];
> NSString *temp3 = [NSString stringWithFormat:"%@ %@", [storeComponents 
> objectAtIndex:0], temp2];
> cell.label.text = temp3;
> // [temp3 release];
> // [storeComponents release];
> // [temp2 release];
> // [temp release];
> // [store release];
> ...
> 
>  If I uncomment any of the object releases above, the app crashes in the 
> simulator, and all the call-stack items are gray (non-user code). But if I 
> don't release them, they'll leak memory, won't they, since iPhone OS doesn't 
> have GC?
>  Note that I've verified that 'store' is actually an NSDictionary, and temp, 
> temp2, and temp3 are non-NIL at the time they're released.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/noah%40wireframesoftware.com
> 
> This email sent to n...@wireframesoftware.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


Three odd iPhone dev problems

2010-03-18 Thread William Squires
1) How does one save an XML back into its file? I've got a project  
that loads an xml file via a UITableView's delegate methods - that  
all works; I can see all the items in the NSMutableArray which was  
loaded from the XML file I created and dragged into the "Resources"  
group in Xcode. But the only code I have for saving only works on the  
simulator, not on the real device. In fact, the book (one of the  
"Head First" books on iPhone dev) specifically states that the code  
only works on the simulator! But there has to be a way to write the  
changed data back on the real device, or Core Data wouldn't work,  
either!


2) I've got a view that's pushed when the user taps on a table view  
cell to expand the info. That view (in StoreDetailView.xib) works,  
but all the UITextFields are disabled (deliberately) Another view  
(AddStoreDetailView.xib) is identical, except the UITextFields are  
all enabled. This works fine on the simulator, but not on the real  
iPhone! On the simulator, I can click a UITextField, and the  
(simulated) keyboard pops up at the bottom. On the real phone,  
nothing happens when I click any of the (supposedly enabled)  
UITextFields! Gr :(


3) How do I get a UITextField that displays a telephone number to be  
able for the user to click it to dial the number, but not so they can  
edit it in place? Or is this a different control?


___

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

Please do not post 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: User-space threads and NSAutoreleasePool

2010-03-18 Thread Michael Ash
On Thu, Mar 18, 2010 at 12:05 PM, Jens Alfke  wrote:
>
> On Mar 18, 2010, at 8:35 AM, Michael Ash wrote:
>
>> Cocoa keeps around a lot of thread-specific state. In addition to
>> autorelease pools, you also have exception handlers, graphics
>> contexts, and possibly others.
>
> Yup. I quickly ran into this in 2008 when experimenting with implementing
> coroutines (which use the same ucontext stuff.) Lightweight
> threads/coroutines can be very useful for highly scalable systems — that's
> one reason there's a lot of hype about Erlang these days — but you can't
> graft them on top of a runtime that doesn't know about them and already has
> its own threading support.
>
> I haven't had a chance yet to use the Grand Central / dispatch-queue stuff
> in 10.6, but I believe that it offers some similar functionality, like being
> able to create huge numbers of concurrent operations without having each one
> create a kernel thread.

GCD sort of kind of offers this. The big difference with GCD is that
the individual jobs submitted to GCD can't be preempted, except by the
normal rules of preemptive multithreading (GCD worker threads are just
pthreads). If you load up GCD with enough jobs to keep your CPU busy,
then submit one more job, that job has to wait until a running job
completes before it gets a chance to run. You can get more granularity
by dividing your work into smaller jobs, of course.

Where GCD can really shine for tasks like the original poster
mentioned is with dispatch sources. These allow you to, among other
things, manage asynchronous I/O using callbacks in a way that's pretty
easy to write and gives you good performance. You can basically just
load up GCD with file descriptors to monitor, and it'll call you when
data is available (or when space is available for writing). By using
blocks, your code looks close to what it would look like with
synchronous I/O, you don't have to use one kernel thread for each I/O
source, and if you do intensive computations on multiple I/O sources,
GCD will give you a multicore speedup pretty much for free.

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


Re: Three odd iPhone dev problems

2010-03-18 Thread Dave Carrigan

On Mar 18, 2010, at 8:55 PM, William Squires wrote:

> 1) How does one save an XML back into its file? I've got a project that loads 
> an xml file via a UITableView's delegate methods - that all works; I can see 
> all the items in the NSMutableArray which was loaded from the XML file I 
> created and dragged into the "Resources" group in Xcode. But the only code I 
> have for saving only works on the simulator, not on the real device. In fact, 
> the book (one of the "Head First" books on iPhone dev) specifically states 
> that the code only works on the simulator! But there has to be a way to write 
> the changed data back on the real device, or Core Data wouldn't work, either!

How exactly are you reading this XML? Without knowing what XML schema the file 
was in, there's no way we can help you with generating a file that uses the 
same schema.___

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

Please do not post 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: Three odd iPhone dev problems

2010-03-18 Thread Dave Carrigan

On Mar 18, 2010, at 8:55 PM, William Squires wrote:

> 3) How do I get a UITextField that displays a telephone number to be able for 
> the user to click it to dial the number, but not so they can edit it in 
> place? Or is this a different control?

Maybe make it a custom button 
instead.___

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

Please do not post 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: [solved] Multiple validation errors. Why?

2010-03-18 Thread Lynn Barton

On Mar 18, 2010, at 7:51 AM, Sean McBride wrote:

> On Wed, 17 Mar 2010 21:05:06 -0700, Lynn Barton said:
> 
>> the app quits, I get a "multiple validation errors occured" message. The
>> console has no error messages.
> 
> Stick this in your app delegate:
> 
> - (NSError*)application:(NSApplication*)application
>   willPresentError:(NSError*)error
> {
>   if (error)
>   {
>   NSDictionary* userInfo = [error userInfo];
>   NSLog (@"encountered the following error: %@", userInfo);
>   Debugger();
>   }
>   
>   return error;
> }
> 
> --
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com
> Mac Software Developer  Montréal, Québec, Canada
> 

Thanks. That was just the help I needed. Console messages showed that I needed 
to explicitly set the value of one of the string attributes, which was defined 
with a minimum length of zero and a blank default value. Once I 
programmatically set the value to @"" the errors went away. Things are looking 
up.

Lynn Barton___

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

Please do not post 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 after an UIAlertView..

2010-03-18 Thread Jon
I have a class set up,   and in the header file,  I have instances of NSString  
that i want to hang around for all the methods of the class to be able to 
use...(why they are declared in the header file).  when i create an instance of 
the class to use  I have a problem.

I create one instance of this class that hangs around while the whole program 
is executing...  or even if it is just called up for a short time..  (this is a 
view type of class that creates a subView over the main view...  ..

several of those methods in the class call UIAlertView, and suddenly the 
information in the NSStrings that i had instanced in the header of the class 
and am actively using,  disappears  each time a method calls up a 
UIAlertView..  i think because it is creating its own subview on top of 
everything and all the strings instances are lost at that moment...

so the question is:what is the best way to keep "strings"  around that i 
deem important enough to still have them  after a call to UIAlertView.??

Jon.
___

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

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

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

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


Re: Manually adding objects to NSArrayController

2010-03-18 Thread Jenny M
Ahhh, thank you, that helped! What I did was add an NSArray property
(though it could've been NSMutableArray), then called setValueForKey,
and bound the ArrayController to that array. And it works great.

Jenny


On Thu, Mar 18, 2010 at 8:26 PM, Scott Anguish  wrote:
> Modify the model, not the controller.
>
> so the model object that holds the array should be called with
>
> mutableArrayForKey:
>
> passing the array variable key.
>
> then mutate the array you get back.. that will be KVO compliant and the 
> changes will be reflected in your controller, and then your view.
>
>
___

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

Please do not post 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: User-space threads and NSAutoreleasePool

2010-03-18 Thread Jeremy Pereira

On 18 Mar 2010, at 06:41, BJ Homer wrote:

> On Wed, Mar 17, 2010 at 11:47 PM, Greg Guerin  wrote:
> doing one transaction updating 400-500 records.) Hence, we pipeline the HTTP
> requests, starting transfer of the second before the first one is finished.
> There are a large number of servers that don't handle pipelining, but we'll
> only we talking to one particular server, and we know it does.
> NSURLConnection does not (according to various mailing list messages)
> implement pipelining, allegedly due to the lack of server support. There's
> some suggestion that CFHTTPStream does support pipelining, but there's
> little to no documentation about it, and I don't know if it will handle 500
> at once.

It seems to me that you can accomplish what you want using just two normal 
threads.

Open a TCP connection to port 80 on the server
Create a read thread and a write thread.

The write thread takes all the requests passed to it and writes them to the TCP 
connection using synchronous IO as fast as the connection will accept data. 
After each request has been written, the thread puts it in an "awaiting 
response" queue.

The read thread reads the TCP connection using synchronous IO and deserialises 
the responses as they come in.  for each response, it takes the first request 
off the "awaiting response" queue and deals with 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: Detecting if you're being debugged

2010-03-18 Thread Jeremy Pereira

On 18 Mar 2010, at 11:48, Peter Hudson wrote:

> Technical Q&A QA1361
> Detecting the Debugger
> 
> Does this code report on my app being debugged by any third party, even when 
> the app has been stripped of symbols ?
> Would it work irrespective of the debugging tool used ?

Did you read the warning at the bottom of the page?

http://developer.apple.com/mac/library/qa/qa2004/qa1361.html

"IMPORTANT: Because the definition of the kinfo_proc structure (in 
) is conditionalized by__APPLE_API_UNSTABLE, you should restrict 
use of the above code to the debug build of your program."

This suggests you should not put the example code in the release builds of your 
program.


> 
> Peter
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/adc%40jeremyp.net
> 
> This email sent to a...@jeremyp.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


NSComboBox problem in 10.6.2

2010-03-18 Thread H. Miersch
hi.
I have a window with 3 comboboxes. one of them uses a data source. the problem 
is that it keeps throwing an exception, and i can't find out why. I've put the 
following methods in my appcontroller:

-(NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox {
return (NSInteger)[symbols count];
}

-(id)comboBox:(NSComboBox *)sender objectValueForItemAtIndex:(NSInteger)index {
return [symbols objectAtIndex:index];
}

symbols is an NSMutableArray which can contain any number of NSStrings (I 
initialize it with 5 NSStrings)

when i try to launch the app from within xcode, the console shows the following:

2010-03-18 19:26:28.515 StoX[63999:a0f] An uncaught exception was raised
2010-03-18 19:26:28.534 StoX[63999:a0f] *** -[NSCFArray objectAtIndex:]: index 
(-1 (or possibly larger)) beyond bounds (5)
2010-03-18 19:26:28.596 StoX[63999:a0f] *** Terminating app due to uncaught 
exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index 
(-1 (or possibly larger)) beyond bounds (5)'
*** Call stack at first throw:
(
0   CoreFoundation  0x7fff87ddb444 
__exceptionPreprocess + 180
1   libobjc.A.dylib 0x7fff800470f3 
objc_exception_throw + 45
2   CoreFoundation  0x7fff87ddb267 
+[NSException raise:format:arguments:] + 103
3   CoreFoundation  0x7fff87ddb1f4 
+[NSException raise:format:] + 148
4   Foundation  0x7fff8798e080 
_NSArrayRaiseBoundException + 122
5   Foundation  0x7fff878f0b81 -[NSCFArray 
objectAtIndex:] + 75
6   AppKit  0x7fff80ba2012 
-[NSComboBoxCell selectItemAtIndex:] + 191
7   StoX0x00011693 
-[AppController awakeFromNib] + 50
8   CoreFoundation  0x7fff87d8a82d -[NSSet 
makeObjectsPerformSelector:] + 205
9   AppKit  0x7fff8086c913 
-[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1445
10  AppKit  0x7fff8086ab49 loadNib + 226
11  AppKit  0x7fff8086a059 
+[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
12  AppKit  0x7fff80869e91 
+[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
13  AppKit  0x7fff80867413 
NSApplicationMain + 279
14  StoX0x000115a8 start + 52
)
terminate called after throwing an instance of 'NSException'

i've checked that i'm using the types that the docs say i should be using, but 
i don't understand why index comes back as -1. 

am i doing something wrong? should I be doing something i'm not doing? is the 
documentation wrong? is there a bug 
somewhere?___

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

Please do not post 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: NSComboBox problem in 10.6.2

2010-03-18 Thread Scott Anguish
what does the symbols array contain? are you sure it’s the length you think it 
is? and what is index? It says −1 or possibly larger.


On Mar 18, 2010, at 3:38 PM, H. Miersch wrote:

> hi.
> I have a window with 3 comboboxes. one of them uses a data source. the 
> problem is that it keeps throwing an exception, and i can't find out why. 
> I've put the following methods in my appcontroller:
> 
> -(NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox {
>   return (NSInteger)[symbols count];
> }
> 
> -(id)comboBox:(NSComboBox *)sender objectValueForItemAtIndex:(NSInteger)index 
> {
>   return [symbols objectAtIndex:index];
> }
> 
> symbols is an NSMutableArray which can contain any number of NSStrings (I 
> initialize it with 5 NSStrings)
> 
> when i try to launch the app from within xcode, the console shows the 
> following:
> 
> 2010-03-18 19:26:28.515 StoX[63999:a0f] An uncaught exception was raised
> 2010-03-18 19:26:28.534 StoX[63999:a0f] *** -[NSCFArray objectAtIndex:]: 
> index (-1 (or possibly larger)) beyond bounds (5)
> 2010-03-18 19:26:28.596 StoX[63999:a0f] *** Terminating app due to uncaught 
> exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index 
> (-1 (or possibly larger)) beyond bounds (5)'
> *** Call stack at first throw:
> (
>   0   CoreFoundation  0x7fff87ddb444 
> __exceptionPreprocess + 180
>   1   libobjc.A.dylib 0x7fff800470f3 
> objc_exception_throw + 45
>   2   CoreFoundation  0x7fff87ddb267 
> +[NSException raise:format:arguments:] + 103
>   3   CoreFoundation  0x7fff87ddb1f4 
> +[NSException raise:format:] + 148
>   4   Foundation  0x7fff8798e080 
> _NSArrayRaiseBoundException + 122
>   5   Foundation  0x7fff878f0b81 -[NSCFArray 
> objectAtIndex:] + 75
>   6   AppKit  0x7fff80ba2012 
> -[NSComboBoxCell selectItemAtIndex:] + 191
>   7   StoX0x00011693 
> -[AppController awakeFromNib] + 50
>   8   CoreFoundation  0x7fff87d8a82d -[NSSet 
> makeObjectsPerformSelector:] + 205
>   9   AppKit  0x7fff8086c913 
> -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1445
>   10  AppKit  0x7fff8086ab49 loadNib + 226
>   11  AppKit  0x7fff8086a059 
> +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
>   12  AppKit  0x7fff80869e91 
> +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 326
>   13  AppKit  0x7fff80867413 
> NSApplicationMain + 279
>   14  StoX0x000115a8 start + 52
> )
> terminate called after throwing an instance of 'NSException'
> 
> i've checked that i'm using the types that the docs say i should be using, 
> but i don't understand why index comes back as -1. 
> 
> am i doing something wrong? should I be doing something i'm not doing? is the 
> documentation wrong? is there a bug 
> somewhere?___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/scott%40cocoadoc.com
> 
> This email sent to sc...@cocoadoc.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: Three odd iPhone dev problems

2010-03-18 Thread Scott Anguish

On Mar 18, 2010, at 11:55 PM, William Squires wrote:

> 1) How does one save an XML back into its file? I've got a project that loads 
> an xml file via a UITableView's delegate methods - that all works; I can see 
> all the items in the NSMutableArray which was loaded from the XML file I 
> created and dragged into the "Resources" group in Xcode. But the only code I 
> have for saving only works on the simulator, not on the real device. In fact, 
> the book (one of the "Head First" books on iPhone dev) specifically states 
> that the code only works on the simulator! But there has to be a way to write 
> the changed data back on the real device, or Core Data wouldn't work, either!
> 

are you reading the data from within the wrapper of the application, and trying 
to write it back out to within the wrapper?

> 2) I've got a view that's pushed when the user taps on a table view cell to 
> expand the info. That view (in StoreDetailView.xib) works, but all the 
> UITextFields are disabled (deliberately) Another view 
> (AddStoreDetailView.xib) is identical, except the UITextFields are all 
> enabled. This works fine on the simulator, but not on the real iPhone! On the 
> simulator, I can click a UITextField, and the (simulated) keyboard pops up at 
> the bottom. On the real phone, nothing happens when I click any of the 
> (supposedly enabled) UITextFields! Gr :(
> 3) How do I get a UITextField that displays a telephone number to be able for 
> the user to click it to dial the number, but not so they can edit it in 
> place? Or is this a different control?

Sounds like a button to me.___

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

Please do not post 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: Printing an NSDocument

2010-03-18 Thread Scott Anguish

On Mar 18, 2010, at 7:17 PM, Jenny M wrote:

> Sorry, no answer, I'm just having a similar issue. I need to print
> columns of text, and all the examples I see indicate a manual creation
> and placement of EACH line of text in an NSRect inside the view. ...
> Is there really no better way to place objects in the view?
> 
> 

if the columns of text match line for line, why not use two NSTextViews side by 
side? You’ll still likely need to handle pagination, but you don’t have to draw 
each one.

A WebKit view may also be another option.

> On Mar 18, 12:47 pm, Brian Postow  wrote:
>> I'm trying to print a document. The document is an array of NSImageReps, or 
>> a single NSPDFImageRep, which has multiple pages. I'm having trouble 
>> figuring out how to use the NSPrintOperation class to print this.  
>> 
>> The NSPrintOperation seems to need an NSView to print. Do I need to manually 
>> add each image into the view at a calculated position and then let it do the 
>> pagination? that seems like it isn't in the spirit of Cocoa... is there some 
>> technique that I'm missing?

Nope, you’re not missing anything. If you want to ensure that pagination 
doesn’t occur during the middle of one of your images, you have to handle that 
yourself.

Our old Cocoa Programming book covered this. The PaginationDemos are still 
available for download at www.cocoaprogramming.net. Mind you, Xcode can’t read 
the project, so you’ll need to make a new project and drag the classes and nib 
in. (or just get the ideas from it).

Chapter 25 examples


___

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

Please do not post 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: Printing an NSDocument

2010-03-18 Thread Scott Anguish
well, getting that old demo to work seems more trouble than it’s worth.

have you looked at the Printing Programming Topics for Cocoa in the 
documentation?


On Mar 18, 2010, at 7:17 PM, Jenny M wrote:

> Sorry, no answer, I'm just having a similar issue. I need to print
> columns of text, and all the examples I see indicate a manual creation
> and placement of EACH line of text in an NSRect inside the view. ...
> Is there really no better way to place objects in the view?
> 
> Jenny
> 
> 
> 
> On Mar 18, 12:47 pm, Brian Postow  wrote:
>> I'm trying to print a document. The document is an array of NSImageReps, or 
>> a single NSPDFImageRep, which has multiple pages. I'm having trouble 
>> figuring out how to use the NSPrintOperation class to print this.  
>> 
>> The NSPrintOperation seems to need an NSView to print. Do I need to manually 
>> add each image into the view at a calculated position and then let it do the 
>> pagination? that seems like it isn't in the spirit of Cocoa... is there some 
>> technique that I'm missing?
>> 
>> Brian Postow
>> Senior Software Engineer
>> Acordex Imaging Systems
>> 
>> ___
>> 
>> Cocoa-dev mailing list (cocoa-...@lists.apple.com)
>> 
>> Please do not post 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/cocoa-dev-garchive-9...
>> 
>> This email sent to cocoa-dev-garchive-98...@googlegroups.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/scott%40cocoadoc.com
> 
> This email sent to sc...@cocoadoc.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