Re: NSApplicationMain question

2010-04-25 Thread Bill Appleton
hi all,

i wanted to do a reality check on some of my code & ask some specific
questions.

1) how do i get that nifty application/preferences/services menu? i create
my menus dynamically (not nibs)

2) i need to create a raw NSScroller and control it like a NSSlider  (min,
max, value, proportion) is that possible?

3) are there window styles for palettes / document windows? there seems to
be only one style...

4) how do you guys check for memory leaks in the cocoa objects? when i
delete a menu... do i have to delete the individual items?

5) is my screen flipping code below going to work on multiple monitors?


thanks,

bill




void deletewindow(NSWindow *thewind)
{

[thewind setReleasedWhenClosed:YES];
[thewind close];
}

NSWindow *createwindow(rect *therect, long thestyle)
{
NSWindow *thewind;
NSRect myrect, newrect;

myrect = [[NSScreen mainScreen] frame];
newrect.origin.x = (*therect).left;
newrect.origin.y = myrect.size.height - (*therect).bottom;
newrect.size.width = (*therect).right - (*therect).left;
newrect.size.height = (*therect).bottom - (*therect).top;
thewind = [[NSWindow alloc] initWithContentRect:newrect
styleMask:thestyle backing:NSBackingStoreBuffered defer:YES];
return(thewind);
}

NSMenu *newmenu(unsigned char *menuname)
{
NSMenu *themenu;
NSString *mystring;
char tempstring[256];

pstr2cstr(menuname, tempstring);
mystring = [NSString stringWithUTF8String:tempstring];
themenu = [[NSMenu alloc] initWithTitle:mystring];
[themenu setAutoenablesItems:NO];
[mystring release];
return(themenu);
}

void deletemenu(NSMenu *themenu)
{

[themenu release];
}

void setmenuitemtext(NSMenu *themenu, long itemindex, unsigned char
*itemname)
{
NSString *mystring;
NSMenuItem *theitem;
char tempstring[256];

itemindex --;
pstr2cstr(itemname, tempstring);
mystring = [NSString stringWithUTF8String:tempstring];
theitem = [themenu itemAtIndex:itemindex];
[theitem setTitle:mystring];
[mystring release];
}
___

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

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

2010-04-25 Thread Keary Suska
On Apr 25, 2010, at 7:44 AM, Bill Appleton wrote:

> hi all,
> 
> i wanted to do a reality check on some of my code & ask some specific
> questions.
> 
> 1) how do i get that nifty application/preferences/services menu? i create
> my menus dynamically (not nibs)

There is nothing special about these menus, other than that the system will 
populate the Services menu. Research services for more info on that. Is there 
something specific that you are unable to accomplish?

> 2) i need to create a raw NSScroller and control it like a NSSlider  (min,
> max, value, proportion) is that possible?

If you must, yes, it is possible.

> 3) are there window styles for palettes / document windows? there seems to
> be only one style...

Technically there are a few, depending on your target OS. But this is just what 
the API gives you for free. You can make your own fairly easily (with some 
caveats).

> 4) how do you guys check for memory leaks in the cocoa objects? when i
> delete a menu... do i have to delete the individual items?

For general leak detection, you can use the clang static analyzer (a simple 
per-project setting) and the Instruments leak tool. Read the "Memory Management 
Programming Guide" (don't have as link handy--easily found in Xcode docs or 
just google "memory management cocoa"). If you ask memory management-related 
questions on this list, you will just get directed to that document so you 
might as well get it over with. If you plan to use garbage collection, also 
(and I mean *also*, not *instead*) read "Garbage Collection Programming Guide".

> 5) is my screen flipping code below going to work on multiple monitors?

You can easily determine this yourself. The NSScreen documentation is a good 
place to start for understanding how this is handled in Cocoa.

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

___

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

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

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

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


Re: NSApplicationMain question

2010-04-25 Thread Paul Sanders
> 1) how do i get that nifty application/preferences/services menu? i create my 
> menus dynamically (not nibs)

I did this by starting out with a menu created from a NIB (and which contained 
the Application menu, File menu, Edit menu and so forth) and then modifying 
this to add the additional elements I wanted.  The NIB I started with was 
created by Xcode, using the generic 'Cocoa Application' template.

> 3) are there window styles for palettes / document windows? there seems to be 
> only one style...

Have a look at the style masks for NSPanel.  In particular, NSUtilityWindowMask 
will give you a floating pallette (with the smaller title bar).

> 4) ... when i delete a menu... do i have to delete the individual items?

