Re: Apple MVC and Document Based application confusion.

2009-11-29 Thread Jason Stephenson

Graham Cox wrote:

On 30/11/2009, at 12:04 PM, Jason Stephenson wrote:


NSDocument and the document-based architecture in Cocoa is a bad
example of MVC.



As a statement that doesn't really stand up to scrutiny. Sure, you
can abuse NSDocument and violate MVC, but as it comes it does not. A
document might own (or be) the data model, and it might also keep a
list of window controllers. How does that violate MVC? NSDocument is
just 'M', and nothing more.


-makeWindowControllers and I disagree with you.


Let me rephrase what I said earlier:

NSDocument and the document-based architecture in Cocoa is a bad example 
of MVC in as much as people confuse NSDocument with a document model 
class when it is a model controller.--This is the confusion that I think 
our friend Sandro is running into.


NSDocument doesn't merely represent the document's data as in a "pure" 
MVC design, rather it is a controller for the document's data. The 
subsection of the Document-Based Applications Overview entitled "The 
Role of NSDocument" makes this abundantly clear. The actual model data 
for the document is very often an ivar of the NSDocument subclass.


A data model should not be required to create controllers for GUI 
elements as NSDocument is asked to do by NSDocumentController when a new 
document is created. The creation and management of GUI elements is 
typically a controller's job, not a model's job. A model should be 
abstract in the sense that it is not tied to any particular visual 
representation of the data. It should work in a command line application 
as well as it works in a GUI application.--Admittedly, this is an ideal.


While NSDocument doesn't necessarily break MVC, I think the class is 
poorly named. It should probably more properly be named 
NSDocumentController and NSDocumentController would more properly be 
named NSDocumentControllerController, but that's a bit awkward.


Now, I will stop before the moderators hit me with the moderation flag, 
because I have a feeling we're going over old ground.





--Graham




___

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

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

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

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


Re: Apple MVC and Document Based application confusion.

2009-11-29 Thread Jason Stephenson

Sandro Noël wrote:

Hello.

I'm reading COCOA Design Patterns from Eric M. Buck & Donald A. Yacktman.
and i'm having a hard time applying the principle in my architecture.

for example, if i create a new document based application in XCode, the MyDocument xib file 
binds the window outlet to the MyDocument Class.


NSDocument and the document-based architecture in Cocoa is a bad example 
of MVC. By default when creating a document-based application in Xcode, 
you get what I like to call MC-V where the model and controller are 
wrapped up in one object. This is very often easier to implement in a 
standalone application where you do not expect to reuse the data model 
class, ever, than is a more traditional MVC approach.


Personally, I prefer to add a NSWindowController subclass for my 
document and make that the File's Owner in the nib/xib. I also don't 
start with the document-based application template, but instead start 
with a straight Cocoa application and then add my NSDocumentController, 
NSWindowContoller, and NSDocument subclasses.


I have not yet needed a NSViewController subclass, but my 
NSWindowController subclass typically fills that role since it generally 
 has the NSView subclass as an outlet and manages whatever needs 
managing in the particular app.








From what I read the MyDocument Class is supposed to be a model controller, not 
the window controller.
The MyDocument Class is supposed to be able to host an array of window 
controllers.
I see that makes sense if I have a main data view window and I would want to associate an inspector 
to that window and share the same data source with both windows. and I like that idea.
 
what i am unsure of is how to go about with interface builder, and where should i associate the view with it's controller

inside the MyDocument Class? ( but i read that model should have no knowledge 
of the view)
is it the same for the Model Controller? 


if it's not then MyDocument Class becomes more than a Model Controller it is 
also a Window controller.
in witch case why bother creating separate View/Window controllers?
and why host an array of window controllers?

Do i create the Window controllers in IB or do i do it in code, and how would i 
go about doing that the right way?


Have you read this?

http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/Documents.pdf

It might prove helpful.



I'm kind of confused and I'd really love some clearing up.

thanks for any pointers.
Sandro Noel.___

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

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

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

This email sent to ja...@sigio.com


___

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

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

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

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


Re: avoiding spagetti code

2009-11-09 Thread Jason Stephenson

Oftenwrong Soong wrote:

Hi all,

In the MVC style, I want to avoid connecting directly between a view 
and a model. However I have a custom NSView subclass that renders a 
graphical view of the model and therefore it needs information from 
the model. I think it is considered bad practice to put a pointer to 
the model directly in my NSView subclass. However how can this type 
of coupling be avoided if the view needs the information?




Have an actual controller class handle the interaction between the View
and the Model. Most of the MVC examples you find for Cocoa are actually 
MC/V where model and controller are wrapped in 1 class. This is very 
often easier to implement in a standalone application.


However, if you want real separation between the view and the model, 
then you'll need a real controller class to query the model and pass 
information to the view when the view needs the model data. The 
controller could also do any transforms on the data required by the view.


In this way, the model doesn't have to know about the view, the view 
doesn't have to know about the model, but the controller does know about 
both.


HTH,
Jason




Thanks, Soong




___

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

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

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


This email sent to ja...@sigio.com


___

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

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

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

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


Re: microsoft file formats in cocoa

2009-05-17 Thread Jason Stephenson

Alexander Cohen wrote:
Does anyone know of any libraries that can read microsoft formats ( xls, 
ppt, doc, etc, ... )? I'd rther not reinent the wheel if something is 
already out there.


You could look at the source code for OpenOffice.org. It does a pretty 
good job of handling MS Office files. I believe most of it is built as a 
series of libraries that are then linked together.


However, be warned: the codebase of OO.o is large.

Jason
___

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

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

Help/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 delegates explicitly

2009-05-16 Thread Jason Stephenson

Eric E. Dolecki wrote:
If I understand you, make a method which you can call directly and call 
this also from your delegate selector.


I was trying to say that if you implement a class that has the following 
method:


-(void) setDelegate: (id) delegate;

You are more or less obligated to call:

[delegate delegateMethod]

somewhere in your implementation. Otherwise, the delegate never does 
anything.


However, if you generalize the question, as Bill seems to have done, 
then normally, you never call


[delegate delegateMethod]

because that is up to the class that implements -setDelegate:.








Thanks,
E.

On May 16, 2009, at 4:27 PM, Jason Stephenson  wrote:


Uli Kusterer wrote:

On 16.05.2009, at 19:28, Bill Bumgarner wrote:

On May 16, 2009, at 10:21 AM, Sourabh Sahu wrote:

Can we call delegates explicitly, Please reply soon.


Yes.  But it is a bad idea.
What exactly was the question, and why is it a bad idea? I'm unable 
to follow the conversation, it seems ... ?


I am not entirely certain either, but I know that if you're writing 
the code for the object that accepts the delegate object, you kind of 
have to call the delegate methods explicitly at the appropriate times 
or they don't get called. There's no magic sauce that makes that 
happen without you providing it.


So, I suppose the answer really depends on what the question means.

Jason
___

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

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

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

This email sent to edole...@gmail.com


___

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

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

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

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


Re: Calling delegates explicitly

2009-05-16 Thread Jason Stephenson

Uli Kusterer wrote:

On 16.05.2009, at 19:28, Bill Bumgarner wrote:

On May 16, 2009, at 10:21 AM, Sourabh Sahu wrote:

Can we call delegates explicitly, Please reply soon.


Yes.  But it is a bad idea.



 What exactly was the question, and why is it a bad idea? I'm unable to 
follow the conversation, it seems ... ?


I am not entirely certain either, but I know that if you're writing the 
code for the object that accepts the delegate object, you kind of have 
to call the delegate methods explicitly at the appropriate times or they 
don't get called. There's no magic sauce that makes that happen without 
you providing it.


So, I suppose the answer really depends on what the question means.

Jason
___

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

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

Help/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: unrecognized selector sent to instance

2009-04-15 Thread Jason Stephenson

Bill Bumgarner wrote:

On Apr 15, 2009, at 8:12 AM, BJ Homer wrote:
Seems to be concrete to me. Nevertheless, calling it on super does 
throw an

