Re: properties attributes misunderstanding

2009-09-30 Thread Sherm Pendley
On Wed, Sep 30, 2009 at 9:02 AM, Colin Howarth  wrote:
>
> I thought the (copy) attribute would mean that
> temporaryPathPointerWhichIsSupposedToBeDifferent would be, well, a copy of
> the original path instance (which conforms to the NSCopying protocol).

That's not what (copy) does. The copy is made when you use "foo.path =
bar" - the setter will make a copy of bar, rather than sending a
retain message to the original.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: whether to use core data...

2009-10-03 Thread Sherm Pendley
On Sat, Oct 3, 2009 at 11:14 AM, Colin Howarth  wrote:
>
> But the Core Data documentation starts like this:
>
> ...
> Core Data is not an entry-level technology.
> ...
> You should not simply try to read [The Core Data Programming Guide] straight
> through to understand Core Data.
> ...
> Do not attempt the NSPersistentDocument Core Data Tutorial unless or until
> you also understand Cocoa bindings.
> ...
> Although Cocoa bindings and Core Data are independent and address different
> issues, both provide abstraction layers that—while individually they are
> reasonably straightforward to grasp—can be challenging to master
> simultaneously.
>
>
> Bloody hell!
>
> WARNING! Do not even ATTEMPT the NSPersistentDocument Core Data Tutorial!
> Your very MIND is in MORTAL DANDER!

Overreact much? We're talking about technical documentation, not an
H.P. Lovecraft novel. Cocoa bindings are a prerequisite for learning
Core Data, so you should learn that first. This is no different than
needing to learn algebra before attempting calculus. If you try it the
other way around, you'll waste a lot of time and probably end up
confused - not the best result, but a far cry from "mortal danger."

> Now that's a shame, because save: load: sounds like a persistent document to
> me. But if even Apple's documentation says WARNING, Do NOT attempt to read
> the Programming GUIDE in order to understand Core Data -- well, I believe
> 'em!

What part of "... should not simply try to read [it] straight through
..." implies that you shouldn't read it at all? You need to do the
exercises, maybe backtrack a little (or a lot) to review material you
didn't quite get the first time through, etc. Apple is simply saying
that the guide is a technical tutorial, not the latest John Grisham
novel!

> To be honest, I find Apple's documentation to be -- unhelpful -- at the best
> of times...

It'd be far more helpful if you skipped all the melodrama. It's not
"warning" you of "mortal danger," it's just describing the
prerequisites to learning about Core Data.

> And finally, how do Apple manage to make load: save: undo: sound more
> intimidating than quantum interference?

It's no more intimidating than a college catalog that says "you must
complete FOO101 before you can take BAR220."

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Keeping NSWindow below all other windows

2009-10-03 Thread Sherm Pendley
On Sat, Oct 3, 2009 at 1:32 PM, PCWiz  wrote:
>
> On 2009-10-03, at 10:44 AM, Ron Fleckner wrote:
>
>>
>> [myWindow setLevel:];
>>
>> check the docs.
>
> Thanks, setting the window level to -1 worked :)

Don't do that. Magic numbers are considered very poor programming:




As Ron suggested - use one of the window level constants that are
described in the docs. That's why they're there!

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Checking whether a file is a genuine PDF file

2009-10-04 Thread Sherm Pendley
On Sun, Oct 4, 2009 at 8:07 AM, Squ Aire  wrote:
>
> I know that, in an open dialog for example, I can view all PDF files by just 
> filtering using the "pdf" file extension. But that isn't good enough really, 
> because a file can have the pdf extension without being a true PDF file.

>From /usr/share/file/magic :

# pdf:  file(1) magic for Portable Document Format
#

0   string  %PDF-   PDF document
>5  bytex   \b, version %c
>7  bytex   \b.%c

So, a "real" PDF begins with "%PDF-", then two bytes with the major
and minor version numbers, respectively. See "man magic" for details.

> How can I check whether a file is indeed a true PDF file (that can be, for 
> example, opened in Preview)? Would I be able to filter true PDFs file in an 
> open dialog, or would I just have to stick to filtering with only the pdf 
> extension in open dialogs, and later ignore the non-valid PDF files?

I would take the second approach. First, it's going to perform better;
to filter the list in an open dialog, you'd have to open and verify
every .pdf file in the directory being shown. You'd also need to
inform the user somehow why some supposedly-pdf files are not
selectable. Also, note that Preview's open dialog will allow you to
select any file with a .pdf extension, then alerts the user if the
file's contents aren't actually PDF data.

> Do you have sample code that checks whether a given file is a genuine PDF 
> file?

Here's a simple command-line tool that checks a single file. Please
keep in mind, this is just an example! In the Real World(tm), you'd
want more robust error checking of the number of arguments given, the
size of the file before attempting to read the first 7 bytes, etc.

#import 

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSString *filename = [[[NSProcessInfo processInfo] arguments] 
objectAtIndex:1];
char buf[7];

[[NSData dataWithContentsOfMappedFile:filename] getBytes:(void*)buf 
length:7];

if (strncmp("%PDF-", buf, 5) == 0)
NSLog(@"%@ is a PDF file, version %c.%c", filename, buf[5], 
buf[6]);
else
NSLog(@"%@ is not a PDF file", filename);

[pool drain];
return 0;
}

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: releasing an object

2009-10-10 Thread Sherm Pendley
On Sat, Oct 10, 2009 at 12:21 PM, Shawn Erickson  wrote:
>
> Anyway the amount of code you have posted leave to much out to understand
> all that may be wrong with your memory management.

The code does show one common anti-pattern - calls to -retain and
-release that should be hidden in an accessor method.

Each instance variable that refers to an object should have a
setVariable: setter method that properly releases the old value and
retains the new value. Encapsulating the memory-management code makes
it far easier to debug - scattering it throughout your code leads to
torn hair and madness.

It's also good OOP; when you find yourself repeating some code around
access to an instance variable, it's often a good idea to factor the
repetitious code into accessor methods. That makes the repeated code
easier to manage, and leaves less clutter in the calling code.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: real verses Virtual memory

2009-10-10 Thread Sherm Pendley
On Sat, Oct 10, 2009 at 12:53 PM, jon  wrote:
>
> there are no files being accessed,  only the webView

WebView can access files on its own. Have you disabled cacheing?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: NSDate timeIntervalSinceNow problem

2009-10-22 Thread Sherm Pendley
On Thu, Oct 22, 2009 at 11:06 PM, PCWiz  wrote:
>
> NSDate *time = [myDict objectForKey:@"time"];
> NSLog(@"%d", [time timeIntervalSinceNow]);
>
> And the result is this:
>
> 2009-10-22 21:01:18.949 TestApplication[8263:a0f] -2097072
>
> Not sure what's wrong here, I've taken a look at some examples and they seem
> to do the same thing.

NSTimeInterval is a floating-point value, not an integer. You should
use %f to print it.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Double-clicking a screensaver

2009-10-31 Thread Sherm Pendley
On Sat, Oct 31, 2009 at 10:19 AM, Gabriel Zachmann  wrote:
> I think I've seen screen savers that copy themselves to
> ~/Library/Screensavers by double-clicking on the .saver file (that is still
> in the DMG).
>
> Could someone tell me how I can make my screensaver have this capability as
> well?

The system's screen saver app registered .saver as a document type, so
that behavior happens automagically. You don't need to do anything
besides create a normal .saver plugin from the standard template.

If you want similar behavior from a screen saver app of your own, you
can do the same thing - register a filename extension for your
plugins, and copy them to your ~/Library/Application Support folder
when the user tries to open them.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Double-clicking a screensaver

2009-10-31 Thread Sherm Pendley
On Sat, Oct 31, 2009 at 11:21 AM, Gabriel Zachmann  wrote:
>> The system's screen saver app registered .saver as a document type, so
>> that behavior happens automagically. You don't need to do anything
>> besides create a normal .saver plugin from the standard template.
>
> I think, I'm doing that, but when I double click the .saver file, System
> Preferences starts and I get the error message "Could not install ...".
>
> My XCode project with which I am compiling my screensaver is pretty old.
> I am running XCode 3.2, though.

How old is "old"? Have you updated the project to create a universal
binary? Snow Leopard is Intel-only, so its screen saver app isn't
going to be able to load a PPC-only .saver plugin.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: objectAtIndex

2009-11-01 Thread Sherm Pendley
On Sun, Nov 1, 2009 at 2:44 PM, Nava Carmon  wrote:
>
> NSObject *anObject = [anArray objectAtIndex:i];
...
> Should I release it?

No. You didn't create anObject with +alloc or a method beginning with
-copy, nor did you send it a -retain message. Therefore you do not own
it and must not release it.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: why use pow(x, 2)?

2009-11-02 Thread Sherm Pendley
On Mon, Nov 2, 2009 at 2:25 PM, Ed Wynne  wrote:
>
> That said, the original question is a good one. Using x*x instead of
> pow(x,2) would be quite a bit faster

Are you certain of that? With loop unrolling and inlined functions, it
should result in identical code being produced by the compiler.

> so except for clarity reasons, there isn't a
> good reason to use pow() in that case.

Clarity should be the default, not the exception. Unless you've
profiled your code and found the use of pow() to be a significant
bottleneck, there's no good reason *not* to use it.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: [Q] copy operation and authorization

2009-11-12 Thread Sherm Pendley
On Thu, Nov 12, 2009 at 12:44 PM, JongAm Park
 wrote:
>
>     NSString *sourceFile = [NSString
> stringWithFormat:@"%@/Desktop/test3.valm", NSHomeDirectory()];

Have you tried this?

[[NSWorkspace sharedWorkspace] openFile:sourceFile];

Many apps register their plugin extensions as document types, so you
can simply open them and let the app handle the installation for you.
The screen saver app, for example, does this with .saver plugins.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: NIB/XIB created objects, should they be released in -[dealloc]?

