how do you set the value of a UIPickerView programatically? [solved]

2010-01-12 Thread Paul Archibald
First, sorry about my last post with the RE:Contents of ... title.  
My bad.


Anyhow, I figured out what was wrong. Seems you need to call  
[self.view addSubview:picker] to hook up the picker to the view  
controller. I am doing that in my viewDidLoad method.


Regards,
Paul


___

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

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

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

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


Re: how do you set the value of a UIPickerView programatically? [solved]

2010-01-12 Thread Paul Archibald
Ahh, now I see it, you are correct. I had been alloc/init'ing some  
other UI elements that were not created in IB, and this got that  
treatment, too, so the picker was double-allocated. I need to more  
careful copy/pasting my own code.



On Jan 12, 2010, at 12:53 PM, David Duncan wrote:


On Jan 12, 2010, at 12:26 PM, Paul Archibald wrote:

Anyhow, I figured out what was wrong. Seems you need to call  
[self.view addSubview:picker] to hook up the picker to the view  
controller. I am doing that in my viewDidLoad method.



If the picker is already a subview of the view controller's view in  
the XIB, then this should not be necessary.

--
David Duncan
Apple DTS Animation and Printing




___

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

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

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

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


how do you set the value of a UIPickerView programatically?

2010-01-11 Thread Paul Archibald
I have a couple of pickers in my app, and when they are displayed I  
want them to show their current values. I have tried:


-(IBAction) setThePicker:(id) sender {
[picker selectRow:3 inComponent:0 animated:YES];
}

(hooked to a button, as a test) as well as just calling

[picker selectRow:indexOfCurrentValue inComponent:0 animated:YES];

from within my viewDidLoad method, but the picker does not change. I  
am pretty sure my XIB is set up right and connected to the code.


I have found some sample code that seems like it should work, but it  
doesn't. Anyone know how to make this work?


___

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

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

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

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


Re: Cocoa-dev Digest, Vol 7, Issue 52

2010-01-11 Thread Paul Archibald


On Jan 11, 2010, at 4:19 PM, cocoa-dev-requ...@lists.apple.com wrote:


What does NSLog(@%@, picker); print out?



UIPickerView: 0x138cee0; frame = (0 0; 320 216); layer = CALayer:  
0x138cf30


Does that tell you anything? It looks okay to me. At least its not  
deadbeef or nil, and the frame makes sense.

___

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

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

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

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


SQLite mime type?

2009-12-29 Thread Paul Archibald
I am using SQLite in my iPhone app. and i want to be able to email the  
database file. I see that attaching it to a message is pretty  
straightforward, but the addAttachmentData method requires a mime  
type, and I  don't know what that should be. Any ideas out there?

___

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

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

Help/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: SQLite mime type?

2009-12-29 Thread Paul Archibald

Cool, thanks, I'll try that.
On Dec 29, 2009, at 11:10 AM, davel...@mac.com wrote:



On Dec 29, 2009, at 11:56 AM, Paul Archibald wrote:

I am using SQLite in my iPhone app. and i want to be able to email  
the database file. I see that attaching it to a message is pretty  
straightforward, but the addAttachmentData method requires a mime  
type, and I  don't know what that should be. Any ideas out there?



I don't know if this is the correct one, but application/octet- 
stream seems to work fine for me in my Attendance app.


Dave



___

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

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

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

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


testing email code in the simulator (MFMailComposeViewControllerDelegate)

2009-12-29 Thread Paul Archibald
Is there a way to test the emailing code in my app from within the  
simulator? I don't have an iPhone. It looks like my code is working,  
but I would really like to see whether the message is actually being  
constructed and sent correctly. I realize that on an iPhone it would  
be handed over to the Mail app for sending at a future time, but the  
sim does not have Mail on it either (is it possible to install Mail  
onto the simulator?)

___

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

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

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

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


[iPhone] Is there no return or dismiss key if my UITextField.keyboardType = UIKeyboardTypeNumberPad

2009-12-09 Thread Paul Archibald
It seems as though the UITextField/View classes do not allow a return  
or done key when keyboardType is a UIKeyboardTypeNumberPad. Am I  
missing something, or is this a deliberate design?


This seems odd to me and kind of a drag since I have several text and  
numeric controls in my view and I would like them to act pretty much  
the same way. Having the one numeric keypad need an extra button in  
the toolbar seems kind of kludgy. Is that the only solution?

___

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

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

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

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


[iPhone] weird crash (aren't they all?): ivar seems to be dynamically changing its type

2009-11-20 Thread Paul Archibald

Comrades,

I have a bunch of UITableViewControllers in my app, each of which is  
responsible for some aspect of the data in my sqlite database. Now,  
maybe I should have done it differently, but I am passing a  
backpointer from each parent vc to its child vc, where the child  
vc is going to allow updating the database in an appropriate manner  
and inform its parent vc of the change so that the data can be  
reloaded. I explicitly set the backpointer like this:


- (void) addProject {
NSLog(@ProjectsViewController:addProject button pressed);
// create a project editor view with text fields in it
	ProjectEditorViewController *projEd = [[ProjectEditorViewController  
alloc] initWithNibName: @ProjectEditorView bundle: nil];

[projEd setParentViewController:self];  // setting my backpointer
[self.navigationController pushViewController:projEd animated:YES];
}

and the ProjectEditorViewController has this implementation:

-(void) setParentViewController:(ProjectsViewController*)  
viewController {

parentVC = viewController;
}

And later I can use that pointer to update the database and request a  
reloadData.


Seems simple enough, eh? (Maybe in a future post I will ask how I  
could have handled data synchronization better, but it seems like a  
long story just now.)




But I end up in setParentViewController TWICE during the addProject  
method, and the second time through the type of the argument is wrong.  
The first time its a ProjectEditorViewController (correct), but the  
second time its a UINavigationController (WTF?). This causes a crash  
later when I try to send a updateDatabase/reloadData message to the  
parentVC and the parentVC is the wrong type!





Tracing through addProject in the debugger, where I set my  
backpointer, and where I think all my trouble begins:


- (void) addProject {
NSLog(@ProjectsViewController:addProject button pressed);
// create a project editor view with text fields in it
	ProjectEditorViewController *projEd = [[ProjectEditorViewController  
alloc] initWithNibName: @ProjectEditorView bundle: nil];

bp  [projEd setParentViewController:self];  // setting my backpointer

step
 at this point, the first time I step into addProject the  
callstack looks like this:
#0	0x7f47 in -[ProjectEditorViewController  
setParentViewController:] at ProjectEditorViewController.m:33
#1	0x3d2b in -[ProjectsViewController addProject] at  
ProjectsViewController.m:74



step
[self.navigationController pushViewController:projEd animated:YES];
 but as I try to step over this, I end up back in  
setParentViewController with the parameter having changed to  
UINavigationController

 and the stack looking like this:
#0	0x7f32 in -[ProjectEditorViewController  
setParentViewController:] at ProjectEditorViewController.m:32
#1	0x01708577 in -[UINavigationController  
pushViewController:transition:forceImmediate:]

#2  0x017031bb in -[UINavigationController pushViewController:animated:]
#3	0x3d75 in -[ProjectsViewController addProject] at  
ProjectsViewController.m:76