exception; you might just try calling [super init] and see what happens.


// NSOutputStream is an abstract class representing the base 
functionality of a write stream.

// Subclassers are required to implement these methods.
@interface NSOutputStream : NSStream
- (NSInteger)write:(const uint8_t *)buffer maxLength:(NSUInteger)len;
// writes the bytes from the specified buffer to the stream up to 
len bytes. Returns the number of bytes actually written.


- (BOOL)hasSpaceAvailable;
// returns YES if the stream can be written to or if it is 
impossible to tell without actually doing the write.

@end


I think I am just going to implement those methods, now. I've been 
playing with the implementation that I sent earlier with a 
NSOutputStream ivar and it looks like I would have to implement a good 
deal of extra code for delegate and propertyForKey methods.


Thanks, again, everyone.




b.bum
___

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

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

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

This email sent to ja...@sigio.com


___

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

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

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

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


Re: unrecognized selector sent to instance

2009-04-15 Thread Jason Stephenson

Thanks to Bill and BJ.

Don't I feel silly. I have a new implementation of the output stream 
class that works. (See attachement.)


Now, I have five other NSInputStream/NSOutputStream subclasses to modify 
and test.


Y'know, when I first started coding these classes the other day, I heard 
a little voice in the back of my mind telling me to include an ivar of 
the "parent" class and implement these classes that way, 'cause I knew 
it was a class cluster implemented on top of CFStream, but I didn't 
listen to that little voice. Guess, I'll need to pay more attention in 
the future. ;)


BTW, the Bzip2 compression works properly on the output stream, too. 
Guess I got lucky on that one. :)