2009-11-23 Thread Sherm Pendley
On Mon, Nov 23, 2009 at 11:13 AM, Michael A. Crawford
 wrote:
> I wouldn't have though so.  I would assume that since I did not allocate them 
> directly, I don't need to clean them up. I've just inspected some code that 
> declares properties that are marked as outlets and whose member variables are 
> allocated in the NIB file.  When the class' dealloc method is called, it 
> calls release for said properties.
>
> I would assume this is bad form.  But I would like to know if I'm mistaken 
> and if this is valid.

It's valid. Remember the other part of the memory management rule -
because you send them a -retain message, you're required to balance
that by sending them a -release when you're done with them.

> @property (nonatomic, retain) IBOutlet MKMapView* mapView;

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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


ANN: CamelBones 1.1.0

2009-11-23 Thread Sherm Pendley
Now supporting Leopard and Snow Leopard, and more. Read the full
announcement at:



sherm--

-- 
Cocoa programming in Perl: http://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: NSImage and NSBitmapImageRep

2010-03-16 Thread Sherm Pendley
On Wed, Mar 17, 2010 at 2:39 AM, Martin Beroiz  wrote:
>
> So how would you guys do this?

Initialize an empty NSImage using -initWithSize:, which according to
its description "does not add any image representations to the image
object." Then add your NSImageRep to it with -addRepresentation:.

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

2010-03-17 Thread Sherm Pendley
On Wed, Mar 17, 2010 at 10:36 AM, Philippe Sismondi  wrote:

> So, I want to launch the secondary task in a separate thread to keep the main 
> runloop responsive.

NSTask only blocks the runloop if you call -waitUntilExit. So - don't
do that. :-)

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: NSTask dilema...

2010-03-31 Thread Sherm Pendley
On Wed, Mar 31, 2010 at 2:21 PM, Jean-Nicolas Jolivet
 wrote:
> I have to run a bunch of NSTasks and I'm not sure to proceed considering I 
> want to be able to update the UI when a task is completed, and I want the 
> process to be as fast as possible (obviously)...
>
> So far I tried a couple of ideas but they all had their problems:
>
> - I tried launching the tasks on the main thread but it locks up my UI and I 
> can't update my progress bar...

NSTask doesn't block unless you specifically ask it to, by calling
-waitUntilExit.

> So I guess my question is... if using threads prevents me from using 
> waitUntilExit

It doesn't normally prevent that. In fact, in most cases you'd only
want to use it from a background thread, because using it from the
main thread would block the main event loop and trigger a beach ball.

> ... and launching them on the main thread locks up my UI... is there anything 
> I am missing?

What you're missing is that NSTask doesn't (normally) block the UI
thread, and that calling -waitUntilExit doesn't (normally) cause a
crash when called from a secondary thread.

> Any help would be appreciated

Just launch your NSTask on the main thread, and *don't* call
-waitUntilExit. Listen for NSTaskDidTerminateNotification, and respond
to it by updating your UI.

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: Introspecting the current method

2010-04-18 Thread Sherm Pendley
On Sun, Apr 18, 2010 at 8:21 PM, Graham Cox  wrote:
>
> On 19/04/2010, at 10:14 AM, Dave DeLong wrote:
>
>> If I'm inside a method, is there a way to know at runtime whether that 
>> method is a class or an instance method?  Currently the only way I though of 
>> to do this is to see if "self" is a Class object or not, but I was wondering 
>> if there's a more reliable way to determine this.
>
> I might be lacking imagination here, but I can't think of any situation where 
> needing to detect this would make any sense.

Language bridging, perhaps. You can build up a class definition at run
time, with all of its selectors registered to resolve to a single IMP
function. That's how CamelBones registers Perl classes with the ObjC
runtime, with messages sent to Perl methods (both class and instance)
routed through one IMP function.

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: Seeking a graceful way to end a program

2010-04-29 Thread Sherm Pendley
On Thu, Apr 29, 2010 at 2:46 PM, Markus Spoettl
 wrote:
> On Apr 29, 2010, at 2:31 PM, Paul Johnson wrote:
>> I would like to have some guidance on the proper way to 'gracefully'
>> terminate a program that cannot proceed, for example, when some
>> critical resource can't be created or doesn't exist.
>
> [NSApplication sharedApplication] terminate:nil];
>
> should work, no?

I'd suggest displaying an error dialog first, explaining the situation
and (possibly) what the user should do to correct the problem. Then,
when they click "OK" on that dialog, use the above to exit.

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: Synthesized ivar for std::tr1::shared_ptr?

2010-05-06 Thread Sherm Pendley
On Thu, May 6, 2010 at 2:19 AM, Barry Wark  wrote:
> I'm no C++ guru, so I'm hoping someone can help me by explaining why
> the following gives a compiler error:

I'm no guru either, but my guess would be that the interaction between
synthesized ivars and C++ templates is rocky territory. I avoid going
down that path, declare the ivar as a pointer (with an #ifdef to
declare it as a void* for ObjC client code) and create the object with
new in +init. Here's a snippet from a random number generator class I
wrote, that uses Boost's random module "under the hood":

In SPRandom.h:

#ifdef __cplusplus
#import 
#endif

typedef struct {
int min;
int max;
} SPRandomRange;

@interface SPRandom : NSObject {
#ifdef __cplusplus
boost::uniform_int<> *distribution;
boost::variate_generator > *generator;
#else
void *distribution;
void *generator;
#endif
}
...
@end

In SPRandom.m:

static boost::lagged_fibonacci607 rng;

@implementation SPRandom

- (id) initWithRange:(SPRandomRange)range {
self = [super init];
if (self) {
distribution = new boost::uniform_int<>(range.min,range.max);
generator = new
boost::variate_generator >(rng, *distribution);
}
return self;
}

- (void) dealloc {
delete generator;
delete distribution;

[super dealloc];
}

@end

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

2010-05-08 Thread Sherm Pendley
On Sat, May 8, 2010 at 3:51 PM, Kevin Callahan  wrote:
> isKindOfClass: is an instance method and doesn't work on a class you get from 
> NSClassFromString().

Because NSObject is a root class (i.e. it has no superclass), you
*can* send its -isKindOfClass: message to a Class object. Instance
methods that belong to a root class are special that way.

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: Regarding MVC design pattern

2010-05-19 Thread Sherm Pendley
On Wed, May 19, 2010 at 6:31 AM, Joanna Carter
 wrote:

> Any outlets for controls (top level objects) in the Nib should be released in 
> the dealloc method only for OS X apps but not for iPhone apps. Setting the 
> properties to nil will ensure that the synthesized setter will be called, 
> which releases the previous contents of the synthesized ivar before setting 
> it to nil.
>
> - (void) dealloc
> {
>  beginButton = nil;
>
>  endButton = nil;
>
>  nameLabel = nil;
>
>  numberLabel = nil;
>
>  myModel = nil;
>
>  [super dealloc];
> }

If you set the ivars directly, as above, the synthesized setters will
NOT be called. For that to happen, you need to use dot-syntax, like
this:

- (void) dealloc {
self.beginButton = nil;
self.endButton = nil;
// etc...
[super dealloc];
}

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: Crash trying to unarchive webview from IB document

2010-05-25 Thread Sherm Pendley
On Tue, May 25, 2010 at 3:10 PM, Laurent Daudelin
 wrote:
> I was doing a little demo to a colleague this morning and built a simple app 
> consisting of a text field and a web view in IB. I was able to run the thing 
> from IB but when I tried to compile it as release and launch it, it would 
> crash with an exception:
>
> *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class 
> (WebView)'
>
> I tried to look if I did something wrong but since it was just a little demo 
> with no code written, I'm a bit stumped. I created a new project for a Cocoa 
> app, nothing fancy, then opened the MainWindow.xib in IB to add the text 
> field and the webview.
>
> Anyone has any idea?

Did you add WebKit.framework to your Xcode project?

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: subclass overwriting superclass ivar

2010-05-26 Thread Sherm Pendley
On Wed, May 26, 2010 at 8:13 AM, vincent habchi  wrote:
> Le 26 mai 2010 à 13:40, jonat...@mugginsoft.com a écrit :
>
>> A subclass ivar is apparently overwriting a super class ivar.
>> When an instance of MGS_B sets stderrData the super class ivar tempFilePath 
>> gets overwritten.
>
> If I am not mistaken, if your superclass ivar is private (!= protected), it 
> cannot be accessed from its subclasses. Thus, the compiler can choose to 
> reuse part of the heap dedicated to private variables to implement subclasses 
> own private ivars.

No way the compiler could do that. @private makes the superclass'
ivars invisible to subclasses, but they're still there. They have to
be, since the superclass' methods (which *can* see them) can be called
on the subclass as well.

There's nothing wrong with the ivar declarations - something must be
going wrong at run time. Typically, when an object pointer seems to
point to the wrong object, the prime suspect is memory management. But
it's hard to say for sure, without seeing the relevant code.

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: isKindofClass with NSData and NSKeyUnarchiver

2010-05-28 Thread Sherm Pendley
On Thu, May 27, 2010 at 8:25 PM, Philip Vallone
 wrote:
>
> This is a relative question, which depends on how the data is coming and 
> going. My question comes from the following situation. Suppose I have a 
> GKSession that is passing information via Bluetooth. The sender can send any 
> type of information (NSString, UIImage etc...). The receiver needs to know 
> how to handle this data. If there is a better way... Then how?
>
> I appreciate the feed back and help,

I would let the sent objects handle the work themselves. A switch or
series of ifs based on class is an OOP anti-pattern. Polymorphism is
often a better alternative, and Objective-C's ability to add a
category to any class makes it easy to implement. So,  I would extend
NSString, UIImage, etc. - whatever types can be sent - by adding a new
method "mySuperDuperMethod" (for example).