Apart from the answer already given, no.  NSMenu retains its submenus and menu 
items so when the parent is deleted (or, rather, released for the last time) 
then all the children will go away too, unless they have been retained 
somewhere else.  This is generally true of collection objects.

To look for leaks, I too use the 'Leaks' tool in Instruments and it did 
discover few things.  It's not foolproof though - there is a chance of a false 
negative - so another simple trick is to watch the memory usage of your app in 
Activity Monitor.  If this keeps on creeping up over time, you still have a 
leak.  I found one or two things this way as well, including a situation where 
an autorelease pool was not being drained for long periods of time resulting in 
excessive peak memory usage.

> 5) is my screen flipping code below going to work on multiple monitors?

Yes, that is essentially what I do to map from and to 'top down' coordinates.  
In fact, I just do:

// Map a screen Y coordinate between Windows (top-down) and Mac (bottom-up) 
coordinate systems (works either way round)
float WCLMapScreenY (float y)
{
NSRect r = [[NSScreen mainScreen] frame];
y = r.size.height + r.origin.y - y;
return y;
}

I tested my multiple-monitor support by plugging an external monitor into the 
back of my 2009 MacBook.  Note that the menu isn't necessary located on the 
primary screen; ditto the dock.

> NSMenu *newmenu(unsigned char *menuname)
> {
> NSMenu *themenu;
> NSString *mystring;
> char tempstring[256];
> 
> pstr2cstr(menuname, tempstring);
> mystring = [NSString stringWithUTF8String:tempstring];
> themenu = [[NSMenu alloc] initWithTitle:mystring];
> [themenu setAutoenablesItems:NO];
> [mystring release];
> return(themenu);
> }

You should not be releasing mystring. [NSString stringWithUTF8String:] will 
autorelease it, as the memory management guidelines make clear.  You are doing 
the right thing with themenu (i.e. not autoreleasing it) because your method 
has 'new' in the name.  The caller of this method is therefore responsible for 
the object's ultimate disposal.  setmenuitemtext contains a similar error.  To 
catch problems like this early, enable 'zombies' (but not when checking for 
leaks!!):

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

Paul Sanders.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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 I get a file reference w/o relying on the path?

2010-04-25 Thread Brad Stone
SOLVED

This works just as it should.  For reasons that I thought were valid at the 
time (I no longer think so) I had this code in writeSafelyToURL: right after 
the writeTofile: command.  What was strange was the url was valid because I was 
storing the bookmark after the file was successfully written to the hard drive 
but I guess there wasn't enough information in the file yet to make a valid 
reference (bookmark).  I moved it farther down the line with the exact same 
code and everything worked fine.

Thank you for all your help.


On Apr 18, 2010, at 10:43 PM, Noah Desch wrote:

> 
> Are you sure the data is being stored into your "note" dictionary correctly? 
> Here is my bookmark resolution code, it looks almost exactly like yours. I'm 
> running on 10.6.3 and building for 10.6 with GC off.
> 
> 
> - (NSURL *)resolveBookmarkData:(NSData *)bookmark 
> withOptions:(NSURLBookmarkResolutionOptions)options needsUpdate:(BOOL *)stale
> {
>   NSURL *url;
>   NSError *error;
>   NSMutableDictionary *userInfo;
>   
>   error = Nil;
>   *stale = NO;
>   url = [NSURL URLByResolvingBookmarkData:bookmark options:options 
> relativeToURL:Nil bookmarkDataIsStale:stale error:&error];
>   if ( url ) {
>   return url;
>   }
>   
>   if ( error && [[error domain] isEqualTo:NSCocoaErrorDomain] && [error 
> code] == NSFileNoSuchFileError ) {
>   // error presentation and resolution code follows...
> 
> 
> 
> 
> -Noah
> 
> 
> 
> On Apr 18, 2010, at 10:08 PM, Brad Stone wrote:
> 
>> The error comes back "file does not exist" and the NSLog statement shows 
>> "url = (null)" after I change the name of the file in the Finder.  If I 
>> change the file name back to what it was when the bookmark was saved the 
>> file opens fine.  I changed my creation option to 0.  No difference.
>> 
>> NSData *bookmarkData = [note valueForKey:@"bookmarkData"];
>>  NSError *error = nil;
>>  BOOL isStale;
>>  NSURL *url = [NSURL URLByResolvingBookmarkData:bookmarkData 
>> options:0 relativeToURL:nil bookmarkDataIsStale:&isStale error:&error];
>>  NSLog(@"url = %@", [url description]);
>>  
>>  if (error != nil) {
>>  [NSApp presentError:error];
>>  }
>> 
>> 
>> On Apr 18, 2010, at 11:45 AM, Noah Desch wrote:
>> 
>>> 
>>> On Apr 18, 2010, at 10:43 AM, Brad Stone wrote:
>>> 
 I'm storing the bookmark data in an array displayed in a table:
 NSData *bookmarkData = [inAbsoluteURL 
 bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile 

 includingResourceValuesForKeys:nil

 relativeToURL:nil
error:&error];
>>> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev%40softraph.com
> 
> This email sent to cocoa-...@softraph.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: NSTableview background image for column?

2010-04-25 Thread Kyle Sluder
On Apr 24, 2010, at 12:52 PM, Izak van Langevelde   
wrote:


The table shows a so-called 'exposure sheet' for an animation, where  
each row corresponds to one frame, and the columns correspond to the  
various foreground and background animation layers. There is one  
column for audio, and for synchronization purposes it is nice to  
show a wave form of the audio. However, the waveform is fixed, i.e.  
not editable, so adding and deleting table rows only affects the  
position fn table rows with respect to the audio: the audio is  
background, both as audio and as picture. Columns are not sortable,  
although it would be nice to be able to reorder them.


It sounds like you're going for something similar to what you'd see if  
you looked at a reel of 8mm film.


Since at some point you have to generate the entire waveform as one  
image, I'd probably use a custom NSCell subclass in the appropriate  
column, and point it at the NSImage that contains your waveform. Then  
when the tableview goes to draw that cell in a row (I believe the  
delegate method informing you of this is called - 
tableView:willDisplayCell: or something similar) I'd poke the cell to  
tell it what offset into the image it should draw. The cell's drawing  
method would then draw the subset of the waveform image.


This avoids the problem you describe of creating tons of image slices;  
there's only one NSImage object but your cells are smart enough to  
share it and only draw the relevant parts when asked.


HTH,
--Kyle Sluder
___

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

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

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

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


Re: UIResponder Woes

2010-04-25 Thread Dylan Copeland
Hi Fritz,

Thanks for the detailed response and sorry for my incorrect posting. This is 
the first time I've ever used a mailing list, heh. The last paragraph in your 
response seems to sum up what I was trying to do exactly. After playing with 
this all day, it looks like you are indeed correct, and "every so often" is all 
I'm going to be able to get. I'm going to add some math to perform some curve 
fitting to concur my problem.

Thanks again for the great response!

-- Dylan Copeland

On Apr 22, 2010, at 8:47 PM, Fritz Anderson wrote:

> On 22 Apr 2010, at 8:18 AM, Dylan Copeland wrote:
> 
>> I have a UIView subclass that overrides UIResponder's touchesMoved: message. 
>> I've noticed that when I swipe my finger very quickly across the UIView, my 
>> touchesMoved: message only gets called every so often and not constantly 
>> getting messaged.
> 
> You are, of course, apologetic about posting an entire digest to the list. 
> Remember to keep up the subject line.
> 
> What user-visible behavior are you trying to produce? "Every so often" seems 
> to mean not often enough for you, but it would help to know, "not often 
> enough for what?" Are you expecting to be notified of every pixel's worth of 
> movement, no matter how little time comes between?
> 
> Back-of-the-envelope math: A fast swipe across the face of an iPhone may take 
> 1/10 of a second, or 3200 pixels per second, or 312.5 microseconds per pixel. 
> I suppose the screen refreshes 60 times a second, or every 16700 µs, which 
> means the pixel movements are piling up 53 times faster than anything you can 
> do to represent them on screen (even granting that your code can do any 
> worthwhile graphical work in its share of 312 µs).
> 
> So somebody — you or the OS — has to aggregate touch movements. You can't 
> always get the smallest quantum of movement, so strictly speaking, "every so 
> often" is all you can expect. The question then is: Is that often enough? And 
> for what?
> 
> I've heard people raising this sort of question about drawing programs. They 
> had hoped to be notified of every pixel, so all they'd have to do is blit the 
> brush tip onto the screen at each event. Can't do it; even desktop mouse 
> movements get aggregated. If they wanted to do it, they had to calculate the 
> straight line between the reported positions, and draw the brush tip at every 
> pixel.
> 
>   — F
> 

___

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

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


ABAddressBookRef question

2010-04-25 Thread David F.
Does an ABAddressBookRef remain valid after the AddressBook that it came from 
is released?

Let's say I have a little object that holds onto an address:

@interface AddressInfo : NSObject {
ABRecordID contactRecordID;
ABMultiValueIdentifier addressID;
}
@end

Now let's say I want to open an ABPersonViewController to edit the address.  
Can I  get the ABAddressBookRef of the person, release the address book and 
show the ABPersonViewController (as in Code Sample 1) or does the address book 
need hang around (as in Code Sample 2)?

--Code Sample 1--
// self.address is an AddressInfo instance
ABAddressBookRef addressBook = ABAddressBookCreate();
ABPersonViewController *personView = [ABPersonViewController new];
personView.personViewDelegate = self;
personView.displayedPerson =
ABAddressBookGetPersonWithRecordID(addressBook, 
self.address.contactRecordID);
personView.displayedProperties =
[NSArray arrayWithObject: [NSNumber numberWithInt: 
kABPersonAddressProperty]];
personView.allowsEditing = TRUE;
[self.navigationController pushViewController: personView animated: 
TRUE];
CFRelease(addressBook);
[personView release];

--Code Sample 2--
// self.address is an AddressInfo instance
ABAddressBookRef addressBook = ABAddressBookCreate();
ABPersonViewController *personView = [ABPersonViewController new];
personView.personViewDelegate = self;
personView.addressBook = addressBook;
personView.displayedPerson =
ABAddressBookGetPersonWithRecordID(addressBook, 
self.address.contactRecordID);
personView.displayedProperties =
[NSArray arrayWithObject: [NSNumber numberWithInt: 
kABPersonAddressProperty]];
personView.allowsEditing = TRUE;
[self.navigationController pushViewController: personView animated: 
TRUE];
CFRelease(addressBook);
[personView release];

Thanks,
David F.

___

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

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


Newbie Q (Distributed Objects)

2010-04-25 Thread Chris Eccles
Hello

I am relatively new to Cocoa but learning fast.
I have a specific problem which I hope may be answered by the
expertise on this forum.

I cannot seem to get a 'client' app to make a connection to a vended
object in a 'server' app across my LAN. The relevant code in my 'server' app
is:

- (void)awakeFromNib {

// create the comms port for receiving
port = [[[NSSocketPort alloc] initWithTCPPort:6] retain];
NSLog(@"Socket Port = %@", [port address]);

// set up, retain and register the connection
connection = [[[NSConnection alloc] initWithReceivePort: port sendPort:
port] retain];

[connection setRootObject:self];
[connection registerName: @"medix"];



NSLog(@"Connection = %@", connection);

}

This seems to work fine. The port is open and the NSLog confirms the
structure of the connection.

The problem lies in my 'client' code (I think):

- (void)awakeFromNib {

// set up and retain connection
connection = [[NSConnection connectionWithRegisteredName:@"medix"
host:@"192.168.1.2"]
retain];

NSLog(@"Connection Setup %...@\n\n\n", connection);

remObject = [connection rootProxy];

NSLog(@"Connection Setup %...@\n\n\n", remObject);

[remObject retain];

}

.. which refuses to connect and which does NOT display the remObject
as having been found and assigned in NSLog, but simply (null).

Am I doing something so obviously crazy that I can't see it ? ?

Thanks in advance

Chris
___

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

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


Not use of push-bottom method

2010-04-25 Thread Affonso Beato
Hi,

I developed a Stereo Depth Calculator for filming in 3D, using formulas on
an Excel Spreadsheet.
Now I am trying to adapt it to Mac OSX using Xcode and Coccoa.
I don't have much experience on it, but I could program my inputs,
processing the trigonometric formulas, etc. using the push-bottom method.
I would like to know which method I should use to accomplish the same not
using the push-bottom, but having the calculated answers showing in an
output after input a new value in an input cell and pressing return.

Thanks

Beato
___

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

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

2010-04-25 Thread Charles Srstka
On Apr 25, 2010, at 8:44 AM, Bill Appleton wrote:

> 4) how do you guys check for memory leaks in the cocoa objects? when i
> delete a menu... do i have to delete the individual items?

The best thing to do is to read Apple’s Memory Management Guide, which will 
clear up a lot of things related to Cocoa memory management.

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

In a nutshell (and this is a simplistic generalization, so there are a few 
exceptions, but this covers the majority of cases):

1. If you used -alloc, -new, -retain, or -copy, or if you used a method 
starting with one of those (i.e. allocWithSomething:, newWithSomething:, etc.), 
you need to release the object when you’re done.

2. If you used some other method to get the object that doesn’t involve one of 
the above, for example -[NSString stringWithSomething:], then you don’t need to 
worry about releasing it.

3. When you get an object and store it as an instance variable, you should send 
-retain to it to make sure it sticks around at least as long as your object 
does, and then send -release (or -autorelease) when you’re done with it.

4. If you have a method that returns an object and doesn’t follow the naming 
convention in #1, you need to send -autorelease to the object before returning 
it, so that the caller doesn’t have to worry about releasing it.

In the case of the menus, all you need to be aware of is that if you create a 
menu item using -[[NSMenuItem alloc] initWithTitle:action:keyEquivalent:], then 
you should either autorelease it before giving it to an NSMenu, or release it 
after you give it. The NSMenu will retain the object so that it stays alive, 
and when you delete the menu, it will release all the individual items, so that 
if the menu is the only object that has them retained, they will be deleted.

Finally, to actually answer your question: To check for memory leaks, look at 
the Instruments application in the /Developer/Applications folder. It’s really 
powerful and gives you access to a lot of different tests for testing 
performance and memory leaks.

Charles___

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

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

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

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


Re: NSApplicationMain question

2010-04-25 Thread Charles Srstka
On Apr 25, 2010, at 6:00 PM, Klaus Backert wrote:

> On 25 Apr 2010, at 22:28, Charles Srstka wrote:
> 
>> The best thing to do is to read Apple’s Memory Management Guide, which will 
>> clear up a lot of things related to Cocoa memory management.
>> 
>> http://developer.apple.com/mac/library/documentation/cocoa/conceptual/MemoryMgmt/MemoryMgmt.html
>> 
>> In a nutshell (and this is a simplistic generalization, so there are a few 
>> exceptions, but this covers the majority of cases):
> ...
> 
> Now I'm really curious what will happen to you, poor man ;-)
> 
> Reformulating the Memory Management Guide is not allowed. There have been 
> again and again statements about this made by the mailing list moderator and 
> by other Apple employees.
> 
> May the Flying Spaghetti Monster help you ;-)