So, why does setParentViewController get called twice, and why is the  
parameter type different the second time, and why don't I get an  
exception  when the wrong type is gets passed into  
setParentViewController that second time?



___

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

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

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

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


Re: [iPhone] weird crash (aren't they all?): ivar seems to be dynamically changing its type

2009-11-20 Thread Paul Archibald

Son of a gun, I think you got it.

I was wondering about whether properties were somehow involved, but I  
had not declared any like that in my classes, and didn't think of the  
inherited ones. Good call.


Oh, I guess I will have to actually fix the code now, but I am willing  
to bet this is the answer.


Thanks,
Paul


On Nov 20, 2009, at 5:23 PM, Michael Babin wrote:



On Nov 20, 2009, at 5:55 PM, Paul Archibald wrote:

So, why does setParentViewController get called twice, and why is  
the parameter type different the second time, and why don't I get  
an exception  when the wrong type is gets passed into  
setParentViewController that second time?


Probably because UIViewController already has a property named  
parentViewController. Your set method is probably overriding the one  
defined in UIViewController, and thus getting called by  
UINavigationController when you tell it to push your view controller  
onto its stack.





___

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

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

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

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


[iPhone] Core Data Application with multiple TableViewControllers

2009-09-29 Thread Paul Archibald

Hey,

I am working on an iPhone app to manage project files which consist of  
names, equipment, and tasks. I want to use Core Data with SQLite as  
the backing store.


Our prototype has a bunch of tableview pages that allow the user to  
create, edit and delete projects and project elements.I have 6  
different tableview controllers, each of which handles a different  
part of the project records.


Modeling my app on the Locations tutorial app, I am thinking that my  
app delegate itself should own the managed object model/context and  
persistent store coordinator, as well as the working object array used  
to populate the various tableviews. This would be slightly different  
from Locations, which has its working array owned by its single  
tableview controller.


It seems to me the data should be globally accessible from any one of  
my tableviews, so each tableview could work on the part of the data it  
is designed for, but I am unsure how to accomplish that. Is it as  
simple as passing the appropriate pointer(s) to each tableview as it  
is loaded, and operating on the project data via that pointer? If so,  
should it just be the pointer to the working array, or the managed  
object context, or both?


If there is a better way to accomplish this, I would be grateful for  
any advice, and especially of any pointers to tutorials or sample code  
that might be helpful. This is my first iPhone app, and my first shot  
at Core Data, so I have a lot to learn.


Thanks,
Paul 
___


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

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

Help/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: [OT] Anyone have the a DIRECT phone number for a real person at Apple Legal???

2009-05-20 Thread Paul Archibald
Hey, I just noticed that there is a goviphone list you can subscribe  
to. Maybe you could find out something useful there. I was looking to  
see if there was a new, dedicated iPhone/iPod/Touch list,


Paul Archibald


---
The competent programmer is fully aware
of the strictly limited size of his own skull;
therefore he approaches the programming task in full humility,
and among other things he avoids clever tricks like the plague.

Edsger W. Dijkstra, (Dutch computing scientist)




___

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

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

Help/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: Porting from Windows to Mac

2008-10-30 Thread Paul Archibald

Amen.

Codewarrior is dead, long live Xcode. (I still mourn CodeWarrior, but  
what's past is past.)


I did some work with MFC a couple of years ago, and thought it was  
pretty nice (not elegant, but productive). Now, I am trying to port  
my Cocoa app to Windows, and for various reasons decided to go with  
MFC again. I cannot believe how much of a pain it is. I just learned  
some Cocoa/ObjC for my last project, and it was easier to learn Cocoa/ 
ObjC than to get this thing going in MFC/C++.


Get the Objective-C 2.0 Programming Language pdf from Apple, and  
have it printed out at Kinkos, and BUY A COPY OF Cocoa Programming  
for Mac OS X, Third Edition by Aaron Hillegass. While there is a  
learning curve for Cocoa/ObjC, once you get going you will look back  
at MFC with disdain.


Refactor the MFC project FIRST. Seperate the UI from the logic as  
much as possible. It should help you understand the MFC code better,  
and you might even be able to stick some of it in a dynamic library  
for reuse.


On Oct 30, 2008, at 11:21 AM, [EMAIL PROTECTED] wrote:

***DO NOT*** expect that it's merely a matter of finding the  
corresponding
Mac API call for each Windows API call--the differences run deeper  
than
that. In order to be successful, you ***WILL*** have to learn to  
be a Mac

developer, period, no shortcuts.


Don't let that scare you.  It's easier than you think.  And in the  
end, you'll go back to Win32 grumbling about how much extra work  
you have to do there. ;)


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


detecting an option-click on a button

2008-10-30 Thread Paul Archibald
Is there a simple way to detect that the option key was down when a  
button was clicked? I have a method in my controller that gets the  
button click, of course, and I have been trying this:


-(IBAction) handleButton:(id)sender {

if( [[NSApp currentEvent] modifierFlags]  NSAlternateKeyMask ) {
// handle option + click
}
else {
// do normal stuff
}
}

but of course the currentEvent is not necessarily related to the  
sender. In fact, I realize there is no reason to think that there  
should be any information about the keyboard status in the sender  
parameter.





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Getting available free disk space on disk image

2008-10-28 Thread Paul Archibald

This is pretty obscure, I think.

My app makes files which can be quite large. It also allows the user  
to distribute copies of those files to various locations. So, to test  
this I have tried creating and mounting a disk image which I tried  
making a copy to.


The problem is that it seems I cannot check the actual available  
space on that mounted disk image. What I get instead is the available  
space on the disk where the image lives.


I am using [[myFileManager  
fileSystemAttributesAtPath:mountedDiskImagePath]

objectForKey:NSFileSystemFreeSize];

Does anyone know if it is possible to get the free space on a mounted  
disk image?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


when should my NSWindowController be released?

2008-09-12 Thread Paul Archibald

Hey folks,

The app I am working on has 2 windows. My project has been to  
implement the 2nd window. I added a new nib file and a new class,  
MyController:NSWindowController. In the MainController:NSObject  
implementation, there is a MyController object, which can be shown or  
hidden by the user.


My question is about creating and destroying my controller. I have - 
initMyController and -windowDidLoad methods, which handle setting up  
my controller, but for some reason my -dealloc method is never  
called, even when the main app quits. In fact, the -dealloc method in  
the main controller is never called either. (I did not work on the  
main controller code.)


So, what is the general outline of properly allocating, initializing  
and deallocating an application and its elements? Can someone point  
me to the right documentation? I can't seem to find reference to this  
subject.


I thought -dealloc was called automagically on objects that are  
properly handled (ie: not leaking). I have been assuming the main app  
was behaving correctly, as I have not seen any warnings while  
debugging or even running some tools on it.


Paul
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Can I get a FILE* from Cocoa (NSFileHandle )?

2008-09-04 Thread Paul Archibald
I have gotten some suggestions on a problem which require access to  
standard C calls. In particular, one poster suggested that I use some  
calls which require a FILE*, when all I have at this point are  
NSTask, NSPipe, and NSFileHandle objects.


Is it possible to get a FILE* from an NSPipe or NSFileHandle? I don't  
see anything in the documentation that looks like that. (I am not  
getting much help from Google either.)

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Can I get a FILE* from Cocoa (NSFileHandle )?

2008-09-04 Thread Paul Archibald
Naturally as soon as I posted my query I noticed that there was a  
method I had not paid any attention to, and, of course, that is the  
one Jean-Daniel and Robert already knew about, and have been kind  
enough to point out to me. Thanks guys, I will be testing this out next.


Regards,
Paul


On Sep 4, 2008, at 10:18 AM, Jean-Daniel Dupas wrote:



Le 4 sept. 08 à 19:09, Paul Archibald a écrit :

I have gotten some suggestions on a problem which require access  
to standard C calls. In particular, one poster suggested that I  
use some calls which require a FILE*, when all I have at this  
point are NSTask, NSPipe, and NSFileHandle objects.


Is it possible to get a FILE* from an NSPipe or NSFileHandle? I  
don't see anything in the documentation that looks like that. (I  
am not getting much help from Google either.)