Then, what you're left with in the receiver class is simply:

if ([obj respondsToSelector(@selector(mySuperDuperMethod))]) {
[obj performSelector:@selector(mySuperDuperMethod)];
}

If the ability of a sent object to implement mySuperDuperMethod is
critical, you could add an else block to log and/or assert any such
failures.

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: eval?

2010-05-31 Thread Sherm Pendley
On Mon, May 31, 2010 at 1:11 PM, Louis-Philippe  wrote:
> Correct me if I am wrong, but there is no way in objective-c to do a runtime
> string execution for which the responding object is not an Objective-C
> class?
>
> like, if I have a c++ lib I would like to call from within an Objective-c
> class, assuming a call like:
>
> const char * retValue = MyExtLib::ExtLibSymbol;
>
> I would like to be able to dispatch dynamically, something like:
>
> const char * retValue = eval( [NSString
> stringWithFormat@"MyExtLib::%@",symbolString]
> );
>
> any thoughts on making this possible?

There's dlopen() for loading the library, dlsym() for getting pointers
to functions in the library, and libffi for building an appropriate
stack frame and making the call at run time.

The biggest problem would be dealing with C++'s name-mangling.

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: Sanity Check

2010-07-08 Thread Sherm Pendley
On Thu, Jul 8, 2010 at 10:19 AM,   wrote:
>> his seems weird. Why assign the panel/window to your own ivar when this is
>> exactly -[NSWindowController window] is designed to do for you?
>
> I was thinking I might need to reference it and rather than call for it just
> have it hanging around. Yes, no?

Did you profile (with Shark or Instruments) your code, and did the
profiler tell you that calls to -window are taking up a significant
amount of your app's time? If not, what you're doing is called
"premature optimization," and it's generally considered a bad idea.

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: modal loops & memory

2010-07-16 Thread Sherm Pendley
On Fri, Jul 16, 2010 at 1:10 PM, Scott Ribe  wrote:
> Does [NSApp runModalForWindow: ...] wrap an autorelease pool around its event 
> handling?

Yes, autorelease pools work normally during a modal session.

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: Link Error: following -F not found

2010-07-17 Thread Sherm Pendley
On Sat, Jul 17, 2010 at 1:45 PM, Joseph Ayers  wrote:
>
> ld: warning: directory 
> '/Users/lobster/Programming/Roboplasm/../../../core-plot/framework/build/Debug'
>  following -F not found
>
> I can't find a reference to core-plot anywhere in the code.

It's not coming from your code, it's a linker option in Xcode, where
the above path has been added to your project or target's "Framework
Search Path." Get Info on your project or target to find that.

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: NSInteger compare - Help Needed

2010-07-18 Thread Sherm Pendley
On Sun, Jul 18, 2010 at 1:21 PM, Steve Wetzel  wrote:
> Thanks guys, that was the problem,  There are so many little things to learn 
> with Objective C.

Out of curiosity, what programming language are you comparing it to?
I've used *many* of them over the past twenty years, and I can't think
of a single one that uses << as a "less than" operator.

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: NSDocument Question

2011-02-07 Thread Sherm Pendley
On Mon, Feb 7, 2011 at 2:54 PM, Bruce Cresanta  wrote:
> Ii have two subclasses of NSDocument.   One of the subclasses only ever needs 
> one instance window.   How do I query NSWindowController for the open window, 
> and if that fails, create it.   Sorry for the confusion.

Override -makeWindowControllers. The default calls -windowNibName, and
loads a new instance of the named Nib for every document, but you can
change that behavior to re-use a single window controller:

- (void)makeWindowControllers {
static NSWindowController *windowController;
if (!windowController) {
windowController = [[NSWindowController alloc]
initWithWindowNibName:@"MyDocumentNib" owner:self];
}
[self addWindowController:windowController];
}

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: NSDocument without Save

2011-02-08 Thread Sherm Pendley
On Tue, Feb 8, 2011 at 9:29 PM, Graham Cox  wrote:
> I'm trying to prevent NSDocument from doing any saving at all, for a demo 
> version of my app. I need to suppress the menu commands (done) and all the 
> automated UI such as the 'save changes' dialog and 'Save As' dialog even 
> though the doc is marked dirty. I've also removed the actual save code.
>
> According to the docs for 
> -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo:, if I 
> immediately pass YES to the should close selector, it should accomplish this. 
> Indeed, it does suppress the "do you want to save changes?" dialog, but the 
> window does not close.
>
> What's the proper way to do this? I searched the archives but surprisingly I 
> couldn't find any previous discussion of this, even though I would have 
> thought it's quite a common thing.

If you've removed the actual save code, why not simply let Cocoa go
through the motions and call your (empty) save method? Seems like a
lot of unnecessary trouble to go through, just to make it avoid
calling a method that isn't going to do anything anyway...

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Two Newbie Questions

2011-02-16 Thread Sherm Pendley
On Wed, Feb 16, 2011 at 5:56 PM, Bruce Cresanta  wrote:
>
> I have an NSTableView set up to a datasource of a single array.   When I run 
> my code, I get two columns (the default in IB) instead of just one with the 
> data duplicated in each column.    I only want one column, how best to 
> achieve this?

Select the table view in IB, then change its "Columns" attribute in
the "Attributes" pane of the inspector panel.

>        NSButton can be set up to perform a selector in IB on click.    How do 
> you set Target/Action for a button in code?

It's pretty rare that you'd need to, so I have to ask the obligatory
question: Are you sure you want to do that? If you tell us what you're
trying to accomplish, we might be able to help you find a way to do it
that doesn't involve setting up the target & action in code.

That said:

  [theButton setTarget:aTarget]; // Set the target to nil to send an
action to the responder chain
  [theButton setAction:@selector(doAction:)]; // Don't forget the colon...

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: NSDocument Problems

2011-02-21 Thread Sherm Pendley
On Mon, Feb 21, 2011 at 2:12 PM, Bruce Cresanta  wrote:
> Hello Volker,
>
> I have the following two methods implemented in AnalyzerDocument, but I still 
> get greyed menu items.
>
> - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
>
> - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName 
> error:(NSError **)outError
>
> Do I need to implement other methods to save/read a file?

You should check to make sure you've assigned the correct class for
the document type - double-click on the target, then look in the
"Document Types" section of the "Properties" pane. The sixth column
over is Class, which by default is MyDocument.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Problem opening file

2011-02-22 Thread Sherm Pendley
On Tue, Feb 22, 2011 at 10:47 AM, Carlos Eduardo Mello
 wrote:
>
> I have a configuration file which is used by an internal library in my app's
> data model engine. The engine was written in c++ and needs this file for
> loading the app's documents correctly. Theis file never changes and
> shouldn't have to be seen or open  by the user. Its contents are the same
> for any document files oppened by the user.
>
> During debugging I place the file next to the executable in Build->Debug and
> the library opens it with using c++ streams with just the file name.
> However, when I compilethe  app as release, and place the configuration file
> next to the executable, it fails to find the file.

It's not a Debug/Release difference. The difference is how you're
launching your app - the current working directory is different when
you launch the app from Finder, from Xcode, and using the "open"
command-line tool.

> I imagine I have to deal
> with application bundle api, but the thing is I can't add any cocoa code to
> this library, as it needs remain cross-platform.

Does this library allow you to specify the full path to its config
file, instead of just its name, when you initialize the library? If
so, you could keep the platform-specific code outside of the library
itself.

Alternatively, you could use NSBundle methods to find the location of
your executable, then chdir() to that directory before initializing
the library.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Mutable and immutable class cluster implementation / "method swizzling" question

2011-03-25 Thread Sherm Pendley
On Fri, Mar 25, 2011 at 1:30 AM, Louis Gerbarg  wrote:
> The corner case you mention below ( [myMutableArrayInstance 
> isKindOfClass:[NSMutableArray class]] ) is a nonissue for a somewhat 
> surprising reason. All instances of NSArray are actually implemented via the 
> concrete class NSCFArray, which is a subclass of NSMutableArray. Thus any 
> instances of mutable or immutable arrays return YES to isKindOfClass for both 
> NSArray and NSMutableArray. The only time that is not true is when people 
> implement custom subclasses of NSArray. Thus no one can depend on that 
> particular construct working unless they have implemented their own 
> subclasses.
>
> For that reason, you can probably completely ignore the issue.

I agree. When bridging Perl's array & hashes, I didn't even bother
creating an immutable class. A mutable array can be passed to any
method that expects an array, and such a method is more or less
obligated by practical concerns to treat it as the declared type.

sherm--

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: doesNotRecognizeSelector exception

2011-03-26 Thread Sherm Pendley
On Sat, Mar 26, 2011 at 9:39 PM, Jeffrey Walton  wrote:
>
> I have a protocol and declarations as follows. respondsToSeletor
> returns NO. If I ignore respondsToSeletor (and send the message), I
> get an expeption.
>
> // FilePicker.m - try both
> BOOL responds = [delegate respondsToSelector:@selector(userSelectedFile:)];
> BOOL responds = [delegate
> respondsToSelector:@selector(userSelectedFile:fileSystemObject:suppliedContext:)];
>
> Any ideas on my error(s)? I can't seem to locate it (or them) on my own.
>
> // MyViewController.h
> @interface MyViewController : UIViewController
>        
> {
>    ...
> }
>
> // MyViewController.m
> FilePicker* picker = [[FilePicker alloc] initWithDelegate:self withContext:0];
> [self presentModalViewController:picker animated:YES];

Okay, I see where you've declared MyViewController as implementing the
FilePickerDelegate protocol - but where are the method
implementations? You *have* implemented those methods, right?

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: doesNotRecognizeSelector exception