Cheers,
Jason
// -*- Mode: ObjC; -*-
/*
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* 
* Copyright 2009 by Jason J. A. Stephenson
*
* SIGIOBzip2OutputStream.h - A NSOutputStream subclass that Bzip2
* compresses as it writes output.
*
* SIGIOBzip2OutputStream.h is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License version 3 only, as published by the Free Software
* Foundation.
*
* SIGIOBzip2OutputStream.h is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License version 3 for more details (a copy is
* avaliable at ).
*
/
#import 
#import 

@interface SIGIOBzip2OutputStream : NSOutputStream
{
bz_stream *m_strm;
uint8_t *m_buffer;
NSInteger m_bzip2Error;
NSOutputStream *out;
}

-(id) initToMemory;
-(id) initToBuffer: (uint8_t *) buffer capacity: (NSUInteger) capacity;
//-(id) initToFileAtPath: (NSString *) path append: (BOOL) shouldAppend;
-(void) open;
-(void) close;
-(BOOL) hasSpaceAvailable;
-(NSInteger) write: (const uint8_t *) buffer maxLength: (NSUInteger) length;
-(NSStreamStatus) streamStatus;
-(NSError *) streamError;
@end
/*
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* 
* Copyright 2009 by Jason J. A. Stephenson
*
* SIGIOBzip2OutputStream.m - A NSOutputStream subclass that Bzip2
* compresses its output.
*
* SIGIOBzip2OutputStream.m is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License version 3 only, as published by the Free Software
* Foundation.
*
* SIGIOBzip2OutputStream.m is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License version 3 for more details (a copy is
* avaliable at ).
*
/
#import "SIGIOBzip2OutputStream.h"
#import "SIGIOArchiveKitErrors.h"

#define SIGIO_ALLOC_CHUNK 4096

@implementation SIGIOBzip2OutputStream

-(id) initToMemory
{
self = [super init];
if (self) {
m_strm = malloc(sizeof(bz_stream));
if (m_strm != NULL) {
m_strm->next_in = NULL;
m_strm->avail_in = 0;
m_strm->next_out = NULL;
m_strm->avail_out = 0;
m_strm->bzalloc = NULL;
m_strm->bzfree = NULL;
m_strm->opaque = NULL;
}
else {
[self release];
return nil;
}
m_buffer = malloc(SIGIO_ALLOC_CHUNK);
if (m_buffer == NULL) {
[self release];
return nil;
}
m_bzip2Error = BZ_OK;
out = [[NSOutputStream alloc] initToMemory];
if (out == nil) {
[self release];
return nil;
}
}
return self;
}

-(id) initToBuffer: (uint8_t *) buffer capacity: (NSUInteger) capacity
{
self = [super init];
if (self) {
m_strm = malloc(sizeof(bz_stream));
if (m_strm != NULL) {
m_strm->next_in = NULL;
m_strm->avail_in = 0;
m_strm->next_out = NULL;
m_strm->avail_out = 0;
m_strm->bzalloc = NULL;
m_strm->bzfree = NULL;
m_strm->opaque = NULL;
}
else {
[self release];
return nil;
}
m_buffer = malloc(SIGIO_ALLOC_CHUNK);
if (m_buffer == NULL) {
[self release];
return nil;
}
m_bzip2Error = BZ_OK;
out = [[NSOutputStream alloc] initToBuffer: buffer capacity: capacity];
if (out == nil) {
[self release];
return nil;
}
}
return self;
}

-(id) initToFileAtPath: (NSString *) path append: (BOOL) shou

Re: unrecognized selector sent to instance

2009-04-15 Thread Jason Stephenson

Thanks, Bill.

I did read the documentation, and in the very documents you point out it 
says:


To create a subclass of NSOutputStream you may have to implement 
initializers for the type of stream data supported and suitably 
reimplement existing initializers. You must also provide complete 
implementations of the following methods:


And in the NSStream class reference:

NSStream is an abstract class for objects representing streams. Its 
interface is common to all Cocoa stream classes, including its concrete 
subclasses NSInputStream and NSOutputStream.


Which I take to mean that NSInputStream and NSOutputStream are concrete 
classes. They are, I suppose, part of a class cluster.


Originally, I wrote the code without overriding any methods other than 
those specified in the subclassing notes. However, I decided that it 
would be easier if I overrode some of the other methods and did 
initialization of ivars, etc. in the typical places. I made those 
changes before trying the code.


I have two ideas that may fix this:

One is to go back to the original implementation and initialize 
everything the first time that -[write:maxLength:] is called.


Two is to add a NSOutputStream ivar and initialize/write to that.

The latter is what's recommended for class clusters, correct?

Jason
___

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

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

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

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


unrecognized selector sent to instance

2009-04-15 Thread Jason Stephenson

Hello, all.

I am stumped by the error message in the subject of this email. I have 
spent several hours looking over my code, googling the list archives, 
etc. Typically, it seems that the error in question occurs at runtime 
when someone has a memory management issue in their application, and the 
message is sent to a released object.


In my case, I am getting the message on an initializer, so I'm assuming 
that there is some problem and my object is not being allocated in the 
first place, or possibly the object file is not properly linked, but I 
get no linker errors, just the unrecognized selector mesasge at runtime.


Originally, the code in question was in a framework, but when I got the 
error using the framework in a test program, I copied the relevant 
source files out of the framework and tried building a test program with 
just the necessary object files to see if the error persists, and it 
does. Thus, I think I have eliminated the linker as a source of the 
issue, but can't rule it out 100%.


Since the error occurs if I link the code from a dylib, link the .o file 
directly with the test application, or build it from the .m file in a 
single compile step, I assume there must be something wrong with my 
source code. However, I don't see it.


If I build the application with the following on the command line:

gcc -Wall -framework Foundation -lbz2 -o bztest bzOutputTest.m 
SIGIOBzip2OutputStream.m SIGIOArchiveKitErrors.m


I get no warnings or errors, and the bztest executable is created.

When I try to run the bztest executable with a filename to compress, I 
get the following error:



2009-04-15 08:53:12.823 bztest[16031:10b] *** -[SIGIOBzip2OutputStream 
initToFileAtPath:append:]: unrecognized selector sent to instance 0x106830
2009-04-15 08:53:12.825 bztest[16031:10b] *** Terminating app due to 
uncaught exception 'NSInvalidArgumentException', reason: '*** 
-[SIGIOBzip2OutputStream initToFileAtPath:append:]: unrecognized 
selector sent to instance 0x106830'

2009-04-15 08:53:12.826 bztest[16031:10b] Stack: (
2477433099,
2443857467,
2477462282,
2477455722,
2477455826,
10990,
9972,
9574
)
Trace/BPT trap

I have to admit that I am not very good with gdb, yet. However, when I 
run the application in the debugger and have it open a file, I get the 
same error. I've not been able to get anything that seems immediately 
useful out of gdb. I do get the following if I go up the call stack:


#4  0x2aee in -[SIGIOBzip2OutputStream initToFileAtPath:append:] 
(self=0x106850, _cmd=0x91afb7dc, path=0x106790, shouldAppend=0 '\000') 
at SIGIOBzip2OutputStream.m:86

86  self = [super initToFileAtPath: path append: shouldAppend];

If I po self at this point, my object looks valid, AFAICT:

(gdb) po self


So, the error that I get at runtime makes it appear that my 
SIGIOBzip2OutputStream does not respond to the 
-[initToFileAtPath:append:] selector, but it does. In the debugger, it 
looks as though SIGIOBzip2OutputStream's super class is the object that 
doesn't respond to that selector. But, it's superclass is 
NSOutputStream, and it is documented to respond to that selector and I 
get no warnings about the selector when compiling.


Just to note, I have also tried -[initToMemory] and get the same message 
about that selector.


I am attaching all of the relevant source files, and if anyone sees 
something that I've missed, I'd be most appreciative. NOTE: At this 
point, I'm not really concerned about any other bugs in my code, I just 
need to get past this error, then start look for other bugs.


Thanks,
Jason
#import 
#import "SIGIOBzip2OutputStream.h"

int main (int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSProcessInfo *procInfo = [NSProcessInfo processInfo];
NSArray *args = [procInfo arguments];
SIGIOBzip2OutputStream *bzStream;
NSInputStream *rawStream;

uint8_t buffer[4096];
NSInteger length;
int i;
for (i = 1; i < [args count]; i++) {
rawStream = [NSInputStream inputStreamWithFileAtPath: [args 
objectAtIndex: i]];
if (rawStream) {
NSString *outFilename = [[args objectAtIndex: i] 
stringByAppendingPathExtension: @"bz2"];
bzStream = [[SIGIOBzip2OutputStream alloc] initToFileAtPath: 
outFilename append: NO];
if (bzStream) {
[rawStream open];
[bzStream open];
do {
length = [rawStream read: buffer maxLength: 4096];
if (length > 0)
length = [bzStream write: (const uint8_t *) buffer 
maxLength: length];
} while (length > 0);
[rawStream close];
[bzStream close];
[bzStream release];
}
}
}

[pool drain];
return 0;
}
// -*- mode: ObjC; -*-
/*
*
* DO NOT ALTER OR 

Re: Memory allocation pattern related question

2009-03-29 Thread Jason Stephenson

Daniel Luis dos Santos wrote:

Hello,

I have a shared library and some client code. In the shared library I am 
adopting the following method signature pattern :


- (int) someMethod: (aType*)someInParam anotherParam: 
(aType**)someOutParam;


I use the return value to indicate success or failure in the execution 
of the method, and the arguments to pass parameters in and out.

The out parameters are double pointers.

Also, the pattern I am using mandates that the out parameters 
dereferenced values are allocated within the method. So :


- (int) someMethod: (aType*)someInParam anotherParam: 
(aType**)someOutParam {


*aType = [[aType alloc] init];

return 0;
}

would do some logic and allocate the return value and set it to the 
double pointer, that would be the visible on the calling scope.


My problem is that I am not really sure of the way Cocoa retains and 
releases objects.
Using a global auto release-pool, when is the out param object released 
? At the end of the scope of someMethod ? or when I explicitly release it ?
If the former, I have to retain it withing some method so that when its 
scope finishes the ref count doesn't go to zero right ?


Doing it with [[aType alloc] init] as you are in your example, the 
return type is never released unless explicitly released by the caller.






Since the idea is to continue using the return type throughout the 
enclosing method call's scope how do I implement this safely so that I 
don't end up trying to access release memory ?




A good example to follow here is what is done with the NSError **s used 
in many Cocoa methods. These are typically returned after having 
autorelease called on them, so by changing your code above to


[[aType alloc] init] autorelease]

You should be all right as long as you do not do the above inside an 
autorelease pool created in your own function.


If your caller is interested in keeping the value around longer than the 
scope of the calling method, or the current autorelease pool, then the 
caller can always explicitly -retain the returned object.


Even though you are basing the functionality on a common Cocoa idiom, it 
is a good idea to document that the method will return an autoreleased 
object in the pointer. This way, your client methods can be coded 
appropriately.



Jason


___

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

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

Help/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 Client/Server App

2009-01-07 Thread Jason Stephenson

Ammar Ibrahim wrote:
The sample you sent is deprecated. This is code from 1992 that uses old 
networking APIs. And I read a complete book about networking programming 
in C. But my goal is to do it in ObjC/Cocoa. I can't believe that 
there;s no up to date code to look at!


There is more up to date code. I put the search in Google and saw the 
first was a TCPServer example, but didn't verify it was the one I'd seen 
before.


site:developer.apple.com tcp server cocoa

That will get you more relevant results, but you should be figuring 
these searches out on your own. One of the first rules of asking for 
help online is learning to help yourself. (Please don't take that 
personally. It is a general rule for everyone.)


Cheers,
Jason




Thanks,
Ammar

On Wed, Jan 7, 2009 at 1:58 PM, Jason Stephenson <mailto:ja...@sigio.com>> wrote:


Try the following in Google:

site:developer.apple.com <http://developer.apple.com> tcp client server

The first result should be a link to the TCP Server sample application.

Your three questions are really far too general to be answered in a
mailing list. You need to find some introductory material on network
programming on UNIX and/or Mac OS X.

Ditto for threads programming.

Most of what you need could probably be found by searching the
documentation. There are guides on networking in Mac OS X with Cocoa
and Carbon.

Another possibility is to examine the rsync code. If your
application is for in-house use only, then you should have no
problem with licensing.

If this were my problem to solve, I'd probably just use rsync for
this, maybe write a gui wrapper for it using NSTask.



HtH,
Jason




___

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

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

Help/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 Client/Server App

2009-01-07 Thread Jason Stephenson

Try the following in Google:

site:developer.apple.com tcp client server

The first result should be a link to the TCP Server sample application.

Your three questions are really far too general to be answered in a 
mailing list. You need to find some introductory material on network 
programming on UNIX and/or Mac OS X.


Ditto for threads programming.

Most of what you need could probably be found by searching the 
documentation. There are guides on networking in Mac OS X with Cocoa and 
Carbon.


Another possibility is to examine the rsync code. If your application is 
for in-house use only, then you should have no problem with licensing.


If this were my problem to solve, I'd probably just use rsync for this, 
maybe write a gui wrapper for it using NSTask.




HtH,
Jason
___

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

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

Help/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: Starting Cocoa apps from the command line

2008-12-11 Thread Jason Stephenson

Shayne Wissler wrote:


I've got an application that isn't specifically for the Mac, and I
want the same standard user-experience whether they are on the Mac or
on Windows or on Linux. I want them to be able to run this program
from the command line by directly using the binary (without calling
"open"), to have it print messages to their terminal (something open
doesn't do), etc. Just like an X application would work on Linux. I
don't want for it to be required to have a .app directory with plists
or nibs or anything other than just my binary.


It may or may not be perfectly legitimate for you to want to do that, 
and I don't intend to debate that with you.


However, speaking as someone who works on/with several cross platform, 
F/OSS projects on Mac OS X, I can assure you that what you are trying to 
do is not what any of the others do. Most projects attempt to look and 
to work as much like a native application as possible, including having 
nibs, plists, app bundles, etc.


If you want your Mac OS X version to work like a X application, then 
make X a requirement for the Mac OS X version. There you will get the 
exact interface, etc., that you expect and you won't shock your users 
who may be more accustomed to Mac OS X applications.


NOTE: I say the above knowing absolutely nothing about your user base.

Jason
___

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

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

Help/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 - what happened to IB

2008-12-11 Thread Jason Stephenson

Ian H Stewart wrote:

I created a new project in xcode, I then got into IB
and created my layout - buttons,
text fields, etc. connected them all together with actions
and defined my outlets, then tried to get the details back
into xcode and found out you can no longer sync from IB to xcode,
but only the other way around.

Am I missing something?


File->Write Class Files...

As Timothy suggested, you might want to check the documentation. The 
basic workflow in Xcode/Interface Builder is the reverse of what you're 
trying to do. These days, you typically write your code in Xcode and IB 
sees the class files automatically, but the reverse is not true.


You can still work the way you want, but its just not as well supported 
as in the past.


Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Starting Cocoa apps from the command line

2008-12-10 Thread Jason Stephenson

Andrew Farmer wrote:


I'm not sure, but I can tell you that mplayer does what you're talking 
about and works fine. You may want to take a look at how they do it.


OpenOffice.org, too. It builds an app bundle, etc., using command line 
tools. It may not be a good place to start, though. It is about 1.8 GB 
of code all together.


The relevant part to the OP's question, though, would be in the 
instsetoonative module where the different installers are created.


Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Monitor Magic packet(wake on lan packet )

2008-12-08 Thread Jason Stephenson

sheen mac wrote:

In my app,I want to monitor the magic packet .
Where I will get more info about this. Could 
give some link for this?.I found a command tcpdump,

Could I use this for wol packet monitoring?.


As Andrew Farmer pointed out, you don't typically monitor for the magic 
packet, since it is used to wake your computer from sleep or to turn it 
on remotely.


The packet is sent as an UDP broadcast on the LAN and can be sent to any 
port, though port 9 seems to be commonly used among the sample WOL 
broadcaster apps available on the 'Net.


If you wanted to monitor for WOL broadcasts on your LAN, then you might 
want to monitor port 9 for incoming UDP connections and log anything 
that arrives. I'm pretty sure that tcpdump can do that, though I've 
never used it. If you're trying to debug an existing WOL application, 
then you'll want to listen on whatever port it sends to.


A WOL monitor would make for a decent first server exercise for a class 
in network programming. Bonus points to the student who can explain why 
WOL won't work over IPv6.



Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [Reposted] Document based resource strategy

2008-11-25 Thread Jason Stephenson

Gerriet M. Denkmann wrote:

What version of Xcode do you have installed? I have 3.1.1 and Safari 
just says: "No file exists at the address 
“/Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/documentation/Cocoa/Conceptual/Documents/Documents.html”." 



So: are the conceptual documents (a.k.a Companion Guides) supposed to 
exist on my machine (implying that something went wrong with my 
installation) or have they disappeared for good (leaving dangling links 
all over  the place)?


Open Xcode and choose Documentation from the Help menu. If you don't 
have the Core Library DocSet already installed, it may be that you need 
to download it. Just click the button labeled "Subscribe" or "Get" next 
to Core Library in the left-hand frame of the documentation viewer window.






Kind regards,

Gerriet.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Autorelease Question

2008-11-21 Thread Jason Stephenson

Luke Hiesterman wrote:
So thinking gets in the way of understanding and not thinking is the 
path to enlightenment?


Yes, Grasshopper. You must stop thinking about the rules. You must stop 
thinking about the code. You must stop thinking about the computer. You 
must instead *become* the rules, become the code, become the computer. 
Only then is true enlightenment achieved.


Sorry, couldn't resist




Sent from my iPhone.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Porting from Windows to Mac

2008-11-01 Thread Jason Stephenson

Rakesh Singhal wrote:

I do not know about porting Windows code (MFC based) to Mac OS. The existing
code is written in C++. As suggested that it is possible then how to do it?
Do I need to change the existing code (Windows code) very much. I have not
used Qt before this. Does Qt support the MFC?


To answer your last question, "No." Qt is a widget toolkit that serves 
the same purpose of MFC, but does so in a very different way, and unlike 
MFC is inherently cross-platform.


You will basically need to rewrite the program from scratch. There is no 
tool that will automagically turn the MFC code in the application into 
something that will work on Mac OS X or anything other than Windows.


Even a few seconds using Google would have answered your questions.

Jason



Regards

On Fri, Oct 31, 2008 at 4:01 AM, Bill Bumgarner <[EMAIL PROTECTED]> wrote:


On Oct 30, 2008, at 3:14 PM, Tommy Nordgren wrote:


   I suggest you port your app to use the Qt framework from TrollTech
(http://www.trolltech.com) It is implemented in C++, and the native layer
on Mac OS X is implemented using Carbon and Cocoa.
   You might have to implement some modules in your app differently
depending on target OS, particularly to get native look and feel.
   The most important thing with using Qt, is that you will be able to
port your app to any unix dialect that uses X windows, as well.


Qt is good stuff, but be very careful going down this path.

While Qt applications are very portable, the Macintosh Qt apps tend to
stick out like sore thumbs.

Google Earth, likely one of the most popular Qt applications around, is
certainly an awesomely powerful application.

But the UI stinks.   It looks bad, it doesn't behave like standard Mac OS X
applications, and it is generally clunky.

b.bum



___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Persistent Connection to Web Server in cocoa, emulating AJAX

2008-10-23 Thread Jason Stephenson

Jack Carbaugh wrote:

the process is as follows ...

a request/command is sent to a URL which processes the request.

The result is then sent out of a "responder" at another URL.

So what i'm wanting to do, i suppose, is to continually poll the 
"responder" URL and process it's results.


NSURLRequest should do what you want. You'll want to use NSTimer and 
periodically retrieve the request in a timed loop.


Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Persistent Connection to Web Server in cocoa, emulating AJAX

2008-10-23 Thread Jason Stephenson

Jack Carbaugh wrote:
What is the best way to emulate, with cocoa, an AJAX persistent 
connection to a web server.


There is no persistent connection to a web server. HTTP does not 
preserve state between discrete requests. This is why cookies were 
invented and session variables stored on the server.


Well-implemented AJAX applications may give the appearance of 
persistence, but they are still initiating a discrete XMLHTTPRequest any 
time they need new data from the server.




I've reviewed NSURLConnection, but am not sure if it what i need.


You might want to use WebKit and JavaScript. However, I can't make any 
useful suggestions without knowing more about what you really want to 
achieve.


Jason



Thank you!

Jack
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: @property and HeaderDoc

2008-10-22 Thread Jason Stephenson

Jerry Krinock wrote:



If anyone has written any Xcode user scripts for inserting Doxygen 
templates, to replace those useless "HeaderDoc Insert" templates, let me 
know.


You might want to look at this:

http://brianray.chipy.org/doxygen/

(Although it does not appear to be working at the moment.)

This page may also prove useful if you're looking for additional tools 
to use with Doxygen:


http://www.stack.nl/~dimitri/doxygen/helpers.html



Otherwise, if I have any further discussion on this topic I'll take it 
to the Xcode list since that's where the issues are.


That's probably a good idea. :)

Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Mutable arrays

2008-10-20 Thread Jason Stephenson

DKJ wrote:
Since mutable arrays and dictionaries expand as required when new 
objects are added, when should one use -initWithCapacity: methods?


I have used it when my program can figure out roughly how many items 
will be in the mutable object to begin with.


Say my program is pulling some data from a database table and there are 
64 rows in the table when I go to initialize a NSMutableArray to hold 
the data rows from the table. In that case, I'd use -initWithCapacity: 
to indicate that there are about to be 64 objects inserted into the array.


If my program can't know how many items will go in the object at the 
start, then I won't bother using it.


I've never checked if it speeds things up or not, but it seems like the 
time to use it when you know how much data you'll be putting in the 
object at the start.


Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa Programming for Mac OsX Third Edition eBook search

2008-10-04 Thread Jason Stephenson

Jamie Daniel wrote:


Anyone know where I can get the above book in eBook ?



If you have a Safari account (http://safari.oreilly.com/) and enough 
download tokens, you could download each chapter as a PDF. Other than 
that, I don't know how you could get a Mac-compatible copy of the book.


Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Help for a beginner..

2008-10-04 Thread Jason Stephenson

Rob Keniger wrote:

On 04/10/2008, at 9:46 AM, mmalc crawford wrote:

Start with Programming in Objective-C by Stephen Kochan (depending on 
how quickly you want to get underway, you may consider waiting for the 
second edition):


 

 




I totally agree with mmalc, this is the first book you should buy. 
Despite what others have said, I highly recommend that you do NOT start 
with Kernigan and Richie, it's simply not the best learning tool for 
getting into Mac programming. K&R is extremely dry and although it 
teaches you plain C, you don't need to know most of the stuff in that 
book to write good Objective-C.


Stephen Kochan's book teaches you everything you need to know about 
programming in Objective-C, including the bits of the C language you 
need to know and none of the bits you don't. It is also one of the most 
well-written technical books I have ever read.


Ditto.

Plus, I'd like to add that Kochan also introduces you to the basic 
programming concepts along the way. He doesn't just teach the language 
or the Objective-C idioms, but several chapters discuss things like 
basic data types and looping. So, you'll not learn just Objective-C the 
language, but you'll get a fairly decent introduction to the basics to 
be an effective programmer in any language.


Kernighan and Ritchie don't do this in their small book. They assume you 
already know the basics of programming, and they are only interested in 
introducing you to the C language. It would help to have some basic 
programming knowledge: data structures, looping, recursion, etc. 
*before* reading K&R.


I've never read it, but I imagine that the book on C by Kochan 
(http://search.barnesandnoble.com/Programming-in-C/Stephen-G-Kochan/e/9780672326660/?itm=1) 
is equally as good as his book on Objective-C.



Once you've read the Kochan book you should get Aaron Hillegass' "Cocoa 
Programming for Mac OS X", which goes beyond the Objective-C language to 
teach you the mechanics of working with the Cocoa frameworks.



Ditto, and Fritz Anderson's Xcode Unleashed is another good choice for a 
second or third book. It covers the Xcode 3 programming environment in a 
bit more detail than Hillegass's book, and has some excellent chapters 
on using libraries and private frameworks.


Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Opening an external file in a external application

2008-08-12 Thread Jason Stephenson

has wrote:
... and don't forget stuff like OpenOffice which contain 
full-blown spreadsheet engines and Excel file importers/exporters. 


I'll make a plug for OpenOffice.org here. The 3.0 release for Mac OS X 
is going to be completely Aqua native with the interface done in Cocoa. 
This work is all done.


OpenOffice.org also has a SDK that you can install. There is support for 
C++, Java, and StarBasic. The Java stuff is pretty much cross platform 
if your environment is setup properly. (There's a script to help with this.)


Anyway, I've been working with the SDK using the 3.1 code. I'll check 
with Juergen if he thinks it will be usable for the 3.0 release which is 
due in a month or two.


HtH,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: KBML Generator/Parser

2008-08-06 Thread Jason Stephenson

Apparao Mulpuri wrote:

Sorry, mentioned incorrect url for KBML. Working url for KBML is:
http://koala.ilog.fr/kbml/.


I was just about to point that out to you. I found the above also by 
googling kbml.




Any pointers on this would greatly help.


My question is, what are you trying to do with kbml? If your intention 
is to serialize Cocoa objects, you should read this first:


http://developer.apple.com/documentation/Cocoa/Conceptual/Archiving/Tasks/serializing.html

The Cocoa way to serialize objects often involves implementing a 
category that returns the object's fields as a plist (NSDictionary). You 
can then serialize this to xml using code very similar to the first 
example on the page linked above.


Retrieving the objects is a simple matter of reading the serialized xml 
into a plist, and then calling your category method to instantiate your 
object from a plist/NSDictionary. Naturally, you will have to implement 
the code to convert your object to and from a NSDictionary 
representation, but it is generally not difficult.


If your intention is to serialize Cocoa objects so that they would be 
compatible with Java objects serialized with kbml, then I'm afraid 
you're on your own. You'd need a Cocoa class hierarchy that is identical 
to the Java objects you are attempting to emulate, and that is more 
trouble than I think it would be worth.


Hope that helps,
Jason



Thanks,
- Apparao.




On Wed, Aug 6, 2008 at 11:16 AM, Apparao Mulpuri
<[EMAIL PROTECTED]> wrote:

Hi Guys,

In my Cocoa application, i am planning to use KBML
(http://www.inria.fr/koala/kbml/). KBML is pure java application, so i
need to port it into Cocoa.

I am looking for open source KBML generators/parsers to cut my
development time. Is anybody aware of such applications?

Thanks In Advance,


___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Hillegass, Third Edition, Chapter 18

2008-07-15 Thread Jason Stephenson

Tommy Nordgren wrote:

...
Don't even think about storing the NSRects in an NSArray.
NSRect is a struct -- not a class
Instead store NSBezierPath instances, or create an oval class.



If you're feeling ambitious, you'd make your own class to hold the oval 
information, such as its NSRect, NSColor, and a BOOL to indicate whether 
or not it should be drawn filled.


If you're truly ambitious, you'd include a fill pattern or fill graphic

'Course, it was my second time doing the exercise. ;)

Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: looking for some help

2008-07-11 Thread Jason Stephenson

Gary Robertson wrote:

I'm very new to programming the mac & looking for some help also

#1 I want to make the  " about my app " window larger
I cant seem to figure out where to do this


I'm fairly new myself, and can't really help you with #2, though I.S. 
gave you a good pointer in another message.


On #1, you can also make your own panel in Interface Builder and make it 
whatever size you want, put whatever text you want in it, and then wire 
the About MyApp... menu item to a routine to open that panel.


I usually do the above by making a nib in my project just for the about 
panel and sometimes add a window controller subclass called 
AboutController to handle event. (The latter is often unnecessary, but 
depends upon how complicated your about panel is.)


HtH,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Does this caution need fixed? (newb)

2008-07-03 Thread Jason Stephenson

Chris Paveglio wrote:

Thanks all for your help and insight! I believe Jason's solution will
work for me as I am changing the assignment of what "theSetting" is
each time through the loop. I have a list (array) of files that gets
copied from one place to the other, and I change the origin and the
destination each time in the loop. Also Michael I understand now what
you are saying about the assignment. Thank you for putting it in a
nice detailed explanation! :-)


Just keep in mind that you'll be leaking memory with my example if you 
use it as written. I'm assuming that you'll do something with the string 
inside the loop. After doing whatever it is you do with it, you'll need 
to release theSettings. Making a mutable copy does allocate memory for 
the copy.







___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Does this caution need fixed? (newb)

2008-07-03 Thread Jason Stephenson

Chris Paveglio wrote:

My code is like this:

NSMutableString *theSettings;
theSettings = [[NSMutableString alloc] init];

//myPrefs is an array of strings, each item is like "Library/Safari"

int i;
for (i = 0; i < 8; i++
{
theSettings = [NSHomeDirectory() stringByAppendingPathComponent:[myPrefs 
objectAtIndex:i]];

}

Thinking about it, do I need the alloc and init commands? Sometimes I am unsure 
about what needs alloc or init versus what I can just declare as a variable 
without doing that.


No, you don't. Also, unless you're going to modify settings after 
assigning it in your loop, then you should make it a NSString *.


The compiler is likely complaining because you're assigning NSString * 
to a NSMutableString *.


If you really need a mutable string then change the assignment line to this:

theSettings = [[NSHomeDirectory() 
stringByAppendingPathComponent:[myPrefs objectAtIndex:i]] mutableCopy];




HtH,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


NSFormatter/NSControl and valid object notification

2008-06-22 Thread Jason Stephenson
I am writing a Cocoa application as a GUI for a command line utility, 
and I decided to create a custom NSFormatter to ensure that the value 
entered in a NSTextField matches what the command line program expects 
for that parameter. (The format is actually rather complicated since it 
will accept domain names, dotted quads in CIDR notations, IP6 addresses, 
and address ranges that can be expressed with - and , in any of the 
quads, and a couple of extra special cases.)


So, I have the rudiments of the formatter working, but I haven't got far 
enough that scrapping it would be a heartbreak.


My AppControllerinstantiates a TargetFormatter (the name of my formatter 
object) in -awakeFromNib and then sets the instance as the formatter for 
my text field's cell. I have also made my AppController object the 
delegate for the text field, so that it handles the 
-control:didFailToFormatString:errorDescription:. When I get that 
message, I pop up an alert with the reason for the failure.


All is good so far, but now I want to make the run button's enabled 
state cue off of the validity of the content of my text field. That is I 
want the button disabled until there is valid content in the text field.


The main problem with this is that I don't want my formatter and my 
button to have to know anything about each other.


Now, I see that using the NSControl delegate, I can easily find out in 
AppController when the validation fails, but I don't see any messages 
that are sent if the validation succeeds.


I see that NSControl can ask its delegate if the object value it 
contains is valid or not, but implementing that would likely mean giving 
up on my formatter, thought the formatter really seemed like the "right 
thing" to do at the time (yesterday).


So, I guess at this point, my options are:

1. Adding a delegate to my NSFormatter that can be sent messages from 
the -getObjectValue:forString:errorDescription: method in my formatter.


2. Posting some sort of notification from the above that my 
AppController objects registers for.


3. Dropping the custom formatter and implementing the 
-control:isValidObject: method in my AppController.


Then, AppController, which knows about the button can set the button's 
state appropriately.


So, I am writing to the list to ask which path should I take and to find 
out if maybe there is some other delegate method or notification that I 
might have missed that the control or cell sends after calling 
-getObjectValue:forString:errorDescription: on the formatter.


(Actually, I believe that the latter must be possible. I can't be the 
only one who wants to control some other object's state based on the 
validity of the object in a NSFormatter subclass. However, if it is not 
possible, I won't be too surprised.)


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: NSPanel should not close on command-W

2008-06-21 Thread Jason Stephenson

Georg Seifert wrote:


I cannot reproduce this. If I close all documents in Textedit (or any 
other Mac-App) the font panel stays there and I get a NSBeep on hitting 
command-w.


According to what I read in the docs and what I've experienced in my own 
applications, panels don't respond to Command-W. They will close if you 
hit the  key.


Also, I do believe that if your panel is in the nib with your window 
controller's window (in a document-based application that would be 
MyDocument.nib), then the panel will close when the last window 
referencing the nib is closed, because the window controller is 
responsible for tearing down the top level objects loaded from the nib, 
which MyDocument : NSDocument will do, and any custom window controller 
should do by sending itself -autorelease in -windowWillClose.


So, I think, as Marco Masser has already mentioned, that if you want 
your panel to be independent of your document window's window 
controller, you'll need to put the panel in its own nib and load it 
independently.


You *might* be able to do some "magic" in your window controller's 
-windowWillClose method to give your panel a new owner. I don't know for 
sure: I haven't actually tried this.


HtH,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Static Functions and Variables

2008-06-15 Thread Jason Stephenson

Whoops! Had a brain fart.

In my previous message where I say @interface, I meant to say 
@implemenation. Sorry for any confusion.


Got too much going on today. I should have just stayed away from email.

--Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Static Functions and Variables

2008-06-15 Thread Jason Stephenson

My question is:

Does it make a difference if I put static functions and variables inside 
or outside of my Class' @interface?


I tend to treat them like C functions and variables and place them at 
the top of my source (.m) file, before the @interface declaration.


When it comes to static functions, these are generally helpers used to 
streamline code in if statements or to manipulate an object in some way. 
Generally, I use them for shorthand of repeated steps or occasionally to 
assist in the +initialize function.


The static variables, of course, are "Class" member variables more or 
less, basically used to manage class wide settings, etc.


I have seen examples where the above appear inside the @interface @end 
pair, and I've even moved some of my statics inside the @interface just 
to see if it makes any difference, and it does not appear to have any 
noticeable effect, other than in code organization.


So, after all the intro., my question is which is the more common way of 
using static variables and functions? Do you put them before the 
@interface or "inside" it?


Thanks,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


3rd Party Nonsense (was Re: Regular Expressions?)

2008-06-07 Thread Jason Stephenson

Ilan Volow wrote:

 Back in the
Jaguar-era when I had to write applications that made heavy use of XML 
and regular expressions, Cocoa-Java saved the day--no 3rd-party nonsense 
required.


This in not a knock on Ilan. His mail just happens to embody an attitude 
that I see quite frequently on this list, and I just feel that I have to 
share my puzzlement at this negative attitude toward 3rd party frameworks.


It seems that many on this list feel that Apple should provide 
everything that the programmer needs to work on Mac OS X and that there 
should not be 3rd party frameworks for much of anything.


This attitude really, truly puzzles me because on every other platform 
where I've programmed this attitude never came up in the discussion 
forums. It was always just assumed that you would need to use 3rd party 
frameworks to get any real work done, unless you intended to roll 
everything yourself.


If you look at programming for Linux or any of the BSDs, you will 
definitely need to install frameworks from 3rd parties to do any GUI 
programming at all, or really any programming. After all, gcc is not 
produced by any of the major distributors or developers of Linux or BSD. 
Heck, even on the Mac, most of the programming frameworks are based on 
3rd party frameworks underneath.


The same is true for Perl where many applications have a list of 3rd 
party module dependencies that make Amy Winehouse look clean and sober. ;)


The only other environment where I've programmed that this same attitude 
may rear its head could be Java land, but even there that attitude does 
not seem to rear its head quite so often as it seems to on this list.


As someone who has worked on a number of 3rd party [open source and 
otherwise] frameworks, I wonder where this attitude comes from in the 
case of Cocoa/Mac OS X. I have some ideas, but I hesitate to share them.


Puzzled,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson

glenn andreas wrote:

[wrote about how using regex is not a good idea, particularly with 
NSString and unicode. Pretty much the same things that Jens wrote earlier.]


Yes, that's all very true. Regex is a poor choice if you're working on 
non-ASCII text. I'm generally not doing so, but just yesterday did have 
the unpleasant experience of regexing some UTF16 files. (See another 
email by me in this thread.)


You could kludge it to work using some options that are available on Mac 
OS X and FreeBSD regex libraries. (Don't know if it is available 
elsewhere, but likely is.) Essentially, you tell regcomp to ignore nuls 
and then you have a lot of fun coding REs that match your UTF16 strings 
taking into account endianness and all. I've pondered how it would work 
and am confident that it would work, but also concede that it would be a 
very ugly hack and be prone to breakage.


One other possible solution is to use the JavaScriptCore and make a 
JSStringRef (which works with unichars like NSString), and use 
JavaScript's regex support - that way the results will at least have 
consistent indices, work well with non-ASCII characters, etc...


That is an excellent option if you're using JavaScriptCore already, or 
maybe even if you're not. There's another thing to look into. Anyone for 
a unicode text editor that is scriptable in JavaScript? (Hmm, maybe the 
world really doesn't need another text editor.) :P


For now, I'm going to look into ICU. I seem to have a couple of copies 
of it on my computer.


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson
Replying to myself here, which I know is generally a bad thing, but this 
thought just came to me.


I have yet to find a regex library that handles UTF-16 well, if at all. 
I actually spent a couple of hours yesterday trying to mangle some 
UTF-16 files in Perl using regular expressions. I gave up and did it in 
Emacs, the only environment where I've seen REs handle UTF16 properly.


So, that's now my mission, to come up with a RE library that handles 
UTF16 as gracefully as 7 bit ASCII.


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson

dream cat7 wrote:


I agree that to be able to use that syntax is highly desirable, and 
indeed missing from all the cocoa libraries that I have looked at. One 
way would be a category addition to NSString class, which would call 
the  perl -pe 's/\b(.*?)/\u\L$1/g' for you and return the result as an 
NSString...


But unfortunately nobody has come up that type of an extension to 
NSString yet.

Or are there and c-libraries that will accept this s syntax ?


Would something like this be acceptable?

[someString replacePattern: @"\\b(.*?)" with: @"\\u\\L$1" flags: @"g"];

It is pretty much how I have considered handling substitions in the 
category that I'm designing.


As for string subs in C libraries, I really am only familiar with using 
the POSIX standard regex library. You can do that sort of thing in it, 
but it is not as simple as writing a single line of code.


I have some limited experience with PCRE, and IIRC the coding is more 
less the same there.


I don't know of any regex library that will accept s in a string. 
That's a bit of syntactic sugar that makes Perl so sweet. ;)


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Regular Expressions?

2008-06-06 Thread Jason Stephenson

Hi,

You've gotten a lot of decent answers so far.

As a long time UNIX programmer, I'll suggest looking into the regexp 
library that already comes with OS X.


man regcomp on the command line to find out how to use.

I've used it for years in my C applications on UNIX and UNIX-like 
operating systems. I've even made some simple classes for using the lib 
in Cocoa. Admittedly the interface is a bit schizoid, but I'll email it 
to you if you're interested in looking at it.


I've looked at RegexKit and it looks good if you want Perl compatible 
regular expressions. The license isn't bad, so you can add it to your 
application without doing much, though giving a plug to the author(s) in 
your About panel would be nice. ;)


I'll have to add making a nice interface for the system regex library to 
my list of things to do. Maybe I'll get to that this weekend right after 
doing bas64, UUcode, binHex, etc. ;)


Cheers,
Jason

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Xcode - IB problems

2008-06-01 Thread Jason Stephenson

Hamish Allan wrote:

On Sun, Jun 1, 2008 at 8:56 PM, Ashley Perrien <[EMAIL PROTECTED]> wrote:


Should I create all the actions and outlets in IB and let it create the
class?


No. I'm not even sure that's possible in the latest version of IB.
What version are you using?


It is still possible, but not necessary in Xcode 3.0+.

Usually, when I have the trouble described by the OP, I have some typos 
in my .h files for the classes.





Hamish
___

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

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

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

This email sent to [EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: odd problem with NSMutableDictionary and initWithContentsOfFile

2008-05-29 Thread Jason Stephenson

Leslie Smith wrote:

Hi:

I found out what I was doing wrong:  rather than

[SimParamnames initWithContentsOfFile: aFile];

I should have had

SimParamnames = [SimParamnames initWithContentsOfFile: aFile];



A more "normal" way of doing the above is

NSMutableDictionary *SimParamnames;
SimParamanames = [[NSMutableDictionary alloc] initWithContentsOfFile: 
aFile];


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: File's Owner

2008-05-23 Thread Jason Stephenson

Hi,

I think you might be making this harder than it needs to be because you 
are expecting the File's Owner of application's main nib file (usually 
MainMenu.nib) to require a lot of wiring up. Generally, it doesn't.


File's Owner is used to link object from one nib to another. Since your 
main nib is loaded at application start, and is generally not receiving 
messages from objects in other nibs, its File's Owner does not normally 
need to do much.


File's Owner becomes important when you have more than 1 nib. You will 
generally give it connections to the objects in its own nib that need to 
be controlled from outside. It should also have the signatures of any 
delegate methods, etc. that are needed for the nib objects to receive 
their messages from the outside objects.


Now, when you need the objects in your second nib, you will load the nib 
and pass in as the owner: an already instantiated object. This object 
will need to have all of the same types of outlets as the second nib's 
File's Owner, and it should implement whatever methods the File's Owner 
has listed.


However, this object will not actually be wired up to the File's Owner 
object in IB. It will become the File's Owner and be wired up 
programatically when the nib is loaded with this instance object as the 
owner. It will take over the role of File's Owner and be assigned all of 
the connections of the File's Owner for the loaded nib.


You should view the File's Owner object in IB as a place holder or a 
template. If you consider it a template, then it describes what the 
class that will take its place at run should do.


I hope the above explanation is helpful. It is my understanding of the 
how/why of File's Owner. It may be slightly off conceptually, but 
practically this understanding has served me well.


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: A directory site for open-source Cocoa components?

2008-05-22 Thread Jason Stephenson

Jens Alfke wrote:


Anyone interested? (Or know of an existing site that I've overlooked?)


I don't guess we could convince Apple to open up Mac OS Forge?

In addition to the other sites listed, Source Forge 
http://www.sourceforge.net/ has some Mac OS X related projects on it.


I would certainly be willing to help out with or contribute to such a 
venture. I'm working on some things now that I plan to put up on my own 
site over the summer, or at Source Forge, but it would be nice to have a 
Mac OS X/Cocoa only site that pulls together a lot of good stuff.


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


+initialize (was Re: Trying to understand -- please help...)

2008-05-21 Thread Jason Stephenson

Vijay Malhan wrote:

What exactly do you mean by initializing the *class*? what exactly 
is initialized with +initialize() method?

When exactly this method gets called?


If you are at all familiar with Java, this is the same thing as a static 
initializer.


It sets up data required by the class and all of its instances. It is 
called as soon as the class exists and before the first instance is init'd.


It is often used to setup class-wide variables. As an example, I have a 
Monte Carlo simulator class called Die. I can initialize any number of 
Die objects, and I can set the number of "sides" of these Die objects 
(dice) to any arbitrary number. In my implementation, I use the standard 
library rand() function to generate pseudo-random numbers. I also 
decided that all Die objects would share the same seed value. Therefore, 
I made the seed a static variable with file scope in the Die.m file, 
thus limiting its visibility to my Die class. I use the following class 
initializer function to put a value in the seed class variable:


+(void) initialize
{
static BOOL initialized = NO;
if (NO == initialized) {
time((time_t *)&seed);
initialized = YES;
}

}

Thus, the +initialize method is used to setup one-time things that you 
need to happen for the class as a whole and not for individual instances 
of the class.


HtH,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: [OT] generating API docs

2008-05-19 Thread Jason Stephenson

I was going to suggest Doxygen, also, but Uli beat me to it.

I will add this link, which explains how to create docsets with Doxygen:

http://developer.apple.com/tools/creatingdocsetswithdoxygen.html

Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-19 Thread Jason Stephenson

Regarding the arrangement of the docs:

I find it much easier to read the guides, and oftentimes also the 
reference documentation, from a web browser rather than in Xcode's 
documentation window. If I'm using Xcode, I will usually have the doc 
window open. However, I'll very often have the guide(s) for the 
particular subject(s) that I'm studying open in various tabs in my 
browser as well.


If you have installed Xcode or the Documentation in the usual places, 
then the following two URLs will get you to the main documentation 
starting pages:


Core Reference
file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.CoreReference.docset/Contents/Resources/Documents/referencelibrary/index.html

Tools Reference
file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/referencelibrary/index.html

If you don't get much joy from Xcode's viewer, then I'd suggest trying a 
web browser instead. Also, you can always download the PDFs and print 
them if you prefer something on paper.


For What It's Worth,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-18 Thread Jason Stephenson

Johnny Lundy wrote:

Tutorials to me are pretty much useless, as I am not looking for a "step 
by step" cookbook to just getting something working, but rather a 
discussion of the why. How many times have we seen a tutorial say 
something like "control-drag from the textfield to the File's Owner 
object?" (just a random example). OK, I can do that, but it is a waste 
of my time - it's like paint-by-number when trying to learn art. Take 
the "Currency Converter With Bindings" much-touted tutorial; it actually 
uses a method that is deprecated.


It's my eagerness to explore and understand all of this rich collection 
of functions that frustrates me when the documentation doesn't go into 
enough depth.


Have you read the Cocoa Fundamentals Guide?

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/chapter_1_section_1.html

Much of what you seek is explained therein. If the Guide makes no sense 
to you, I'd suggest picking up some basic books on OO programming and 
design patterns. Read them, then come back to the Cocoa Fundamentals Guide.


Cheers,
Jason

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa et al as HCI usability problem

2008-05-18 Thread Jason Stephenson

Julius,

You could change Apple for just about any other vendor, and Cocoa for 
just about another GUI/system interface, and your argument will still hold.


(Have you ever tried programming X11 with just XLib C calls? Nasty stuff 
that)


Also, please don't confuse the language, Objective-C in this case, with 
the frameworks/system interface. Objective-C is a very small language, 
and it is easy to keep the main things in mind. PL/1 is another matter 
altogether (So is C++ if you think about it.)


Cocoa is much larger, but the same could be said of  C and XLib 
respectively. Not to mention that on X you have many different GUI 
toolkits to choose from to abstract away the complexity of XLib: Xt, Qt, 
Tk, XAW, Motif, GNUStep, Gnome, KDE, etc., etc.


Modern computer systems are complex. There are many, many options of the 
programmer. If modern computer systems lacked this complexity, and if 
the published interfaces did not have APIs available so that programmers 
could make adequate use of this complexity, then we'd be stuck where we 
were in the early '80s, having to roll our own library for everything.


I don't think you can expect to lose the learning curve in any 
programming interface. APIs expose complexity, and at the same time, 
cover it up. Imagine if you had to implement your own 
Model-View-Controller paradigm for your GUI widgets before you could 
start making your own applications? That is the situation that you'd be 
in with something like XLib, or even the old Macintosh Toolbox. Today, 
that complexity is abstracted away rather neatly by the Cocoa framework, 
just as it would be on X if you used Motif or Qt or some other toolkit.


If you do want to just jump in and start writing code, then perhaps you 
should look into Python or some other "scripting" language. They do an 
even better job of hiding the complexity.


I also don't find any great difficulty in using Apple's documentation. 
The conceptual documents cover the concepts, and the reference 
documentation serves as a reference. No, I don't think you should learn 
to use Cocoa just from the conceptual documents, but I'm sure it is 
possible.


The simple fact of the matter is that documentation, just like a GUI, 
cannot be all things to all people. Programmers and those interested in 
programming are a particularly eclectic bunch. We each come at Cocoa for 
the first time with different experience, different reference points, 
and different expectations. One set of documentation cannot be expected 
to handle all of the possible permutations of programmer knowledge and 
experience. For this reason, other books exist written by third parties 
to cover those gaps or target different audiences.


In summary, I think it is a problem of all programming documentation and 
programming interface regardless of the platform or language, and I 
don't really see a way for a single vendor to resolve the issue, not do 
I think they really should.


Well, I'll shut up, now.

Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Learning Curve/Documentation Challenge/Recommendation

2008-05-17 Thread Jason Stephenson
I came at Cocoa and Objective-C after years of programming experience 
with C, C++, Java, Perl, etc., etc. (My resume, for the curious: 
http://www.sigio.com/~jason/resume.html .)


I found two books to be very helpful at getting me up to speed on 
Objective-C and Cocoa. These books respectively are Steve Kochan's 
Programming in Objective-C and Aaron Hillegass's Cocoa Programming for 
Mac OS X. I read them in that order.


(I think it goes without saying that you should also do the tutorials in 
the books, and don't just copy and paste the examples. Play with them. 
See what changing parameters does. See if you can add little features to 
the sample programs.)


Yes, Kochan's book does contain some introductory material on 
programming and OO in general, and several chapters on the C roots of 
Objective-C. Those sections, however, are very easily skipped without 
missing anything in learning Objective-C.


The Hillegass book is a good introduction to Cocoa application 
programming. It will get you started with the basic paradigms and 
conventions of Cocoa. It will be helpful to have some prior programming 
knowledge and knowledge of Objective-C to begin with, even though this 
book contains a very basic introduction to Objective-C.


It is important to remember that Objective-C and Cocoa are two different 
topics. It is hard to learn the latter without already having some 
proficiency in the former. Objective-C is a programming language, and 
Cocoa is a framework, or rather a series of related frameworks. I found 
learning both to go very quickly given my experience. However, I studied 
Objective-C first and then Cocoa.


That said, I don't think a programmer's education is ever finished. To 
steal a line from the Beatles, "the more I learn, the less I know." That 
is, I realize just how much more there is to learn.


So, I'd recommend anyone looking to learn Cocoa, who already has 
programming experience in other languages/paradigms get the two books 
listed above. I found them most helpful.


Cheers,
Jason Stephenson
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to send email without using email client

2008-05-09 Thread Jason Stephenson
Jens' description of the intent of the LGPL is pretty much the same as 
my understanding.


However, another option exists. You can always contact the "author" of 
the LGPL or GPL code and request a license agreement that allows you to 
use their code in a closed product. Some are quite amenable to this sort 
of arrangement and don't usually ask for a lot of money.


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Resource Fork - is this a good use/the right thing to do?

2008-04-23 Thread Jason Stephenson

Chris Suter wrote:



Furthermore, it doesn't follow the file which was the original design goal.

Going back to the original question, I personally think that the best 
thing to do is to just create another file and educate the user. 
Extended attributes and resource forks are all very nice but most users 
don't understand what they are and they just don't interoperate nicely 
with other systems.


My first thought on reading this thread is that it would be easiest just 
to store the data in a zip-type archive file. You could then have all 
the metadata/resource files included in an archive subdirectory, and 
everything would transfer nicely across operating systems. 
OpenOffice.org does this. All of the components of a document are stored 
in a zipped archive that just happens to have the .odt or .od-whatever 
extension.


Using an archive file format solves the issue of user education, since 
it appears to be a single file to the user, gives the programmer the 
option of including whatever arbitrary resources are needed for this 
particular file, and also solves the issue of operating system 
portability, since just about any OS in current use can handle copying a 
binary file around.


Just my 2d

Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Returning a value from a function

2008-04-08 Thread Jason Stephenson

I. Savant wrote:
  No, it's precisely accurate. While the meaning is clear in this case, 
failure to use proper terminology on a technical mailing list can cause 
confusion resulting in more noise and wasted time. A method is a method. 
A function is a function.


A method is simply a subclass of function, it being a functional member 
of an object. While I agree that saying method in this case is more 
precise than function, using the term function is still accurate.


Also, the answer to the OP's question had nothing to do with the 
function being a member of an object. The answer and question apply to 
the larger set of functions of which method is a member.



Drawing distinctions in cases where they are not needed is also a waste 
of time. As three of us have now wasted our time on this semantic 
discussion. ;)


Cheers,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa Database Connection

2008-03-21 Thread Jason Stephenson

Justin Giboney wrote:
So, libpq sounds like a well supported way to go, but when I import 
"libpq-fe.h" into my project I get an error that says "postgres_ext.h: 
No such file or directory", along with 30 more errors which I assume are 
related to the lack of this file. I searched my computer for it and I 
can't find it.



How did you install PostgresQL on your system? I've install mysql-client 
via Mac Ports and have no trouble connecting to MySQL servers via C or 
Objective-C with the proper compiler options.


Chances are, you simply need to specify the right paths with -I and -L 
to tell gcc and ld where to find the PostgresQL headers and libraries.






Is there something that I should have installed besides PostgreSQL 
8.3.0? I have seen something about doxygen, but I don't know what that 
is. Do I need it?




doxygen is a documentation generator. It generates document files from 
specially formatted comments in your code, similar to Autodoc, 
Autoheader, and Javadoc. You don't need it to build PostgreSQL apps.


BTW, thanks for mentioning the PostgresQL Cocoa project on Source Forge. 
I was thinking of starting something similar on my own, since about all 
the programming I do is for databases.


HtH,
Jason
___

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

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

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

This email sent to [EMAIL PROTECTED]