fdopen[[fileHandle fileDescriptor], ...)

See man fdopen for details.

Get a fileDescriptor from your NSFileHandle object, then fdopen it  
to get a FILE*.





___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: process monitoring panic

2008-09-03 Thread Paul Archibald
I do not have the source code to the subprocess, so I think I will  
need to find another solution. I can't call setvbuf from my code, can I?


I am using the TaskWrapper class from the Moriarity sample for my  
task handling. It is pretty old, maybe it is not compatible with  
Leopard or Xcode 3?


As an experiment, I tried calling ttyname in my code, but it returns  
null in both the Xcode and Finder launched cases.


I am moving this line of questioning over to the Xcode list, since it  
seems more Xcode related than Cocoa related.


On Sep 2, 2008, at 11:05 PM, [EMAIL PROTECTED] wrote:




Anyone have any ideas what to look at here? I am using an NSTask
wrapper class (TaskWrapper) I adapted from the Moriarity sample to
do the sublaunch and monitoring stuff. ( I have a fix for it under
Leopard which I will report on later, just to try to put something
back into the pot.)


It sounds like your subprocess is buffering its output.  See the
setvbuf man page.  Until the subprocess writes enough to fill its
buffer, it won't put anything on the pipe.  When the process shuts
down, it flushes all of its buffers.

Xcode may have convinced the subprocess that its output is to a tty,
which is line buffered rather than block buffered.  I'm not sure why
that would happen since you are (or should be) controlling the nature
of the subprocess's output.

Cheers,
Ken


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Adding PDFPage to PDFDocument crashes

2008-09-02 Thread Paul Archibald
Okay, after a bunch of struggles, I got my code to work. What I  
wanted was to make a multi-page pdf document from a bunch of text. I  
wanted a method that would take an array of strings and make a pdf  
page from each string, then join them all together into a single pdf  
document.


My original plan was to iterate through the text chunk array, making  
PDFPages from each one, and adding them to the PDFDocument, but that  
did not work (I forget now why not, although that is how I am doing  
it now. Should have taken notes.) Since that was not working, and  
since I saw another example on CocoaDev, I tried putting the PDFPages  
in a separate array, then iterating through that array to get the  
pages to add to the document. That seemed to work on my Tiger- 
PowerBook but not on my Leopard-intelMini, so I went back to the add- 
pdfpage-to-doc-as-you-go method, which now works. I must have made  
some changes on the way back, but I did not keep track of them.


So, this method seems to work, but I still have some questions. I  
have not mastered ObjC memory management, and I am not convinced that  
I am doing this correctly. Can any take a look at this and comment on  
how I am allocating, initing, releasing and autoreleasing the various  
objects here?


Here is the working code, with the nonworking code commented out, and  
some other comments, too:

//==
- (BOOL) renderToPDFFile: (NSArray*) textChunks :(NSString*) file {
	// NSMutableArray *pdfpages = [[NSMutableArray alloc] init]; // not  
using this anymore

NSRect r = NSMakeRect(0, 0, 600, 1);
NSTextView* view = [[NSTextView alloc] initWithFrame:r];
r = [view bounds];
	PDFDocument *outputDoc = [[PDFDocument alloc] initWithData:[view  
dataWithPDFInsideRect:r]];


int i;
for(i = 0; i  [textChunks count]; i++) {
NSTextView* v = [[NSTextView alloc] initWithFrame:r];
NSString *s = [textChunks objectAtIndex:i];
[v insertText:s];
[v sizeToFit];  // this is important for me
r = [v bounds]; // and it seems to work fine

		PDFDocument *tempDoc = [[PDFDocument alloc] initWithData:[v  
dataWithPDFInsideRect:r]];

PDFPage *page = [[PDFPage alloc] initWithDocument:tempDoc];
page = [tempDoc pageAtIndex:0];

[outputDoc insertPage:page
atIndex:[outputDoc pageCount]]; // this now works

//		[pdfpages addObject:page];	// originally, I was trying to hold on  
to the page objects in an array

//  [page autorelease]; //  WOULD THIS BE CORRECT?  
My reading of the
		// mmgt stuff tells me yes, since the page is added to an  
array, its refcount is incremmented,
		// WAIT!! now it works without being released or autoreleased.  
HELP!
		// the rule says if I alloc it, I need to release it, so what's  
correct? Am I leaking?

[tempDoc autorelease];
[v autorelease];
}

//  id p;
//	NSEnumerator *e = [pdfpages objectEnumerator];		// here I intended  
to take each pdf page in the array and add it

//  while(p = [e nextObject]) { // to the main 
pdf document
//		[outputDoc insertPage:p 			// this was crashing. seemed to be an  
array out of bounds error
//			atIndex:[outputDoc pageCount]];		// but I could not decipher the  
error message.

//  }   

[outputDoc removePageAtIndex:0];// the first 
page was really a dummy
NSData *data = [outputDoc dataRepresentation];
BOOL b = [data writeToFile:file atomically:YES];// this works 
fine

[pdfpages autorelease]; // coments anyone?
	[outputDoc autorelease];	// is this okay, or should I release  
instead, or ...?
	[view autorelease];		// if(alloced) release, right? isn't that the  
rule?

return b;
}

If anyone has a few minutes to comment on this I would appreciate it.  
Some aspects of Cocoa memory management are still odd to me, like how  
to handle 
___


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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Adding PDFPage to PDFDocument crashes

2008-09-02 Thread Paul Archibald

Thanks for the comments Andy.

I see what you mean about reassigning that page pointer. As I recall,  
I had trouble fully allocating a page without the pdf document. Just  
using [[PDFPage alloc] init] did not seem to create a real pdf  
page, and trying to do anything with such an object failed. I sort of  
stumbled into this technique. Looking at the code, I think I could  
also just forgo that pointer completely, and go with


PDFDocument *tempDoc = [[PDFDocument alloc] initWithData:[v  
dataWithPDFInsideRect:r]];
//PDFPage *page = [[PDFPage alloc] initWithDocument:tempDoc];	// does  
this copy the content of the doc to the page?

//page = [tempDoc pageAtIndex:0];
[outputDoc insertPage:[tempDoc pageAtIndex:0] atIndex:[outputDoc  
pageCount]];