2011-03-26 Thread Sherm Pendley
On Sat, Mar 26, 2011 at 10:21 PM, Jeffrey Walton  wrote:
>
> 2011-03-26 22:12:50.029 CryptoSandbox[123:707] -[UIView
> userSelectedFile:fileSystemObject:suppliedContext:]: unrecognized
> selector sent to instance 0x1dbd00

The delegate message is being sent to an instance of UIView - not to
your controller. That would indicate that the first argument you're
sending to -initWithDelegate:withContext: is not what it should be.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Can't keep untitled windows from opening!

2011-03-31 Thread Sherm Pendley
On Thu, Mar 31, 2011 at 12:49 PM, Carlos Eduardo Mello
 wrote:
> Isn't the document subclass the app's delegate by default in the document
> architecture?

No, it isn't. The document's job is to handle per-document
responsibilities; the app delegate's job is to handle tasks that are
relevant for the app as a whole.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Simulate touch event with cordinate?

2011-04-02 Thread Sherm Pendley
On Sat, Apr 2, 2011 at 7:29 AM, Jesse Armand  wrote:
>
> But, my word of advice:
> People don't read PDFs with the gestures of their face or head. It's just 
> silly.

Tell that to Stephen Hawking. There are cases where what seems "silly"
to most of us are the only options one has left.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Book for expert programmer about cocoa and Objective-C

2011-04-02 Thread Sherm Pendley
On Fri, Apr 1, 2011 at 3:40 PM, Rodrigo Zanatta Silva
 wrote:
> Hi. I need to have a good book in my side to program with Objective-C using
> the cocoa. I read the beginner books like "... for absolute beginner",
> "starting to program with...".
>
> But now, I need a book for professional. Book that is BIG, DIFFICULT and is
> HARDCORE about anything for cocoa and objective-c.

Book? HARDCORE programmers don't read books, we read header files! :-)

Kidding aside, I just wanted to add another vote for both "Cocoa
Programming" & "Cocoa Design Patterns." Both are written by active and
respected community members, at least one of whom has since been hired
by Apple to write documentation. Two thumbs up, and more than that if
I had 'em.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: special characters are destroyed when copying a string character by character

2011-04-05 Thread Sherm Pendley
On Tue, Apr 5, 2011 at 11:55 AM, Horst Jäger  wrote:
>
>                [dst appendFormat:@"%c", chr];

%c is the format specifier for 8-bit chars - use %C for 16-bit unichars.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Framework Installation Directory

2011-04-08 Thread Sherm Pendley
On Fri, Apr 8, 2011 at 8:53 AM, Mr. Gecko  wrote:
> I need help with the Installation Directory for a framework that will be 
> shared between a application and 2 daemons within side it. I think I may be 
> able to do it if I were to have the 2 daemons executables in the MacOS path 
> or another folder such as one named Daemons in the Contents folder. I am 
> needing at least 1 of the daemons to be a bundle based daemon as it'll have 
> some UI elements and such. The installation directory that I have been doing 
> is "@executable_path/../Frameworks" which according to this, it'll go back 1 
> directory from the path of the executable and into the Frameworks directory 
> to find the framework. The reason I am thinking in doing this as a framework 
> is because some of the code I am using will be used in the daemons such as 
> core code.

The details will vary according to how you've structured your bundles,
but the principle is the same. The install name of the framework is
used at link time, and copied into any apps that link with it. At run
time, it's the copy in the app that's used to find the framework, and
you can use install_name_tool's -change option to modify that.

install_name_tool -change
'@executable_path/../Frameworks/Foo.framework/Foo'
'@executable_path/../../Frameworks/Foo.framework/Foo'.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Framework Installation Directory

2011-04-08 Thread Sherm Pendley
Yeah, that's how I'd do it, add a "run script" build phase to the daemon target.

sherm--

On Fri, Apr 8, 2011 at 9:57 AM, Mr. Gecko  wrote:
> So basically once I've compiled the daemon, have it run a post script that 
> will change the path to go back 4 directories instead of 1 if I was to place 
> it in Contents/Daemon/Daemon.app/Contents/MacOS/Daemon?
>
> Thanks for the response,
> Mr. Gecko
>
> On Apr 8, 2011, at 8:48 AM, Sherm Pendley wrote:
>
>> The details will vary according to how you've structured your bundles,
>> but the principle is the same. The install name of the framework is
>> used at link time, and copied into any apps that link with it. At run
>> time, it's the copy in the app that's used to find the framework, and
>> you can use install_name_tool's -change option to modify that.
>>
>> install_name_tool -change
>> '@executable_path/../Frameworks/Foo.framework/Foo'
>> '@executable_path/../../Frameworks/Foo.framework/Foo'.
>>
>> sherm--
>>
>> --
>> Cocoa programming in Perl:
>> http://camelbones.sourceforge.net
>
>



-- 
Cocoa programming in Perl:
http://camelbones.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: Framework Installation Directory

2011-04-08 Thread Sherm Pendley
True! There's more than one way to skin that cat. :-)

sherm--

On Fri, Apr 8, 2011 at 11:05 AM, Jean-Daniel Dupas
 wrote:
> Or do a symlink of MyApp.app/Contents/Frameworks into your daemon Contents 
> directory (using a build script too).
>
> cd Daemon.app/Contents/
> ln -s ../../../Frameworks Frameworks
>
> (I didn't check the count of '..' so it may be wrong, but you get the idea).
>
>> Yeah, that's how I'd do it, add a "run script" build phase to the daemon 
>> target.
>>
>> sherm--
>>
>> On Fri, Apr 8, 2011 at 9:57 AM, Mr. Gecko  wrote:
>>> So basically once I've compiled the daemon, have it run a post script that 
>>> will change the path to go back 4 directories instead of 1 if I was to 
>>> place it in Contents/Daemon/Daemon.app/Contents/MacOS/Daemon?
>>>
>>> Thanks for the response,
>>> Mr. Gecko
>>>
>>> On Apr 8, 2011, at 8:48 AM, Sherm Pendley wrote:
>>>
>>>> The details will vary according to how you've structured your bundles,
>>>> but the principle is the same. The install name of the framework is
>>>> used at link time, and copied into any apps that link with it. At run
>>>> time, it's the copy in the app that's used to find the framework, and
>>>> you can use install_name_tool's -change option to modify that.
>>>>
>>>> install_name_tool -change
>>>> '@executable_path/../Frameworks/Foo.framework/Foo'
>>>> '@executable_path/../../Frameworks/Foo.framework/Foo'.
>>>>
>>>> sherm--
>>>>
>>>> --
>>>> Cocoa programming in Perl:
>>>> http://camelbones.sourceforge.net
>>>
>>>
>>
>>
>>
>> --
>> Cocoa programming in Perl:
>> http://camelbones.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/devlists%40shadowlab.org
>>
>> This email sent to devli...@shadowlab.org
>
> -- Jean-Daniel
>
>
>
>
>



-- 
Cocoa programming in Perl:
http://camelbones.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: Compiling screensaver for 10.5

2011-04-08 Thread Sherm Pendley
On Fri, Apr 8, 2011 at 2:48 PM, Nick Zitzmann  wrote:
>
>
> ppc. The linker may change this to ppc7400 under certain circumstances. This 
> is normal, and only means that your screen saver will not load on G3 Macs.

This has to do with the deployment target, right? That is, it will be
changed to ppc7400 if your deployment target is an OS version that
requires a G4 anyway...

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Test for TCP port

2011-04-08 Thread Sherm Pendley
On Fri, Apr 8, 2011 at 6:26 PM, Heizer, Charles  wrote:
>
> What is the best way to test to see if a TCP port is reachable and will 
> answer connections? I was trying to use NSSocketPort and NSConnection but I'm 
> not getting a valid connection.
>
> NSSocketPort *sendPort = [[NSSocketPort alloc] initRemoteWithTCPPort:3600 
> host:@"test.myhost.com"];

That's not a valid host name. Try connecting to just @"test.myhost.com" instead.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: I'm given a project.pbxproj file....

2011-05-18 Thread Sherm Pendley
Have you tried simply checking out the source tree directly from
Subversion? Google Code usually allows anonymous check outs.

sherm--

On Wed, May 18, 2011 at 5:45 PM, R4EE  wrote:
> Howard,
>
> That was my original approach but the .xcodeproj file wants to save as
> html.  I then, wrongly, extracted the .pbxproj file and used it to
> replace the .pbxproj file inside my .xcodeproj package that was
> created as part of a new XCode project.
>
> I'm tangled up in XCode process at this point.  Can you give me some
> guidance on how to bring the .xcodeproj over?  I've dropped all the
> other files in a project folder with no problems.  the *.xcodeproj
> portion is giving me the problems.
>
> Much thanks -- Ron
>
>
> On May 18, 3:14 pm, Howard Siegel  wrote:
>> The .xcodeproj isn't really a folder, it just looks that way on the FTP
>> site.
>> On your Mac it is really a "package".
>>
>> You want to download all the files from that site (the .xcodeproj, the .m
>> files,
>> the .h file, and the .pch file).  Drop 'em in a folder and double click on
>> the
>> .xcodeproj file to open the project in Xcode.
>>
>> - h
>>
>>
>>
>>
>>
>> On Wed, May 18, 2011 at 14:02, R4EE  wrote:
>> > Here is the original form
>>
>> >http://gtm-oauth.googlecode.com/svn/trunk/Examples/OAuthSample/
>>
>> > On May 18, 2:51 pm, Kyle Sluder  wrote:
>> > > On Wed, May 18, 2011 at 1:42 PM, R4EE  wrote:
>> > > > How do I incorporate this into a XCode project?
>>
>> > > Er, that *is* the project. Well, part of it anyway.
>>
>> > > You should go back to whoever gave you the .pbxproj and ask for the
>> > > entire .xcodeproj.
>>
>> > > --Kyle Sluder
>> > > ___
>>
>> ___
>>
>> 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/sherm.pendley%40gmail.com
>
> This email sent to sherm.pend...@gmail.com
>



-- 
Cocoa programming in Perl:
http://camelbones.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: Using WebKit for UI instead of Cocoa in cross-platform app

2011-05-23 Thread Sherm Pendley
On Mon, May 23, 2011 at 9:52 AM, John Joyce
 wrote:
>
> Apps that try to be somehow universal without trying to behave naturally on a 
> given OS usually suffer for it.

Even Microsoft had to learn that lesson the hard way - google for
"Word 6 fiasco."

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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 point of a host-reachability test that doesn't test the reachability of the host?

2011-06-02 Thread Sherm Pendley
On Thu, Jun 2, 2011 at 11:16 AM, Kyle Sluder  wrote:
>
> Why does everyone insist on using roundabout ways to detect if maybe a host 
> will accept connections on a completely unrelated port

... when it may not even accept *those* on the next attempt. Can you
say "race condition?" I knew you could!

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: tools for writing help books

2011-06-08 Thread Sherm Pendley
On Wed, Jun 8, 2011 at 3:33 AM, Michael Thon  wrote:
> What tools to y'all recommend for writing content for the help viewer on Mac 
> OS? Do you write them directly in html/xhtml?

I just use BBEdit and write the markup by hand - HTML ain't exactly
rocket surgery to begin with, and every tool I've tried that claims to
make it "easier" has ended up creating atrocious code that I've needed
to fix anyway.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: ObjC stdin equivalent? and other questions

2011-06-10 Thread Sherm Pendley
On Fri, Jun 10, 2011 at 10:56 PM, William Squires  wrote:
> Hi!
> 1st question:
>  In regular C, you have the  functions for reading/writing to stdio; 
> printf(), scanf(), etc...
>  In C++, you have cin/cout and the overridden '>>' and '<<' operators.
>  What does ObjC have (besides NSLog() anyway) that C/C++ doesn't?

NSFileHandle methods:
  +fileHandleWithStandardInput
  +fileHandleWithStandardError
  +fileHandleWithStandardOutput

>  I'm guessing

Why? Just look at the standard I/O classes - it's right there in the
reference material.

> 2nd question:
>  Can a console app control the text 'cursor' in Terminal.app's window solely 
> through stdio? (i.e. are there control codes that clear the screen, locate 
> the cursor at some x,y location, set the text color/brightness (I know the 
> man page reader can, at the very least, change the text brightness), position 
> the cursor at the beginning/end of a line, etc...)

You *could* deal with ANSI escape codes manually, but it's a massive
PITA. Far easier to use something like Curses.

>  Are all the C libraries (with the possible exception of ) available 
> in iOS 3 and later?

I haven't dived into iOS development yet, so I can't answer that one.

>  Are there any plans to include NumberFormatter and DateFormatter in iOS 5 
> (or later)?

If there are, no one who knows of them can tell you about them. That
kind of thing is covered under NDA, and Apple takes those quite
seriously.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Re-using the same NIB on two owners

2011-06-26 Thread Sherm Pendley
On Sun, Jun 26, 2011 at 11:16 AM, Daniel Luis dos Santos
 wrote:
>
> My problem is that I need to load the same NIB from two different classes, so 
> the owner is different according to which class I load it from.
> Is there another way to do it without the file's owner ? Subclassing the 
> controller ?

One way would be to declare a common superclass, of which both owner
classes are subclasses, that implements the outlets & actions that are
connected in the .xib. Each subclass can then override the actions as
needed. In IB (or Xcode 4, as the case may be), just define the
"file's owner" in the .xib as the parent class.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: finder eject images

2011-07-05 Thread Sherm Pendley
On Tue, Jul 5, 2011 at 6:53 AM, Ulf Dunkel  wrote:
> Hi Lee Ann.
>
>> Also I think Apple frowns on copying their icons into your apps. Only the
>> ones you can get through imageNamed: or iconForFileType: are fair game.
>
> Wasn't it Steve Jobs who invited us to pick all their nice icons, somewhen
> in the past when he introduced Leopard (or even Tiger)?

Yes, but we're supposed to use them in-place, not copy them into our apps.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Apache Module

2009-11-28 Thread Sherm Pendley
On Fri, Nov 27, 2009 at 6:45 PM, Mr. Gecko  wrote:
> Hello, I'm working to write an Apache Module that allows you to make websites 
> in Objective-C

Been there, done that. :-)