Oh, apologies. I didn’t mean to cause offense.

Scratch that then, and simply refer to the memory management guide.

Charles___

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

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

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

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


Re: Can't set a cursor on a programmatically created window

2010-04-25 Thread David Preece
Hi Sean,

Sorry I am so tardy...

On 23/04/2010, at 8:49 AM, Sean McBride wrote:
> Does it work if you don't use NSBorderlessWindowMask?

Sadly, no. Will continue to research

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


iPad Programming Tutorial

2010-04-25 Thread ML
Hi All,

Does anyone know of a resource that helps understand how to NOT use interface 
builder for developing applications? 

I am trying to create a iPad SplitView application and I dont quite understand 
if I want to put code to create additional interface elements in: - 
(void)configureView or - (void)viewDidLoad

Say I wanted to add a UITextView and display it.

Wouldn't I do something like:

CGRect bounds = [[UIScreen mainScreen] applicationFrame];

UITextView *theTextView = [[UITextView alloc] initWithFrame:bounds];
[theTextView setContentView:theTextView];
[theTextView makeKeyAndOrderFront:nil];
[theTextView makeFirstResponder:theTextView];

[theTextView show];

But I dont know if it displays, I was thinking that maybe this is something to 
do with that fact the project uses Interface Builder and I dont want to.