I am going to test this idea.  Do you think that it would work? One  
less pointer to manage?



Thanks again for your response.
Paul

On Sep 2, 2008, at 12:28 PM, Andy Mroczkowski wrote:


Hi Paul,

The structure of your code is very similar to some I wrote, which  
works well for me.


A couple comments:

		PDFDocument *tempDoc = [[PDFDocument alloc] initWithData:[v  
dataWithPDFInsideRect:r]];

PDFPage *page = [[PDFPage alloc] initWithDocument:tempDoc];
page = [tempDoc pageAtIndex:0];



Here you're creating a PDFPage object and assigning it to the *page  
pointer var.  Then the *page pointer is being immediately re- 
assigned to the first page of tempDoc.  This is why the [page  
autorelease] was blowing up.  The PDFPage object was owned by  
tempDoc, so it was being double released.  Also, the PDFPage  
initially alloc'd is being leaked.  To fix it all, you just want to  
do:


PDFDocument *tempDoc = [[PDFDocument alloc] initWithData:[v  
dataWithPDFInsideRect:r]];

PDFPage *page = [tempDoc pageAtIndex:0];

I use the same strategy, which again, Works For Me.

Next:


[pdfpages autorelease]; // coments anyone?
	[outputDoc autorelease];	// is this okay, or should I release  
instead, or ...?
	[view autorelease];		// if(alloced) release, right? isn't that  
the rule?



Well first, pdfpages is no longer declared, but you probably knew  
that =]


oops, yeah. what I pasted in is not exactly what I am using. I missed  
that.




The other two autoreleases are correct, though in general I suggest  
using regular release when you can.  The overhead on autorelease  
isn't much but it is non-zero.  Plus it makes over-release bugs a  
little harder to track down sometimes.


Point taken.



Happy Hacking =]

- Andy







Here is the working code, with the nonworking code commented out,  
and some other comments, too:

//==
- (BOOL) renderToPDFFile: (NSArray*) textChunks :(NSString*) file {
	// NSMutableArray *pdfpages = [[NSMutableArray alloc] init]; //  
not using this anymore

NSRect r = NSMakeRect(0, 0, 600, 1);
NSTextView* view = [[NSTextView alloc] initWithFrame:r];
r = [view bounds];
	PDFDocument *outputDoc = [[PDFDocument alloc] initWithData:[view  
dataWithPDFInsideRect:r]];


int i;
for(i = 0; i  [textChunks count]; i++) {
NSTextView* v = [[NSTextView alloc] initWithFrame:r];
NSString *s = [textChunks objectAtIndex:i];
[v insertText:s];
[v sizeToFit];  // this is important for me
r = [v bounds]; // and it seems to work fine

		PDFDocument *tempDoc = [[PDFDocument alloc] initWithData:[v  
dataWithPDFInsideRect:r]];

PDFPage *page = [[PDFPage alloc] initWithDocument:tempDoc];
page = [tempDoc pageAtIndex:0];

[outputDoc insertPage:page
atIndex:[outputDoc pageCount]]; // this now works

//		[pdfpages addObject:page];	// originally, I was trying to hold  
on to the page objects in an array
//		[page autorelease];		//  WOULD THIS BE CORRECT?  My reading  
of the
		// mmgt stuff tells me yes, since the page is added to an  
array, its refcount is incremmented,
		// WAIT!! now it works without being released or  
autoreleased. HELP!
		// the rule says if I alloc it, I need to release it, so  
what's correct? Am I leaking?

[tempDoc autorelease];
[v autorelease];
}

//  id p;
//	NSEnumerator *e = [pdfpages objectEnumerator];		// here I  
intended to take each pdf page in the array and add it

//  while(p = [e nextObject]) { // to the main 
pdf document
//		[outputDoc insertPage:p 			// this was crashing. seemed to be  
an array out of bounds error
//			atIndex:[outputDoc pageCount]];		// but I could not decipher  
the error message.

//  }   

	[outputDoc removePageAtIndex:0];			// the first page was really a  
dummy

NSData *data = [outputDoc dataRepresentation];
BOOL b = [data writeToFile:file 

[OT] curious about the iPhone dev program

2008-09-02 Thread Paul Archibald

Comrades,

 going off topic here

I am getting interested in iPhone development, but I can't tell if  
dropping a C-note to Apple is really worth it. Anyone know of other  
fora where I can tune in to see what its all about, or is Apple's the  
only game in town?


 now returning to our regularly scheduled programming



Paul Archibald

Governments need armies to protect them
from their enslaved and oppressed subjects.

-- Leo Tolstoy




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Adding PDFPage to PDFDocument crashes

2008-09-02 Thread Paul Archibald
I really like that rule of thumb. Very clean, very cool. Thanks. (I  
am not too worried about overhead in this case.)


Paul


On Sep 2, 2008, at 7:00 PM, [EMAIL PROTECTED] wrote:



And if you do use autorelease, then put it right where you allocate
the object. For example:

NSTextView* view = [[[NSTextView alloc] initWithFrame:r]  
autorelease];


The advantage of this is that it places all of your memory management
right in the same place. It's much harder to forget to release
something if you use an autorelease right when you create the object
instead of using a release farther down. This also saves you from
accidentally leaking if you return from the middle of the function or
throw an exception.

However, as you say, this does have some extra overhead and can make
some bugs harder to find, so it's something of a tradeoff.

Mike


___

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

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

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

This email sent to [EMAIL PROTECTED]


process monitoring panic

2008-09-02 Thread Paul Archibald

Help.

I was about to send my client a new version of the app, and the main  
thing I just thought I fixed has completely stopped working. Sheesh.


What the app does is launch a memory and cpu intensive command line  
program and monitor its progress. It I run the CLP separately, I see  
it outputs its progress as text to the Terminal window it was  
launched from. If I run my app via Xcode, either the release or debug  
version, and cause it to do that sublaunch, my app grabs that output,  
which I use to update the progress bars. That part works fine. Usually.


Now the problem. If I shut down Xcode and launch my app and sublaunch  
the CLP, no progress info gets to my app, and nothing appears in the  
console window. The CLP does its work okay, I can see the resulting  
output file, but the console communications are on hold until it is  
done, when all the progress info gets poured into the console at  
once. I need that console output, why is it being held hostage?


Okay, this has me stumped. Does Xcode somehow pipe the output of the  
CLP to my app when it is present, and when its not there that pipe is  
never hooked up? This CLP is a major hog, it grabs 85+% of the CPU  
when it runs, does that make a difference? I thought my app would  
work better if Xcode was not using half the available memory itself.


Anyone have any ideas what to look at here? I am using an NSTask  
wrapper class (TaskWrapper) I adapted from the Moriarity sample to do  
the sublaunch and monitoring stuff. ( I have a fix for it under  
Leopard which I will report on later, just to try to put something  
back into the pot.)


This is gonna hold up my paycheck!

Paul



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Dynamic right-sizing of TextContainer

2008-08-29 Thread Paul Archibald
Doug is correct. Check out NSText in the APIs. I used this method  
just yesterday to size a text view:



-sizeToFit
Resizes the receiver to fit its text.
- (void)sizeToFit
Discussion
The text view will not be sized any smaller than its minimum size,  
however.

Availability
•   Available in Mac OS X v10.0 and later.
See Also
•   – isHorizontallyResizable
•   – isVerticallyResizable

To prove it to yourself, create a rectangle r, make a textview with  
r, -insertText into it, check r in debugger,  call -sizeToFit, and  
look at the rectangle now. Horizontal does not adjust automatically,  
maybe due to wordwrapping concerns?



Paul

On Aug 29, 2008, at 12:27 PM, [EMAIL PROTECTED] wrote:


On Aug 29, 2008, at 11:01 AM, Martin Stoufer wrote:


I am able to set the initial height/width of the NSTextContainer
object of a NSTextView object in IB. However, I cannot find any
method that will allow the programmatic re-sizing of the container
when the text I'm adding exceeds this size.


Don't do this.  NSTextView handles this automatically for you.  See /
Developer/Examples/AppKit/TextSizingExample for examples of various
different ways to set up a text view depending on how you want it to
resize vertically, horizontally, etc.  If the width is fixed and you
just want the container to size properly vertically, you don't need to
do anything; the stock NSTextView you create in IB should be fine.

Douglas Davidson


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


How do I create a PDF fle paginated according to my own rules?

2008-08-28 Thread Paul Archibald
  
a PDFDocument object.


That sounds like the right thing to use, what am I doing wrong?


Paul Archibald

Every decent man is ashamed of the government he lives under.
H.L. Mencken (1880-1956)




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


Creating a PDF file from NSString without showing it onscreen

2008-08-26 Thread Paul Archibald

Comrades -

A while back I posted a question about creating a PDF file. I got a  
good, simple answer from Chuck which has worked in one test I have  
tried, but which I want to generalize. The first test used a custom  
view in the nib file, which I inserted text into, and then wrote out  
to the file. However, what I really would like is to be able to send  
an NSString (in)directly to the PDF file.


I am using the PDFImageView form Apple's PDFView sample project.

Here is my snippet:

- (void) renderToPDFFile: (NSString*) text :(NSString*) file {
// PDFImageView isa NSImageView
PDFImageView* pdfview = [[PDFImageView alloc] init];
[pdfview setHidden:YES];
[pdfview insertText:text];

NSRect pdfbounds = [pdfview bounds];
NSTextView* tview = [[NSTextView alloc] initWithFrame:pdfbounds];
[tview insertText: text];   

NSRect r = [tview bounds];
NSData *data = [tview dataWithPDFInsideRect:r];
[data writeToFile:file atomically:YES];
}

I do get a pdf file out of this, but it has no content. Debugging it,  
I see that my pdfbounds rectangle is not properly sized, but is just  
{0,0,0,0}.


I suspect that the problem I am having now is that I am not properly  
initializing the PDFImageView. (In my first test I had a normal nib  
with a PDFImageView displayed in the main window). In the real  
program I don't have a spare window to render the text into, so I  
would like to do all the work without any visible elements.


So, how do I create a view (PDFImageView or NSImageView) without  
having it in the nib? Do I need a window to put the view in? If so,  
does that window need to be visible?


As usual, if someone can just point me in the right direction, that  
would be swell.


Paul


On Aug 6, 2008, at 12:03 PM, [EMAIL PROTECTED] wrote:




It looks like PDFKit is aimed at simply reading and navigating within
an existing PDF file, but what I need to do is create a new
PDF and   write some simple text to it. I know that the Preview app
does that  for a lot of apps, but I would like to bypass that, too. I
simply want my app to create a PDF file, open it for writing,
write some  simple text to it, and save it to disk.


Easiest way: Create a view that draws what you want, send it - 
dataWithPDFInsideRect: and write that data to a file.


Cheers,
Chuck


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Creating a PDF file from NSString without showing it onscreen (solution?)

2008-08-26 Thread Paul Archibald

I think this will probably do:

- (void) renderToPDFFile: (NSString*) text :(NSString*) file {
NSRect r = NSMakeRect(0, 0, 800, 800);  
NSTextView* v = [[NSTextView alloc] initWithFrame:r];
[v setHidden:YES];
[v insertText:text];
[v sizeToFit];  // ah, the magic elixir!
r = [v bounds]; // now it is the right size
NSData *data = [v dataWithPDFInsideRect:r]; 
[data writeToFile:file atomically:YES];
[v release];
}

It seems that the sizeToFit method only effects the width of the  
view, but that's probably okay in my case. My text will always be  
fairly narrow, but it could be quite tall.


Guess I better do some error checking.

Also got rid of that redundant stuff that I didn't need because there  
was already some stuff that could be used.



Paul
CROR
(Chief Redundancy Officer of Redundancy)



On Aug 26, 2008, at 1:22 PM, Andy Lee wrote:


On Aug 26, 2008, at 4:03 PM, Paul Archibald wrote:

PDFImageView* pdfview = [[PDFImageView alloc] init];


[...], I see that my pdfbounds rectangle is not properly sized,  
but is just {0,0,0,0}.


That's because you used -init to initialize pdfView.  The  
designated initializer for NSViews is -initWithFrame:.


--Andy




___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 enumerate directory contents?

2008-08-21 Thread Paul Archibald

I did something like this:

NSString *file;
// Get all of the files in the source directory, loop thru them.
	NSEnumerator *files = [[myFileMgr  
directoryContentsAtPath:srcDirectory] objectEnumerator];

while(file = [files nextObject] ) { 
if( [[file pathExtension] isEqualToString:interestingExtension] 
) {
// do something with file
}

}



Paul Archibald

An ocean without its unnamed monsters
would be like a completely dreamless sleep.
— John Steinbeck





On Aug 19, 2008, at 10:06 PM, [EMAIL PROTECTED] wrote:


Re: How to enumerate directory contents?


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 enumerate directory contents?

2008-08-21 Thread Paul Archibald

You make a valid point. I think I will make that change.

This is not really what we actually do. I cut out most of the real  
code to keep the example simple. The actual files we are looking for  
are machine generated, and the user is not really involved in the  
process at this point.


Paul


On Aug 21, 2008, at 9:49 AM, Sean McBride wrote:


On 8/21/08 7:46 AM, Paul Archibald said:


NSString *file;
// Get all of the files in the source directory, loop thru them.
NSEnumerator *files = [[myFileMgr
directoryContentsAtPath:srcDirectory] objectEnumerator];
while(file = [files nextObject] ) { 
if( [[file pathExtension] isEqualToString:interestingExtension] 
) {
// do something with file
}


You might want to read the docs for isEqualToString.  Using it to
compare file extensions will not behave as the user expects (case
sensitivity, Unicode decomposition, etc.)

--

Sean McBride, B. Eng [EMAIL PROTECTED]
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada





___

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

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

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

This email sent to [EMAIL PROTECTED]


How do you create a new PDF file and write text to it?

2008-08-06 Thread Paul Archibald

Comrades -

It looks like PDFKit is aimed at simply reading and navigating within  
an existing PDF file, but what I need to do is create a new PDF and  
write some simple text to it. I know that the Preview app does that  
for a lot of apps, but I would like to bypass that, too. I simply  
want my app to create a PDF file, open it for writing, write some  
simple text to it, and save it to disk.


Any advice?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 do you create a new PDF file and write text to it? LOOKS LIKE ITS SOLVED

2008-08-06 Thread Paul Archibald

Dude!

That does look simple. I figured it would be.

Thanks,
Paul


On Aug 6, 2008, at 11:42 AM, Charles Steinman wrote:


--- On Wed, 8/6/08, Paul Archibald [EMAIL PROTECTED] wrote:


It looks like PDFKit is aimed at simply reading and
navigating within
an existing PDF file, but what I need to do is create a new
PDF and
write some simple text to it. I know that the Preview app
does that
for a lot of apps, but I would like to bypass that, too. I
simply
want my app to create a PDF file, open it for writing,
write some
simple text to it, and save it to disk.


Easiest way: Create a view that draws what you want, send it - 
dataWithPDFInsideRect: and write that data to a file.


Cheers,
Chuck






___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


simple question about passing around pointers to objects

2008-06-27 Thread Paul Archibald

Comrades:

I have experimented a bit with this, and I think I have something  
that works, but I would like to understand it better. I am reading  
the Hillegass book, but I don't really see an example of what I am  
tryng to do, although it seems like a very basic question.


The Question:
If I want to create an object and pass it to another method, where I  
plan to use it briefly (as a local variable), what is the proper way  
to allocate and deallocate the object in the various methods?



Here is a simple example:

-(NSArray*) makeObject {
	NSArray *a = [NSArray arrayFromObjects];someObject, anotherObject,  
nil];

// should I [a retain];
// or [a release];
// or [a autorelease];
// or do nothing
// before I
return a;
}

-(void) useObject {
NSArray *local = [self makeObject];
// should I [local retain];
// or [local release];
// or [local autorelease];
// or do nothing
// before I exit this method?
	// I need to pass local as an argument to the creation of another  
object before exiting

MyObj *o = [[MyObj alloc] initWithArray:local];
}


There are a lot of possible combinations here, and I have tried a  
bunch of them. Some of them work, others crash the program with a  
EXC_BAD_ADDRESS. But, as I have been trying to make an exhaustive  
test of what works and what crashes, I realize that just  
experimenting with this is not enough, and I need a better  
theoretical understanding of this stuff. If you recognize this  
pattern and can tell me where to read more on it, that would be  
great, too.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


wrapping multiple IBOutlet objects for reuse

2008-06-24 Thread Paul Archibald

Is there a way to use class objects that wrap multiple IBOutlet objects?

The app I am working on has groups of interface elements that are  
repeated on the interface and in the code. Let me see if I can  
illustrate what I mean:


The window looks (slightly) like this:

(button_set_src_1) (add) (delete) (halt) (progressbar1)
(button_set_src_2) (add) (delete) (halt) (progressbar2)
(button_set_src_3) (add) (delete) (halt) (progressbar3)

And the code looks (slightly) like this:

IBOutlet NSTextField*src1;
IBOutlet NSProgressIndicator*progressbar1;
IBOutlet NSTextField*dest1;
IBOutlet NSButton   *halt1;
IBOutlet NSButton   *remove1;
IBOutlet NSTextField*precentdone1;

IBOutlet NSTextField*src2;
IBOutlet NSProgressIndicator*progressbar2;
IBOutlet NSTextField*dest2;
IBOutlet NSButton   *halt2;
IBOutlet NSButton   *remove3;
IBOutlet NSTextField*precentdone2;

IBOutlet NSTextField*src3;
IBOutlet NSProgressIndicator*progressbar3;
IBOutlet NSTextField*dest3;
IBOutlet NSButton   *halt3;
IBOutlet NSButton   *remove3;
IBOutlet NSTextField*precentdone3;

This is pretty klunky, and I would like something more like:
@interface Element : NSObject
{
IBOutlet NSTextField*src;
IBOutlet NSProgressIndicator*progressbar;
IBOutlet NSTextField*dest;
IBOutlet NSButton   *halt;
IBOutlet NSButton   *remove;
IBOutlet NSTextField*precentdone;
}
@end

...
Element *e1;
Element *e2;
Element *e3;

or even better, an array of Elements:

NSArray *elements [[NSArray alloc] initWithObjects:
e1, e2, e3];
 not sure exactly how to do this, but you get the idea..


But, while the code part seems easy enough, I am not sure how it  
would work with Interface Builder. Is it possible to create a custom  
class like that (Element), and place instances of it on a window in  
IBuilder, hook up the controls in the code? Maybe someone can help me  
with terminology or examples? I know what I want, but I don't know  
enough about Cocoa yet to express it.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How does an instance variable in the ObjC code get connected to an interface element in the NIB file? BACK ON TRACK

2008-06-17 Thread Paul Archibald
Well, Erik, you know that sometimes we inherit working code without  
knowing much about its history. I don't want to break something that  
already works (and ships), and re-factoring the whole codebase is not  
part of my charter. I am trying to add my stuff without disturbing  
the working app. I think I will be moving a lot of the outlets that  
concern my module, but as for the rest ...


If it ain't broke, don't fix it.

(The message thread you mention looks like a rich source. I will have  
to read the whole thing. I have only been on the forum a couple of  
weeks, and I am running to catch up.)


On Jun 17, 2008, at 12:37 AM, [EMAIL PROTECTED] wrote:

Over 130 outlets! Holy Sassafras Tea!  That is ten to fifteen times  
more outlets than I have ever seen in a single class in 20 years of  
Objective-C programming!


  I suspect you are doing something very wrong.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 does an instance variable in the ObjC code get connected to an interface element in the NIB file? BACK ON TRACK

2008-06-16 Thread Paul Archibald
Okay, I see them now. I was missing them in the rather long list of  
outlets (over 130!) for the main controller.


I wanted to understand this better because I want to re-factor the  
code so that there are NOT 135 outlets for one controller. Currently  
we have two windows that handle different tasks, but share the  
controller. I want separate controllers for each window/task.


Thanks, Ken.


On Jun 13, 2008, at 6:22 PM, Ken Thomases wrote:


On jun 13, 2008, at 4:21 PM, Paul Archibald wrote:

This puzzles me. I am tracing through some code in which I am  
looking at the value of some selected popup menu items. I am  
seeing the correct values for them, but I have to confess I don't  
know how the code is connected to the popup, or just why the code  
even works! I see the connections for the buttons on the  
interface, and I hit the breakpoints I expect, but I don't see any  
connections between the member variables and the popup items.


There are instance vars for the popups in the code, but I don't  
see how they are connected to the NIB.


It sounds to me like you're not familiar with outlets, which is a  
pretty basic part of Cocoa GUI design.  You probably need to review  
the conceptual documentation:


http://developer.apple.com/documentation/Cocoa/Conceptual/ 
CocoaFundamentals/


http://developer.apple.com/documentation/Cocoa/Conceptual/ 
CocoaFundamentals/CommunicatingWithObjects/ 
chapter_6_section_3.html#//apple_ref/doc/uid/TP40002974-CH7-SW3


Regards,
Ken



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Still trying to refactor a category as a class

2008-06-15 Thread Paul Archibald
Wow, Ken, thank you for such a thoughtful and  detailed response. I  
need to read it a few more times to understand it better, but it has  
been very useful already. I recognize a couple of points were I might  
have gone astray in my first try.


Oh, and thanks for your second response, too. For a lot of this  
stuff, I just need someone to tell me to look at categories or  
bindings or whatever. Facing the ObjC/Cocoa/IBuilder thing,  
sometimes I just wnat a hint as to where to look for the  
documentation, of at least the terminology to look up.


Paul

On Jun 13, 2008, at 6:19 PM, Ken Thomases wrote:

I tried making a new controller for the new window/module, on the  
theory that since they don't share much data or functionality,  
they ought to be separate class objects. However, I am had some  
problems with that approach. In particular, I was getting several  
runtime errors of the type: Could not connect the action  
someNSApplicationAction: to target of class MyController. I don't  
understand this at all, but I am more worried that I am just  
completely off track in trying to create a new controller, and  
that fixing this problem will just allow me to go even farther  
into the weeds.


This sounds like the nib you received had controls which were  
configured to deliver their action to the File's Owner target.   
When you change the class of File's Owner, you change which actions  
it responds to.  These actions are/were part of AppController or  
its category AppController(ExtraCategory), but are not part of your  
new controller.


___

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

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

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

This email sent to [EMAIL PROTECTED]


Still trying to refactor a category as a class

2008-06-13 Thread Paul Archibald

Comrades:

Geez, I am feeling totally wrapped around the axle here.

I have posted questions on this project a couple of times, and have  
gotten useful answers that allow me to continue. Sometimes I think I  
am heading deeper into the weeds, though. So, let me try rephrasing  
my situation and try to ask a more specific question. Maybe the  
answer will put me back on track.


The project I am working on is used to make and distribute copies of  
certain files. I am trying to add a module that will do some extra  
processing of the files, and then distributing copies of that new,  
processed file. I was given the interface (a window with a bunch of  
popups and stuff) for the new module in the NIB, and there was  
originally a category (AppController(ExtraCategory)) for the extra  
module.


Some of the functionality of the original copy code would be handy to  
reuse, but there are code dependencies in there that I don't want to  
touch, so I am planning to replicate the copy code and modify it for  
the new module. Not very OOP-sy, but what the heck, sometimes you  
just can't do things the way you would like.


I tried making a new controller for the new window/module, on the  
theory that since they don't share much data or functionality, they  
ought to be separate class objects. However, I am had some problems  
with that approach. In particular, I was getting several runtime  
errors of the type: Could not connect the action  
someNSApplicationAction: to target of class MyController. I don't  
understand this at all, but I am more worried that I am just  
completely off track in trying to create a new controller, and that  
fixing this problem will just allow me to go even farther into the  
weeds.


So, here is my question:

Given my description of this project, does the two controller  
solution sound like the best one? Does anyone have any tips on how to  
re-factor this thing? My first effort kind of blew up in my face. I  
could not figure out how to do it gradually, so I just did a major  
cut/copy/paste/change-some-connections/rename-some-stuff kind of  
thing, and then built and ran it, but I don't know enough about the  
Cocoa/ObjC/IB/Xcode system to figure out what went wrong.


(And, a followup question would be: where could I find an example of  
an app that has multiple controllers which do not relate to the same  
document? The samples I have looked at so far seem to be based on the  
MCV pattern. I am looking for something more like MCV(1)+MCV(2).)


Paul
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


How does an instance variable in the ObjC code get connected to an interface element in the NIB file?

2008-06-13 Thread Paul Archibald

Comrades:

This puzzles me. I am tracing through some code in which I am looking  
at the value of some selected popup menu items. I am seeing the  
correct values for them, but I have to confess I don't know how the  
code is connected to the popup, or just why the code even works! I  
see the connections for the buttons on the interface, and I hit the  
breakpoints I expect, but I don't see any connections between the  
member variables and the popup items.


There are instance vars for the popups in the code, but I don't see  
how they are connected to the NIB.



Paul
(I hope I didn't already ask this question!)
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


how do you make NIB connections for class with multiple categories (and their headers)?

2008-06-12 Thread Paul Archibald

my head is hurting

I am trying to understand the NIB/code connection. I have a couple of  
windows in this project, one of which I am working on, the other I  
have been leaving alone. For MyWindow, I have been adding methods in  
my category.h file, and dragging that header to the nib, and linking  
up the controls. That seems to be working okay. The problem is that  
there don't seem to be any connections for the OldWindow. How can  
that be?


a bit later

Oh dang. It looks like I broke the OldWindow while working on  
MyWindow. I am going to have to roll back to a working version.



one of my many questions

This project consists of a AppController class with a bunch of added  
categories, one of which I am trying to implement. So, there are a  
bunch of AppController+ExtraCategory header/source files. I think I  
understand how we synchronize the code and the nib, by dragging the  
header file from the Xcode project to the nib-instance window. But  
what about a project like this, with a bunch of different header  
files, all of which are part of the same controller? Do I select all  
the header files in the Xcode project and drag all of them into the  
nib-instance window? And, when I do that should I merge the  
contents, or replace? I don't wnat to break an existing connection  
by dragging my AppController(MyCategory) header onto the nib-instance  
winodw only to break all the established connections for the other  
categories! (I see I can lock the connections, which I will do, but  
I still want to know how to add the connections of MyCategory without  
stepping on the other ones.


cocoa + objc + ibuilder = lots of questions



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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-factoring a category into a class instance

2008-06-10 Thread Paul Archibald

Comrades:

I am working on a file-handling Cocoa app that (at this point) has a  
single window. We are adding a second window (really sort of a non- 
modal dialog) to do some extra processing of the target files. The  
interface for the new window is already built (with IB), but is not  
hooked up yet.


So, the way this started was as a AppController(ExtraCategory) thing,  
with the NIB file having a single controller object. I don't like  
that method, because there is a lot of data and code that would need  
to be replicated in the main AppController to handle the work that  
the ExtraCategory does. What I would like to do is put all the  
ExtraCategory stuff into its own class, but I am not sure how. My  
inclination is toward making the ExtraCategory into a  
NSWindowResponder, but the documentation I have read so far makes it  
look like that is more intended for document-based apps, which this  
is not. Also, I don't quite see (looking at some example code) how an  
extra controller is instantiated by the main app controller.


 A simplified example of the current code 

@interface AppController {
NSString* srcDir;   // the original stuff
NSString destDir;   // original
// there is a bunch more

	NSString* srcDirForExtraCategory;	// needed for new window/dialog/ 
category

NSString destDirForExtraCategory;   // needed for new
// more stuff needed here
}
-(void)setSrc;  // implemented in the .m file, of course
-(void)setDest;
@end

and in AppController(ExtraCtegory)

@interface AppController(ExtraCategory)
-(void)setSrcForExtraCategory;  // special handling
-(void)setDestForExtraCategory; // special handling
@end

It seems funky to me that I can declare extra functions for the  
ExtraCategory, but I can't add member data. I understand there is a  
difference between the class/subclass and the class/category  
paradigms. I guess what I am trying to do is turn this new window  
category into a standalone class, instantiate it (in the NIB, I  
suppose), and control its availability from the original main app  
controller instance.


Any advice?
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: re-factoring a category into a class instance

2008-06-10 Thread Paul Archibald
Ooops, saw that go by and spaced out fixing it. I am just beginning  
with Cocoa, and the framework names are not that familiar yet.


Thanks for the advice, Brian, especially the part about instantiating  
my controller in code. I figured it couldn't be too hard, but a  
little nudge in the right direction is welcome.



On Jun 10, 2008, at 4:04 PM, [EMAIL PROTECTED] wrote:


Since there's no such thing as NSWindowResponder I assume what you
meant was NSWindowController.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]


newbie question: menu item appears when app runs, but is not visible in NIB

2008-05-29 Thread Paul Archibald

Comrades,

-- Newbie Alert --
This is my first posting to this list, and has to do with my first  
foray into Cocoa + ObjC + Interface Builder. I am trying to  
understand the relationships between resource elements in the NIB and  
the ObjC code the the Xcode project, and how to modify them. I have  
worked a lot with CodeWarrior and VisualC++/MFC in the past, but the  
Xcode/IB interplay seems different from either of those systems.



-- The Project --
I am modifying an existing application. Its purpose is to allow a  
user to select a source directory and several destination directories  
into which copies of the source will be copied. The existing app has  
a single window with a bunch of controls for setting directory paths  
and some options for those copies (checksums, metadata, etc). The  
app is used to make special backup copies of a specialized data type.



-- My Task --
My job is to hook up the controls for another window. That window has  
already been built in IB, but is not functional yet. This new window  
will do some similar tasks (setting source/destination directories),  
but also does some extra stuff.



-- The Problem --
I added a menu item to switch between the new window and the old  
window. The switching works okay (sort of), but somehow along the way  
I have gotten an extra menu item into the app.


When I run the app, I see a menu item that is not visible in the NIB  
file. I recognize the extra item, I built it. However, I had some  
problems with the NIB, so I reverted to an older copy of the NIB, and  
started modifying that. I thought I had gotten rid of the old menu  
item, and I can't see it anywhere in the NIB or the ObjC code, but I  
sure see it when I run the app. What gives?


-- My Question --
How can a running app show a menu item that is not in the NIB? Where  
else does Xcode/IB store resources that I am not seeing?


Thanks for any help. I am sure to lots more questions while I work  
through tutorials and wok on this project.


Paul Archibald

--
The competent programmer is fully aware of the strictly limited size  
of his own skull; therefore he approaches the programming task in  
full humility, and among other things he avoids clever tricks like  
the plague.


Edsger W. Dijkstra, (Dutch computing scientist)
---



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: newbie question: menu item appears when app runs, but is not visible in NIB

2008-05-29 Thread Paul Archibald

Yes, I did that. No dice.

At this point I am doing better. Since I have just barely begun, I  
just made a new branch of the codebase and started over (in the nib,  
the source code I copied and pasted into the new branch).


So, now the menu looks okay. I still don't understand what was going  
on, though. Maybe as I gain experience with Cocoa/IB I will figure it  
out.



On May 29, 2008, at 2:32 PM, Jean-Daniel Dupas wrote:



Le 29 mai 08 à 20:25, Paul Archibald a écrit :


Comrades,

-- Newbie Alert --
This is my first posting to this list, and has to do with my first  
foray into Cocoa + ObjC + Interface Builder. I am trying to  
understand the relationships between resource elements in the NIB  
and the ObjC code the the Xcode project, and how to modify them. I  
have worked a lot with CodeWarrior and VisualC++/MFC in the past,  
but the Xcode/IB interplay seems different from either of those  
systems.



-- The Project --
I am modifying an existing application. Its purpose is to allow a  
user to select a source directory and several destination  
directories into which copies of the source will be copied. The  
existing app has a single window with a bunch of controls for  
setting directory paths and some options for those copies  
(checksums, metadata, etc). The app is used to make special  
backup copies of a specialized data type.



-- My Task --
My job is to hook up the controls for another window. That window  
has already been built in IB, but is not functional yet. This new  
window will do some similar tasks (setting source/destination  
directories), but also does some extra stuff.



-- The Problem --
I added a menu item to switch between the new window and the old  
window. The switching works okay (sort of), but somehow along the  
way I have gotten an extra menu item into the app.


When I run the app, I see a menu item that is not visible in the  
NIB file. I recognize the extra item, I built it. However, I had  
some problems with the NIB, so I reverted to an older copy of the  
NIB, and started modifying that. I thought I had gotten rid of the  
old menu item, and I can't see it anywhere in the NIB or the ObjC  
code, but I sure see it when I run the app. What gives?


-- My Question --
How can a running app show a menu item that is not in the NIB?  
Where else does Xcode/IB store resources that I am not seeing?


Thanks for any help. I am sure to lots more questions while I work  
through tutorials and wok on this project.


Paul Archibald



First,  try to clean your target (Buile Menu  Clean) and to  
rebuild it.







___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Re: newbie question: menu item appears when app runs, but is not visible in NIB

2008-05-29 Thread Paul Archibald
I am really a total newbie (3 or 4 days) with IB, so I have NO  
confidence that I can tell what is a bug yet. I barely understand  
what I am doing as yet.


However, I should have done the IB run mode thing. I did not think  
of that. I just looked at it and it looks correct (no extra item). Go  
figure.


On May 29, 2008, at 6:11 PM, [EMAIL PROTECTED] wrote:


Interface Builder can be buggy at times, leaving some leftovers
around when they should be gotten rid of.  I've got a couple of
leftovers myself, but they're harmless so far; one of these days,
I'll just go all down-and-dirty editing on it, but I don't have the
time right now.  If you've still got the buggy NIB, submit a bug
with it included and describe what you see in IB edit mode, IB run
mode, and application runtime.  Also make sure to include what
version of Interface Builder you used to create it and are using to
edit it.


You have filed a bug on this, right?   preferably attaching the
NIB file with extras in it?

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Another newbie question

2008-05-29 Thread Paul Archibald

Comrades:

Hi, its me again.

My interface consists (mostly) of a bunch of popup buttons with  
various values in them. Out user will set up all these popups and  
click go, and the app will emit a string which can be used to run a  
command line program. So, for example we have a couple of popups like:


Color
-black
-red
-green
-blue

Size
-small
-medium
-large

So, lets say that the command line wants something like:
runfoo -color 2 -size 1

and that the runfoo help file says
-color : red = 1, blue = 2, green = 3, black = 4, default = 4
-size : small = 1, medium = 2, large = 3, default = 3

So, here is my question. What is the best way to translate between  
the popup item and the value? I was thinking of building an  
NSDictionary with item_string_key/command_line_argument_value pairs,  
but I realized that I have a bunch of different default values  
(color default = 4, size default = 3).


I guess I could have a dictionary for each popup, but that seems  
clunky. I see there is something called Bindings for menu/popup  
items, is that a way to go? (I am trying not to put the info in the  
NIB, I would prefer code, where I can see it.)





Paul Archibald


--
The competent programmer is fully aware of the strictly limited size  
of his own skull; therefore he approaches the programming task in  
full humility, and among other things he avoids clever tricks like  
the plague.


Edsger W. Dijkstra, (Dutch computing scientist)
---



___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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]