Have a look at the list archives:


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: Apache Module

2009-11-28 Thread Sherm Pendley
On Sat, Nov 28, 2009 at 7:54 AM, Sherm Pendley  wrote:
> On Fri, Nov 27, 2009 at 6:45 PM, Mr. Gecko  wrote:
>> Hello, I'm working to write an Apache Module that allows you to make 
>> websites in Objective-C
>
> Been there, done that. :-)
>
> Have a look at the list archives:
> <http://lists.apple.com/archives/Cocoa-dev/2005/May/msg01522.html>

Keep in mind though, that I posted that nearly five years ago, and
wrote the code for Apache 1.x. The basic idea of registering a
trampoline function that bounces requests to your handler class still
works, but you'll need to update the code to the Apache 2.x API.

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: Apache Module

2009-11-30 Thread Sherm Pendley
On Sat, Nov 28, 2009 at 1:19 PM, Mr. Gecko  wrote:
> Ok, I know your idea of a CGI Proxy like PHP CGI

That's not what I said. Did you read the link I gave you?

> On Nov 28, 2009, at 9:32 AM, Sherm Pendley wrote:
>
>> Keep in mind though, that I posted that nearly five years ago, and
>> wrote the code for Apache 1.x. The basic idea of registering a
>> trampoline function that bounces requests to your handler class still
>> works, but you'll need to update the code to the Apache 2.x API.

I'm not talking about a "CGI Proxy" here. Apache's module API doesn't
know how to directly call an Objective-C method. So, you need to write
a C function that "bounces" the call to your method. Such functions
are commonly called "trampoline" functions.

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: iterating and removing objects from a collection

2009-11-30 Thread Sherm Pendley
On Mon, Nov 30, 2009 at 4:21 PM, Ken Thomases  wrote:
> On Nov 30, 2009, at 2:45 PM, Dennis Munsie wrote:
>
> Some alternatives:
>
> * Iterate over the array just using an index, rather than fast enumeration 
> (or NSEnumerator).

A safe way to do that is to iterate backwards, starting at the max
index and counting down to 0. That way, removing the item at the
current index will only change the indexes of the items you've already
seen.

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: problem encoding large float* matrix

2009-12-01 Thread Sherm Pendley
On Tue, Dec 1, 2009 at 1:47 PM, James Maxwell
 wrote:
> I'm trying to save the state of my app. It chews up a lot of memory, most of 
> which is in large float* matrices. I'm getting an EXC_BAD_ACCESS error in 
> -encodeBytes:length:forKey: and I'm just wondering what might be happening. 
> The float* "coincidences" is a malloced array.
>
> NSUInteger coincsSize = maxCoincs * inputSize * sizeof(float);

This looks suspicious to me. Based on the variable names, it looks
like you malloc(maxCoincs * sizeof(float)), then store the actual
number of floats in the buffer in inputSize. If that's what you're
doing, you only need to multiply by maxCoincs (to get the size of the
whole buffer) or by inputSize (to find out how much of the buffer is
actually in use) - not by both of them.

> NSData* coincData = [NSData dataWithBytesNoCopy:&coincidences 
> length:coincsSize];
> [aCoder encodeBytes:[coincData bytes] length:coincsSize 
> forKey:@"coincidences"];

As someone else said, if you created the buffer with "coincidences =
malloc(...)", then you don't need to dereference it here; doing so
will give you the address of the pointer variable, not the address of
the buffer to which it points.

What's the point of creating the NSData object here? Wouldn't this be
just as good?

[aCoder encodeBytes:coincidences length:coincsSize forKey:@"coincidences"];

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: Remember Window and Inspector Positions

2009-12-21 Thread Sherm Pendley
On Mon, Dec 21, 2009 at 2:38 PM, Alexander Spohr  wrote:
>
> Am 21.12.2009 um 20:22 schrieb David Blanton:
>
>> I have a main window and a few floating inspectors. I would like to come 
>> back to the position the user left these upon relaunch. Do I have to program 
>> this or is there some Cocoa or other construct that does this for me?
>
> You can put that into UserDefaults.
> And I think a window just needs a name (in IB even?)

Yes, you can do that in IB. It's the "Autosave" in the Attributes pane
of the inspector panel.

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: Simple question on Menus and Document-based apps

2009-12-21 Thread Sherm Pendley
2009/12/21 Henri Häkkinen :
>
> So I have a simple document-based application which has MyDocument with some 
> other classes. The application has the default MainMenu.xib and 
> MyDocument.xib interface files. I would like to add a menu item to the 
> MainMenu, which would call an IBAction method on the MyDocument class. 
> However, the document class and the main menu are on different xib files so I 
> can't make the connection.
>
> What is the Right Way to handle these kinds of things in Cocoa?

Connect the menu item to the "First Responder" in Interface Builder.
At runtime, Cocoa's event-handling machinery will then look through
the responder chain (which includes, among other things, the
currently-active document) to find an object that has the required
action method.

For details, have a look at:




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: Releasing Objects

2009-12-24 Thread Sherm Pendley
On Thu, Dec 24, 2009 at 5:13 PM, Greg Parker  wrote:
>
> More precisely, there's exactly one short-circuit check and thus only one 
> selector value. Under GC, @selector(retain) == @selector(release) == 
> @selector(autorelease) == @selector(dealloc) == @selector(retainCount). 
> Happily, `return self` works to implement all of those.

Just out of curiosity, is that really a short-circuit in the
message-passing machinery, or are all those selectors simply
registered to point to the same IMP function? A useless bit of
knowledge for us end-users, I know, but interesting just the same.

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