-ML
___

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

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

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

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


Re: iPad Programming Tutorial

2010-04-25 Thread Rick Mann
I can't stress enough how much better it is to use IB.

Having said that, a view created entirely programmatically is done in 
-loadView. You must implement that in your view controller subclass.

If you do load a NIB but want to create additional views, do that in 
viewDidLoad.

-- 
Rick

On Apr 25, 2010, at 19:01:49, ML wrote:

> Hi All,
> 
> Does anyone know of a resource that helps understand how to NOT use interface 
> builder for developing applications? 
> 
> I am trying to create a iPad SplitView application and I dont quite 
> understand if I want to put code to create additional interface elements in: 
> - (void)configureView or - (void)viewDidLoad
> 
> Say I wanted to add a UITextView and display it.
> 
> Wouldn't I do something like:
> 
> CGRect bounds = [[UIScreen mainScreen] applicationFrame];
>   
> UITextView *theTextView = [[UITextView alloc] initWithFrame:bounds];
> [theTextView setContentView:theTextView];
> [theTextView makeKeyAndOrderFront:nil];
> [theTextView makeFirstResponder:theTextView];
>   
> [theTextView show];
> 
> But I dont know if it displays, I was thinking that maybe this is something 
> to do with that fact the project uses Interface Builder and I dont want to.
> 
> -ML
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/rmann%40latencyzero.com
> 
> This email sent to rm...@latencyzero.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