I think that should be "Wruntime Wrangler." :-)

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: Releasing Objects

2009-12-24 Thread Sherm Pendley
On Thu, Dec 24, 2009 at 7:36 PM, Joar Wingfors  wrote:
>
> On 24 dec 2009, at 15.16, Sherm Pendley wrote:
>
>> Just out of curiosity, is that really a short-circuit in the
>> message-passing machinery, or are all those selectors simply
>> registered to point to the same IMP function? A useless bit of
>> knowledge for us end-users, I know, but interesting just the same.
>
>
> Short circuited. See:
>
>        
> <http://www.friday.com/bbum/2009/12/18/objc_msgsend-tour-part-3-the-fast-path/>

Wow, that's a *fascinating* read! Thanks!

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: Dynamically update drawRect

2009-12-27 Thread Sherm Pendley
On Sun, Dec 27, 2009 at 4:51 AM, proger proger  wrote:
> So now i don't see how to solve this problem. I thought it's not very hard
> problem - get data and paint it. Maybe i need to use other tools ? I think
> with libSDL framework it's very simple to solve such thing. I'm wanted to
> learn more about CG but seems even simple problem is too hard for me.
>
> Maybe i need to MyView constructor add my program logic and invoke '[self
> setNeedsDisplayInRect: suppliedRect]' ?

I suggest reviewing the docs concerning the design patterns used in
Cocoa - you're not going to figure this out by making assumptions
based on how libSDL or some other toolkit works. When in Rome, do as
the Romans do.




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: Retain Count of NSConnection object

2010-01-04 Thread Sherm Pendley
On Mon, Jan 4, 2010 at 10:34 AM, Alexander Reichstadt  wrote:

> I can hardly expect for this to be a Cocoa-bug but imagine I am
> misunderstanding something. Can anyone help and please tell me where I am
> erring here?

You're expecting -retainCount to return a useful number. It doesn't.

Have a look at:


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: Looking up a NSString constant at runtime

2010-01-04 Thread Sherm Pendley
On Mon, Jan 4, 2010 at 4:56 PM, David Alter  wrote:
> Is there a way to lookup what and NString constant is at runtime?

Just log it, same as any other string:

NSLog(@"%@", NSDeviceResolution);

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: iPhone: validate a NSString for US zipcode

2010-01-07 Thread Sherm Pendley
On Thu, Jan 7, 2010 at 11:53 AM, Eric E. Dolecki  wrote:
> I don't care about the city, just that the zip code will work. On an iPhone
> testing against an array of 42,305 values... could that be pretty quick?
> Seems like a large set to go through looking. I'm sending the value to a
> webservice to return weather data.

Doesn't the service return an error if you give it an invalid zip
code? You could simply check for that. Doing so would avoid having to
do the check on the phone, and also having to update your app whenever
zip codes change.

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: ConvertCocoa64: spaces in filename problem

2010-01-11 Thread Sherm Pendley
Completely agree with the problem and your suggested alternative, but
this ain't the place to file bug reports. You should file this at:



sherm--

On Mon, Jan 11, 2010 at 10:56 AM, A.M.  wrote:
> On this page:
>
> http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/Cocoa64BitGuide/ConvertingExistingApp/ConvertingExistingApp.html#//apple_ref/doc/uid/TP40004247-CH5-SW5
>
> Apple suggests using:
>
> /Developer/Extras/64BitConversion/ConvertCocoa64 `find . -name '*.[hm]' | 
> xargs`
>
> However, that combination of "xargs" and "find" fails to account for 
> filenames with elements that need to be escaped, such as spaces. You may not 
> notice that the utility didn't process such files because the ruby script 
> prints a line for each file, effectively hiding the errors.
>
> A better incantation is:
>
> find . -name '*.[hm]' -print0| xargs -0 
> /Developer/Extras/64BitConversion/ConvertCocoa64
>
> 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/sherm.pendley%40gmail.com
>
> This email sent to sherm.pend...@gmail.com
>



-- 
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: (void *)contextInfo

2010-01-12 Thread Sherm Pendley
On Tue, Jan 12, 2010 at 2:51 PM, Rainer Standke  wrote:
>
> Here is the code that displays the sheet:
>
> NSArray *theContextInfo = [[NSArray alloc] init];

This creates a new array that you are responsible for releasing when
you're finished with it.

>        theContextInfo = [NSArray arrayWithObject:objTBD];

This creates a new array that you are *not* responsible for releasing.

Because you assign the result to theContextInfo without releasing the
previous array, that one leaks. Because you expect to use the new
array later, you should have retained it.

> What am I missing? (Another newbie thing I suspect...)

The memory management guidelines:




Additionally, I'd recommend making theContextInfo into an instance
variable, rather than passing it through the contextInfo. You can then
write (or @synthesize) an accessor method that encapsulates all of the
relevant memory management into one place, which is *far* less
error-prone than scattering -retain and -release calls all over the
place.

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: Getting filesize when downloading file with NSURLDownload?

2010-01-19 Thread Sherm Pendley
On Tue, Jan 19, 2010 at 2:13 PM, Laurent Daudelin
 wrote:
> I'm using an NSURLDownload to download a file from a server. Is there any way 
> I could find what the size of the file will be so that I could put up a nice 
> progress indicator?

Implement the -download:didReceiveResponse: method in the download
object's delegate. You can then call the NSURLResponse object's
-expectedContentLength method.

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: Allow only root/admin users to execute the cocoa app

2010-01-24 Thread Sherm Pendley
On Sun, Jan 24, 2010 at 4:19 AM, Arun  wrote:
>
> I want to allow my cocoa app to be only launched by root/admin users.
> How can i achieve this?

Use Authorization Services to check for admin authority, and exit if
your app doesn't have it.




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: dynamic typing in a text field

2010-01-25 Thread Sherm Pendley
On Mon, Jan 25, 2010 at 11:16 AM, Ronald Hofmann  wrote:

> I want a textfield in my project which triggers a method while I´m writing in 
> it.
> I saw this option 'continous' in the interface builder which works fine with 
> sliders.
> While I move the slider the method executes.
>
> How can I do the same thing with a textfield?

Assign a delegate to the text field, and implement the
-controlTextDidChange: method in the delegate's class.

> I can´t find it. Is there an example somewhere?

Don't forget to look in the superclass! NSTextField is a subclass of
NSControl, which is where the above delegate method is defined and
documented.

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: 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: Odd NSString behavior

2010-02-24 Thread Sherm Pendley
On Wed, Feb 24, 2010 at 2:30 PM, McLaughlin, Michael P.  wrote:
> This is just a minor glitch but I hate loose ends.
>
> I have a Cocoa app as a resource in my MainBundle.  If I try to get its
> executable via the obvious
>
> NSString * linrgPath = [myBundle pathForResource:
> @"linrg2.app/Contents/MacOS/linrg2" ofType: @""];
>
> then linrgPath is nil;

Seems reasonable - pathForResource:ofType: is probably respecting the
fact that linrg2.app is itself a bundle, and refusing to look around
inside of it.

> However, if I split the path into two pieces it works as intended.
>
> NSString * linrgPath = [myBundle pathForResource: @"linrg2.app" ofType:
> @""];
> linrgPath = [linrgPath stringByAppendingString:@"/Contents/MacOS/linrg2"];
>
> Is this reasonable?

It could be better, IMHO. The type of your resource is "app", and you
shouldn't hard-code the location of the executable within it. I'd
create another NSBundle instance to represent the resource app, then
ask that bundle for the path to its executable, something like this:

NSBundle *linrgBundle = [NSBundle bundleWithPath:[myBundle
pathForResource:@"linrg2" ofType:@"app"]];
NSString *linrgExecutable = [linrgBundle executablePath];

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: Looking for info on anti-piracy and trial-mode techniques for my app . . .

2010-02-24 Thread Sherm Pendley
On Wed, Feb 24, 2010 at 4:54 PM, Michael A. Crawford
 wrote:
> I've purchased apps from other developers on this forum, which have 
> mechanisms for limiting functionality until a valid registration code has 
> been provided.  I'd like to include this functionality in my own app but 
> don't want to create it from scratch if I don't have to.  To that end, I'm 
> looking for existing libraries, techniques, blogs, and/or suggestions.

Not a big fan of such things myself, but to each his own... That said,
I've heard good things about Aquatic Prime:



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: Embedded frameworks and hard links

2010-02-24 Thread Sherm Pendley
On Wed, Feb 24, 2010 at 11:58 PM, Ashley Clark  wrote:
> I've been using an embedded framework in a couple of my apps for database 
> access. I've recently created an Automator action which also embeds this 
> framework, built from within the same project. This Automator action is, in 
> turn, then embedded within the app bundle also. Now at this point, there are 
> two copies of the embedded framework contained within the app bundle.
>
> I've manually replaced the contents of the duplicate framework in the action 
> with hard links to the other embedded framework and it works well but I'm 
> wondering if there's some automated way to do this already that I'm missing.
>
> Does anyone know of a tool or Xcode setting that would do this or has someone 
> already written this?

I assume that your framework is built with an install name that begins
with @loader_path/../Frameworks, right?

The framework's install name is copied into your .app and .action
binaries at link time, and it's those copies that the dynamic loader
uses to find the framework at run time. So, you can add a shell script
build phase at the end of your .action target, and use
install_name_tool to modify the .action binary to look in
@loader_path/../../../../../Frameworks instead.

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: Carbon is C++?

2010-02-25 Thread Sherm Pendley
On Thu, Feb 25, 2010 at 6:42 PM, Dave Carrigan  wrote:
>
> On Feb 25, 2010, at 3:40 PM, Chunk 1978 wrote:
>
>> is Apple's Carbon basically code written in C++, while Cocoa is
>> written in Objective-C?  should developers avoid using frameworks
>> written in C++ (like some sound frameworks)?
>
>
> Why? Objective-C and C++ mix just fine as long as you follow a few basic 
> rules. Apple's documentation can tell you specifically what rules to follow.

... and what APIs are deprecated.

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: Carbon is C++?

2010-02-25 Thread Sherm Pendley
On Thu, Feb 25, 2010 at 7:02 PM, Stephen J. Butler
 wrote:
>
> Apple has deprecated libraries/frameworks. They haven't stopped
> supporting any languages though.

I'm pretty sure they no longer support Pascal. ;-)

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: How a window was closed?

2010-03-05 Thread Sherm Pendley
On Fri, Mar 5, 2010 at 1:44 PM, Eric Gorr  wrote:
> My point is not that I don't know how to fix it or cannot (as an absolute) 
> fix it, but that it is not practical to fix it at this time, so I need a way 
> to determine how the window was closed.

Given that there's no reliable way to determine that, you might want
to reconsider the practicality of the alternative.

> If you have never faced one of these situations before, just wait 
> awhile...you will.

I have. The thing is, it's a mistake to take it as a matter of dogma
that the workaround will *always* be the easier solution. Doing so
runs the risk of failing to recognize when one has arrived at a point
when that is no longer true.

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: short question but I don't know how to describe it

2010-03-07 Thread Sherm Pendley
On Sun, Mar 7, 2010 at 7:07 PM, Marx Bievor  wrote:
> Hi,
> I can substitute a String with %@ and an int with %d... like in return @"Hi
> I am %@ and %d years old", name, age;
> what is the right command to substitute a bool and a float? I cannot find
> any reference at apple's docs.
> does anyone have a list of those commands?

They're called "format specifiers," and they're listed here:




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: Determining OS at Runtime

2009-07-01 Thread Sherm Pendley
On Wed, Jul 1, 2009 at 7:24 PM, iseecolors wrote:
> I need to support 10.4 in my application, but it uses some Carbon APIs that
> are deprecated in 10.5 and I am using some new 10.5 APIs that require the
> 10.5 SDK.
>
> I am sure I have seen this before, but I have been unable to find it in the
> Archive.  How do I determine at runtime which OS version I am running on?

Just check for the presence of the function you want to call. In
Xcode, set your deployment target to 10.4, so that Leopard-only
symbols will be weak-linked. Then just check the symbol for NULL
before calling it:

if (SomeLeopardFunction != NULL) {
SomeLeopardFunction();
} else {
TigerFunction();
}

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Cocoa Frontend to SDL App

2009-07-10 Thread Sherm Pendley
On Fri, Jul 10, 2009 at 9:58 AM, Anthony Smith wrote:
> I'm wanting to integrate an already made SDL app executed through the
> command line into a Cocoa app within a custom view. Does anybody have any
> insight on where to start something like this?

The most obvious starting point would be the Xcode project template
that's included with the Mac version of SDL. Just create a new
project, add your existing files, and bob's your uncle.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Initialising NSMutableArray

2009-07-13 Thread Sherm Pendley
On Mon, Jul 13, 2009 at 12:53 PM, I. Savant wrote:
> On Jul 13, 2009, at 12:41 PM, Quincey Morris wrote:
>
>> What you *don't* get for free from subclassing is an internal storage
>> mechanism -- you have to invent that for yourself (usually by putting a real
>> NSArray instance variable in your subclass :) ). You also need a pretty
>> clear understanding of how class clusters work, and that's where confusion
>> can set in.
>
>  These two sentences are exactly my point. Perhaps we have differing
> opinions of what makes an angry, fire-breathing, treasure-grubbing dragon.
> :-)

I agree with Quincey. The difficulty of subclassing a class cluster is
often over-stated on this list. There's really not much to it. Just
implement the primitive methods - by providing your own storage, or by
using a "real" collection object in an instance variable - and bob's
your uncle.

>  What's more (said in an off-list discussion with the OP): It's just not
> worth it to say "give me a mutable array with a single instance of a certain
> class".

Sure, if I wanted an easy way to get a single-element array of Foo,
I'd implement +arrayWithSingleFoo on the Foo class. I'd do it that way
even if NSArray were not a class cluster - there's no need to create a
whole new class just for such a simple task.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: I need a milder application badge (solution)

2009-07-25 Thread Sherm Pendley
On Sat, Jul 25, 2009 at 1:54 PM, Jay Reynolds
Freeman wrote:
> What I want to do is modify the dock icon while the application running.
>  The only interface I can find to do this is
> NSApp.setApplicationIconImage: , which requires an NSImage.  I have no way
> to get at the actual view being used to draw the dock icon, in order to
> subclass it; I have to create a new NSImage somehow, and pass that to
> setApplicationIconImage.

You don't need to subclass anything just to draw into an NSImage. You
can call an NSImage's -lockFocus method to direct all the usual
drawing functions and methods to draw into that image, instead of into
an onscreen view. Don't forget to call -unlockFocus when you're done!

So, what you want to do is, get the default image, -copy it and
-autorelease the copy, send the copy a -lockFocus, draw whatever
content you want to add to the icon, using all the usual functions &
methods you'd have used in a subclass' -drawRect: method, send the
copy a -unlockFocus, send the copy to -setApplicationIconImage:.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Trouble with NSColor

2009-08-13 Thread Sherm Pendley
On Thu, Aug 13, 2009 at 1:29 PM, Daniel Furrer wrote:
> On Thu, Aug 13, 2009 at 6:51 PM, Sean McBride wrote:
>
>> Did you read the docs for 'redComponent'?
>>
>> "This method works only with objects representing colors in the
>> NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace color space"
>>
>> Use colorUsingColorSpaceName:NSCalibratedRGBColorSpace to convert.
>
> I believe that's what I'm doing in my first line of code, no?

Not quite - in your code, you're using NSCalibratedRGBColorSpace as a
literal string value, not as the name of a global variable.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Cleaning "garbage" in Core Data

2009-08-16 Thread Sherm Pendley
On Sun, Aug 16, 2009 at 11:22 AM, Squ Aire wrote:
>
> Just to make it clear: The whole userInfo dictionary will tend to NOT be 
> "garbage". Only a subset of key-value pairs within the userInfo dictionaries 
> for the employees will be "garbage". I want to get rid of this subset without 
> bothering the user in any way.
>
> Therefore, the attribute must persist and transient properties will not work 
> in this case. I hope my problem is clearer now.

Seems to me that the source of the problem is the mixing of transient
and persistent key-value pairs within the same dictionary. If you
store the transient pairs in a dictionary of their own, that whole
dictionary could be transient.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Two controllers in a window, how do I get one to run a function in another?

2009-08-27 Thread Sherm Pendley
On Thu, Aug 27, 2009 at 10:04 AM, Graham Cox wrote:
>
> On 27/08/2009, at 11:55 PM, Support wrote:
>
>> I want to have two NSObjects (controllers) - one for the tableview and all
>> the actions that it needs to perform, and one for the web view.  I am having
>> difficulty getting the tableview controller to tell the webview controller
>> to display a particular page.  And I can't find anything about this subject
>> in my Cocoa books or on the web.  Am I barking up the wrong tree here?
>>  Should I only have one controller per window?
>>
>> I'd be most grateful for any enlightenment.
>
>
> One controller for each view sounds like a good plan. There's certainly no
> requirement that you can have only one controller per window.

Also, there's no requirement that outlets refer to graphical widgets
either. You can create outlets that refer to other controller objects
too, and connect them in Interface Builder.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Best way to determine what ip address are assigned to a given network interface.

2009-08-27 Thread Sherm Pendley
On Thu, Aug 27, 2009 at 10:09 AM, Mark McCray wrote:

> I've seen a bunch of methods for getting a list of ip addresses that a
> machine may have. But i haven't seen a Cocoa way of figuring out what
> ip address is attached to a given interface.  NSHost give's you IPs
> but which network interfaces those IPs are attached to.
>
> Can this be done with the SystemConfiguration Framework?
>
> Why do I need this? We know a bunch of our machines have many IPs but
> we only care about ethernet ip addresses. and we typically only care
> about ones that are en0 or en1. We want to write an application which
> will give this information to us easily without the user having to go
> into System Preferences.

If you know which interface(s) you want info about, you could run
"/sbin/ifconfig en0" with NSTask.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.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: Elapsed time vs sleep

2010-07-26 Thread Sherm Pendley
That depends on what you mean when you say "animation." NSTimer works
fine for triggering screen updates. But if your animation is
physics-based - a 3d "shooter" game, for instance - you'll want
something like the aforementioned mach_absolute_time to keep the
animation smooth.

sherm--

On Mon, Jul 26, 2010 at 12:27 PM, Charlie Dickman <3tothe...@comcast.net> wrote:
> As long as the NSTimer firing interval is sufficiently small the NSTimer can 
> be used. If the run loop is stalled for any "significant: time _all_ timers 
> will be inaccurate to some degree. The NSTimer works fine for animation and , 
> e.g., alarm timers and they are consistent across platforms such as Mac Pros, 
> iMacs, iPhones, etc.
>
> On Jul 26, 2010, at 12:12 PM, Kyle Sluder wrote:
>
>> On Jul 26, 2010, at 8:32 AM, Charlie Dickman <3tothe...@comcast.net> wrote:
>>
>>> Try using an NSTimer with a repeating timeout interval of, say, .001 (or 
>>> anything smaller than your required accuracy), and countdown your time 
>>> delta by the same amount each time the NSTimer fires and when you get to 
>>> zero you'll have what you need.
>>
>> NSTimer is not suitable for timekeeping of any significant resolution. 
>> NSTimer works by comparing the current time at the top of the runloop with 
>> the last time the timer was fired. Obviously, this is highly susceptible to 
>> anything that prevents the runloop from running at at least the timer 
>> interval—which on a modern multitasking operating system is quite likely.
>>
>> mach_absolute_time is certainly the way to go. The best advice I've seen out 
>> there is to listen for sleep/wake notifications from IOKit and record the 
>> system time there to figure out how much time has elapsed between the two.
>>
>>
>> --Kyle Sluder
>
> Charlie Dickman
> 3tothe...@comcast.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/sherm.pendley%40gmail.com
>
> This email sent to sherm.pend...@gmail.com
>



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

2010-07-26 Thread Sherm Pendley
On Mon, Jul 26, 2010 at 4:39 PM,   wrote:
>
> where is rm?

Ironically, that's almost exactly the shell command you'd use to find
it: "whereis rm". :-)

Bill's right though - NSFileManager seems like a much better way to do this.

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: Screen pixels changed notification?

2010-07-26 Thread Sherm Pendley
On Mon, Jul 26, 2010 at 8:37 PM, Ryan Joseph  wrote:
>
> Are there any notifications I could get that would tell me if screen pixels 
> changed

I don't know of any Objective-C methods - you might have a look at the
Core Graphics function CGRegisterScreenRefreshCallback().

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: Calling Matlab from Cocoa

2010-07-30 Thread Sherm Pendley
On Fri, Jul 30, 2010 at 1:00 PM, Chris Goedde  wrote:
>
> Anyone here have any experience calling Matlab from a Cocoa program?
>
> I have a rather complex calculation that I've implemented in Matlab that I 
> would like to call from a Cocoa program. (I could re-implement it in 
> Objective C if absolutely necessary, but I would prefer not to; it would 
> probably take me several weeks to get right.) Matlab comes with the glue to 
> integrate with C/C++ (see 
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/f38569.html),
>  so I think what I want to do should be possible.

Remember, Objective-C *is* C. The easiest thing to do IMHO would be to
simply call the C functions.

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: Wow! Just installed OPENSTEP ENTERPRISE 4.2

2010-08-06 Thread Sherm Pendley
On Fri, Aug 6, 2010 at 6:21 PM, Todd Heberlein  wrote:
>
> It took a lot longer to bring out Mac OS X than I expected after the 
> acquisition. We never got our "yellow box" for windows (with the promised 
> free runtime libraries).

Have you seen Cocotron?

  

Not from Apple, but they are free. And, you get to develop in Xcode
and add a cross-compiled Windows target to your project. :-)

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: stringByReplacingCharactersInRange leading to bus error

2010-08-18 Thread Sherm Pendley
On Wed, Aug 18, 2010 at 2:52 PM, Murat Konar  wrote:
>
> On Aug 18, 2010, at 11:06 AM, John C. Randolph wrote:
>
>> -stringByReplacingCharactersInString: creates and returns a new string,
>> which is autoreleased.
>
> Always?

Yes, always.

> I recall running into a problem that was caused by
> -stringByReplacingCharactersInString: (or a method like it) simply returning
> self if no substitution occurred.

Possibly, but even in that case it would still have to "return [[self
retain] autorelease];" in order to fulfill its end of the memory
management contract.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: stringByReplacingCharactersInRange leading to bus error

2010-08-18 Thread Sherm Pendley
On Wed, Aug 18, 2010 at 3:33 PM, Kyle Sluder  wrote:
> On Wed, Aug 18, 2010 at 12:16 PM, Sherm Pendley  
> wrote:
>> Possibly, but even in that case it would still have to "return [[self
>> retain] autorelease];" in order to fulfill its end of the memory
>> management contract.
>
> This is incorrect. It's perfectly valid to just return self if you
> aren't returning a +1 reference.

Not true. Consider this example, where
-stringByReplacingOccurrencesOfString:withString: could reasonably
take a shortcut and return self:

  NSString *foo = [[NSString alloc] initWithString:@"foo"];
  NSString *bar = [foo stringByReplacingOccurrencesOfString:@"foo"
withString:@"foo"];
  [foo release];

The "[foo release]" is perfectly correct, but if
-stringByReplacingOccurrencesOfString:withString: is implemented with
a simple "return self;" then *both* foo and bar would be immediately
released. Implementing it as "return [[self retain] autorelease]"
prevents such problems.

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: stringByReplacingCharactersInRange leading to bus error

2010-08-18 Thread Sherm Pendley
On Wed, Aug 18, 2010 at 4:22 PM, Kyle Sluder  wrote:
> On Wed, Aug 18, 2010 at 12:49 PM, Sherm Pendley  
> wrote:
>> The "[foo release]" is perfectly correct, but if
>> -stringByReplacingOccurrencesOfString:withString: is implemented with
>> a simple "return self;" then *both* foo and bar would be immediately
>> released. Implementing it as "return [[self retain] autorelease]"
>> prevents such problems.
>
> It doesn't violate the memory management guidelines to do so. The onus
> is technically on the caller to retain bar if he wants to use it later.

Here's the example you snipped:

  NSString *foo = [[NSString alloc] initWithString:@"foo"];
  NSString *bar = [foo stringByReplacingOccurrencesOfString:@"foo"
withString:@"foo"];
  [foo release];

The caller is doing nothing wrong here. It's finished using foo, and
released it. If the caller's only use of bar is within the scope of
the calling method, it's under no obligation to retain it. It's the
responsibility of -stringByReplacing... to return an object that
remains valid throughout the caller's scope, even if the original
string is released. Doing "return [[self retain] autorelease]"
fulfills that responsibility; "return self" does not.

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

Indeed, on that very page, at
<http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/Articles/mmAccessorMethods.html#//apple_ref/doc/uid/TP40003539-SW6>,
it gives this example:

  - (NSString*) title {
  return [[title retain] autorelease];
  }

...

"Because the object returned from the get accessor is autoreleased in
the current scope, it remains valid if the property value is changed.
This makes the accessor more robust, but at the cost of additional
overhead."

Implementing -stringByReplacing... as "return [[self retain]
autorelease];" makes the same guarantee, that the object returned by
-stringByReplacing... will remain valid if the original string is
released.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: stringByReplacingCharactersInRange leading to bus error

2010-08-18 Thread Sherm Pendley
On Wed, Aug 18, 2010 at 5:23 PM, Kyle Sluder  wrote:
> On Wed, Aug 18, 2010 at 2:08 PM, Sherm Pendley  
> wrote:
>
>> Indeed, on that very page, at
>> <http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/Articles/mmAccessorMethods.html#//apple_ref/doc/uid/TP40003539-SW6>,
>> it gives this example:
>
> It gives it as one example of three, the other two not having
> performing an immediate retain/autorelease pair.

The second example avoids having a retain/autorelease in the getter,
by moving the autorelease to the setter instead; while valid for
accessors, it's not really applicable to -stringByReplacing..., since
that's not an accessor method.

The third example avoids autorelease, but has precisely the same
problem that "return self" would have:

"Its disadvantage is that the old value may be deallocated immediately
(if there are no other owners), which will cause a problem if another
object is maintaining a non-owning reference to it. For example:

  NSString *oldTitle = [anObject title];
  [anObject setTitle:@"New Title"];
  NSLog(@"Old title was: %@", oldTitle);

If anObject was the only object that owned the original title string,
then the string will be deallocated after the new title is set. The
log statement would then cause a crash as oldTitle is a freed object."

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: stringByReplacingCharactersInRange leading to bus error

2010-08-18 Thread Sherm Pendley
On Wed, Aug 18, 2010 at 5:25 PM, Martin Wierschin  wrote:
> On 2010.08.18, at 2:08 PM, Sherm Pendley wrote:
>
>> Implementing -stringByReplacing... as "return [[self retain]
>> autorelease];" makes the same guarantee, that the object returned by
>> -stringByReplacing... will remain valid if the original string is
>> released.
>
> Yes, but there's no guarantee which technique -stringByReplacing.. will use
> internally.

True, but the MM rules *do* guarantee that -stringByReplacing...* will
return an object that remains valid throughout the caller's scope.
Implementing with a simple "return self;" wouldn't fulfill that
contract, since releasing the original object would then release the
"copy" as well.

* Is anyone else wishing that we'd chosen a shorter method name to
have this discussion? :-)

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Trying to capture XML data and convert to a String...

2010-08-19 Thread Sherm Pendley
On Wed, Aug 18, 2010 at 3:11 PM, R  wrote:
> I'm new and in the process of learning Objective-C and Cocoa.
>
> I want to take some raw XML data, isolate, and convert to a string.  I seem 
> to be able to capture the data I want, but cannot seem to get into a string 
> format.  Actually, I will want in a NSMutableString format… but am keeping 
> things simple for now.
>
> Here is an excerpt of my code:
>
> The problem is at the end of the code below….  the string findAlerts is 
> empty.  The NSXMLElement specificAlert prints correctly.

...

>        myGames=[[gameStatusXML nodesForXPath:@"//alerts" error:&error]retain];

The alerts element in the document you pointed to is:

  

>        findAlerts=[specificAlert stringValue]; // attempting to create a 
> string

-stringValue returns the value of any text-node children, but the
alerts node has no such children. Try using -attributes to get an
array of all the attributes, or -attributeForName: to get one of them.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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: Set the Cursor Position

2010-08-19 Thread Sherm Pendley
On Thu, Aug 19, 2010 at 9:32 PM, Murat Konar  wrote:
> CGDisplayMoveCursorToPoint(CGDirectDisplayID display, CGPoint point);
>
> But heed the other's hints that, except for special classes of software
> (like a VNC app), software that warps the pointer's location independent of
> the mouse is much un-loved on the Mac.

One such exception would be 2d or 3d graphics apps, where it's
expected to have a tool that allows the user to click and drag to
scale or rotate an object. When such a tool is active, one might
respond to drag events by modifying the model to match the mouse
movement, then warping the cursor back to its original position.

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.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


  1   2   3   4   >