Re: Masking UIImages (yes, again)

2011-06-27 Thread Gustavo Pizano
I was on the same boat a few weeks ago and I wanted to ask something similar 
but I completely forgot.

I was trying to mask an image with a mask image created from a bezier path, the 
idea was that I created my bezier path  then I fill EO the path so the part 
that was supposed to mask I left it of white color and the rest was black, then 
I created an image from that path using the UIGpraphicContext methods.  The 
image was created successfully,  then I created the mask form that image 
passing the bits per row, etc,  and when I apply the mask to the image I wanted 
to mask I left all fine expect the part that was supposed to mask (and leave 
transparent), this part was black.


After checking everything and realizing all was ok, I desisted on using CG and 
used instead CALayer, I set the contents to the mask image and then CALayer has 
a mask method that seemed to work fine.  But I really wanted to make it work 
with CG. :(

Gustavo
 

On Jun 27, 2011, at 1:03 AM, Luke Hiesterman wrote:

 
 
 On Jun 26, 2011, at 3:06 PM, James Miller jmiller3...@gmail.com wrote:
 
 I've been reading and experimenting and browsing and reading and 
 experimenting but mostly failing miserably here and I need to ask the hive 
 mind for some assistance.
 
 In a nutshell, I'm just trying to take a range of white colors out of a 
 UIImage and make those colors transparent. From what I've read, I shouldn't 
 use PNGs with an alpha already defined, but I also shouldn't use JPGs 
 because they don't have an alpha channel.
 
 Where did you read that you shouldn't use PNGs with alpha?
 
 
 So I've been trying to the extract the UIImage's CGImage and then convert it 
 from RGB to RGBA and THEN mask it with CGImageCreateWithMaskingColors with 
 no success (transparent areas appear as black). I've tried various 
 techniques involving CGBitmapContextCreate and CGImageCreate but with no 
 luck.
 
 Note that if you did successfully make parts of your image transparent, they 
 would show up as black if drawn into an opaque context. How are you 
 drawing/displaying the image?
 
 Luke
 
 
 This can't POSSIBLY be as complicated as I'm making this out to be! Can 
 someone please show me how to do this properly!?
 
 A thousand thank yous and a pet herring named after you!
 
 --James
 
 
 
 
 The world is divided into people who do things and people who get the 
 credit. Try, if you can, to belong to the first class. There's far less 
 competition.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com
 
 This email sent to luket...@apple.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/gustavxcodepicora%40gmail.com
 
 This email sent to gustavxcodepic...@gmail.com

___

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

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

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

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


Re: NSURLConnection

2011-06-27 Thread R
Thanks to all on the learning curve

On Jun 26, 11:12 pm, Tito Ciuro tci...@mac.com wrote:
 Hello,

 If you have access to the Developer Forums, check the very first entry in 
 Core OS named Five Reasons Why Synchronous Networking Is Bad, by Apple's 
 Quinn The Eskimo!:

 https://devforums.apple.com/thread/9606?tstart=0

 Cheers,

 -- Tito

 On Jun 26, 2011, at 9:51 PM, Jerry Krinock wrote:







  On 2011 Jun 26, at 09:52, Fritz Anderson wrote:

  Synchronous network operations are almost always a bad idea. …, …, …, …,

  and the error object that you get from 
  -sendSynchronousRequest:returningResponse:error: if it fails is quite 
  nondescript.

  ___

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

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

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

  This email sent to tci...@mac.com

 ___

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

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

 Help/Unsubscribe/Update your 
 Subscription:http://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev-garchive-9...

 This email sent to cocoa-dev-garchive-98...@googlegroups.com
___

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

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

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

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


RE: MFMailComposeViewController: referencing attached data in HTML body

2011-06-27 Thread Pierre Fournier

Great,  thanks Heath.
 Date: Sun, 26 Jun 2011 21:23:02 -0500
 From: heath.bord...@gmail.com
 To: cocoa-dev@lists.apple.com
 Subject: Re: MFMailComposeViewController: referencing attached data in HTML   
 body
 
 You could base64 your image data and use a data url to refer to it
 within your HTML. Then, you wouldn't have to attach it.
 
 
 -Heath Borders
 heath.bord...@gmail.com
 Twitter: heathborders
 http://heath-tech.blogspot.com
 
 
 
 On Sun, Jun 26, 2011 at 6:14 PM, Pierre Fournier shir...@hotmail.com wrote:
 
  Hi,is there a way to reference the attached data within the HTML 
  body?[mailController addAttachmentData:pngDataFooter  mimeType:@image/png 
  fileName:@footer.png];[mailController setMessageBody:@htmlbodyimg 
  src=\footer.png\/body/html isHTML:TRUE];When running such code, I 
  get a blue question mark instead of the image, while the image is correctly 
  attached.I want to kind of compose an html email based of different images. 
   
  ___
 
  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
  Please do not post admin requests or moderator comments to the list.
  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
  Help/Unsubscribe/Update your Subscription:
  http://lists.apple.com/mailman/options/cocoa-dev/heath.borders%40gmail.com
 
  This email sent to heath.bord...@gmail.com
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/shirm01%40hotmail.com
 
 This email sent to shir...@hotmail.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


-(id)init methods, NSExceptions, and returning nil

2011-06-27 Thread William Squires
The favored form for writing an init method seems to be

-(id)init
{
if (self = [super init])
  {
  // Do something here
  }
return self;
}

Several questions arise:
1) Isn't the 'if' superfluous? if self was nil (after the assignment from 
[super init]), any messages sent (in the commented section) to it would do 
nothing. The real problem would be if you accessed the instance variables 
directly to initialize them to some non-zero value.

2) Isn't the prevailing paradigm to raise an NSException if something goes 
wrong? In which case, maybe the above code should be more like:

-(id)init
{
if (!(self = [super init]))
  {
  // Raise an NSException here
  }
// Do initializations here
return self;
}

or is 'init'ing a special case?

What if I have an init method, and - in the above '// Do something here' 
section - my initializations fail (maybe a resource can't be located/loaded) - 
should I raise an NSException, or set self=nil so that any subclasses will get 
a nil when they call my class' init through the [super init] part?

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: -(id)init methods, NSExceptions, and returning nil

2011-06-27 Thread Roland King

On 27-Jun-2011, at 9:22 PM, William Squires wrote:

 The favored form for writing an init method seems to be
 
 -(id)init
 {
 if (self = [super init])
  {
  // Do something here
  }
 return self;
 }

actually I think the current favoured method is

-(id)init
{
self = [ super init ];

if( self )
{
// your code here
}

return self;
};

 
 Several questions arise:
 1) Isn't the 'if' superfluous? if self was nil (after the assignment from 
 [super init]), any messages sent (in the commented section) to it would do 
 nothing. The real problem would be if you accessed the instance variables 
 directly to initialize them to some non-zero value.
 

And that's usually the case, either you are setting instance variables or 
calling some other object methods on other objects, so, no, you usually use the 
if() to avoid that code entirely and fast-fail right out of the method. 


 2) Isn't the prevailing paradigm to raise an NSException if something goes 
 wrong? In which case, maybe the above code should be more like:
 
 -(id)init
 {
 if (!(self = [super init]))
  {
  // Raise an NSException here
  }
 // Do initializations here
 return self;
 }
 
 or is 'init'ing a special case?

init returning nil on error is the usual paradigm. For instance it's used in 
that code above, if( self ), indicates that if the superclass init failed and 
it returned nil, so the subclass then returns nil. 


 
 What if I have an init method, and - in the above '// Do something here' 
 section - my initializations fail (maybe a resource can't be located/loaded) 
 - should I raise an NSException, or set self=nil so that any subclasses will 
 get a nil when they call my class' init through the [super init] part?
 

return nil would be normal. If the original caller of alloc/init can't continue 
without this object, it should raise an exception or attempt some kind of 
recovery when it receives nil. It is your application and code however so if 
you want to raise an exception in some init case you're welcome to do so, but 
that's not particularly usual. Possibly if you had an 
initWithParam:param:param: type method and you supplied parameters which were 
invalid, you might raise an exception there instead of returning nil. 

You should also, in the case you mention, of succeeding [ super init ] and then 
failing in the if(), think about dealloc'ing self and setting it to nil, else 
you are leaking it. There's been quite a lot of conversation about that in the 
past, whether you should call [ super release ] or [ super dealloc ] if your 
initialization code fails, I can see it both ways. 

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: -(id)init methods, NSExceptions, and returning nil

2011-06-27 Thread Ken Thomases
On 27-Jun-2011, at 9:22 PM, William Squires wrote:

 2) Isn't the prevailing paradigm to raise an NSException if something goes 
 wrong?


No.  In Cocoa, exceptions are used to indicate programmer error, not runtime 
failure.  In general, Cocoa isn't exception safe, so if an exception occurs, 
your app should do its best to gracefully shut down, save data (without 
overwriting known-good data, since you can't be sure the app is in a good 
state), with an explanation to the user.

 or is 'init'ing a special case?


-init isn't special with respect to the above convention regarding exceptions, 
but it does have its own conventions.  Among those is that failure is indicated 
by returning nil.

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 arch...@mail-archive.com


Re: -(id)init methods, NSExceptions, and returning nil

2011-06-27 Thread Kyle Sluder
On Mon, Jun 27, 2011 at 6:38 AM, Roland King r...@rols.org wrote:
 The favored form for writing an init method seems to be

 -(id)init
 {
 if (self = [super init])
  {
  // Do something here
  }
 return self;
 }

 actually I think the current favoured method is

 -(id)init
 {
        self = [ super init ];

        if( self )
        {
                // your code here
        }

        return self;
 };

These are equivalent. All you did was move the self assignment out of
the if statement.

I actually prefer to use `if (!(self = [super init])) return nil;`.
Again, it is equivalent.

--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: -(id)init methods, NSExceptions, and returning nil

2011-06-27 Thread Roland King
yes I know it's equivalent, didn't say it wasn't, I said it was the favored 
form, which I remembered from Scott's message a year ago in this thread 


http://www.cocoabuilder.com/archive/cocoa/286849-self-super-init-nil.html#286952

where he said 

This has been, or is being updated.

The suggested pattern is now

- (id)init
{
self = [super init];
if (self)
{

}
return self;
}

All our documentation has been updated to reflect this (even if it 
hasn’t necessarily made it out to the users yet)

ok he said 'suggested', I didn't look up the message until now. I believe 
that's the version all the templates give you and my fingers have eventually 
started doing it this way too. 

Nobody ever did answer the question why Apple prefers that form though, or if 
they did, I sure don't remember the answer. 


On 28-Jun-2011, at 12:30 AM, Kyle Sluder wrote:

 On Mon, Jun 27, 2011 at 6:38 AM, Roland King r...@rols.org wrote:
 The favored form for writing an init method seems to be
 
 -(id)init
 {
 if (self = [super init])
  {
  // Do something here
  }
 return self;
 }
 
 actually I think the current favoured method is
 
 -(id)init
 {
self = [ super init ];
 
if( self )
{
// your code here
}
 
return self;
 };
 
 These are equivalent. All you did was move the self assignment out of
 the if statement.
 
 I actually prefer to use `if (!(self = [super init])) return nil;`.
 Again, it is equivalent.
 
 --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: Problem with setNeedsLayout and layoutSubviews in UIScrollView

2011-06-27 Thread David Duncan
On Jun 26, 2011, at 12:51 PM, Tales Pinheiro de Andrade wrote:

 Well, I used the macro UIDeviceOrientationIsLandscape, I'm assuming that this 
 is for both sides:
 #define UIDeviceOrientationIsPortrait(orientation)  ((orientation) == 
 UIDeviceOrientationPortrait || (orientation) == 
 UIDeviceOrientationPortraitUpsideDown)
 #define UIDeviceOrientationIsLandscape(orientation) ((orientation) == 
 UIDeviceOrientationLandscapeLeft || (orientation) == 
 UIDeviceOrientationLandscapeRight)
 
 So the else only occours when the device is in portrait (being normal or 
 upside down), right?

The problem is that a UIDeviceOrientaiton also includes Unknown, FaceUp and 
FaceDown orientations. Thus !Landscape means Portrait or one of those (ditto 
for !Portrait). A large portion of the time, your likely holding the device in 
FaceUp orientation as far as UIDeviceOrientation is concerned, and thus failing 
your Landscape check.

 So, if scroll view layout during scroll, I cannot do this resizing in 
 layoutSubview, and should do this in shouldAutorotateToInterfaceOrientation 
 method in my controller?

No, you would use -willAnimateAutorotationToInterfaceOrientation:duration: to 
do your layout. But at a higher level, why layout based on orientation in the 
first place? Unless you have specific elements that should not appear in one 
orientation or another (which doesn't seem to be the case from your code) why 
not just layout based on the size of the containing view? You can locally 
determine if it is a portrait or landscape view by comparing width  height in 
many cases.

--
David Duncan

___

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

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

2011-06-27 Thread Nathan Day
OK here is a more detailed explanation of what I am doing

I start downloading the video file with a NSURLConnection

I then implement the received data delegate method like the following.

- (void)connection:(NSURLConnection *)aConnection didReceiveData:(NSData *)aData
{
bytesFetched += aData.length;
if( bytesFetched  kBytesRequiredBeforeStart  !hasCachedData )
// kBytesRequiredBeforeStart = 16
{
[[NSNotificationCenter defaultCenter] 
postNotificationName:kVideoURLCacheHasDataNotification object:self];
hasCachedData = YES;
}
[self.fileHandle writeData:aData];  // this file 
handle is not closed until after the video has finished downloading
}

The fileHandle is created like this

- (NSFileHandle *)fileHandle
{
if( fileHandle == nil )
{
NSError * theError = nil;
cachedURL = [[NSURL fileURLWithPath:[NSTemporaryDirectory() 
stringByAppendingFormat:@/%@, kTempFileName]] retain];
[[NSFileManager defaultManager] 
createFileAtPath:[self.cachedURL path] contents:nil attributes:nil];
fileHandle = [[NSFileHandle 
fileHandleForWritingToURL:self.cachedURL error:theError] retain];
if( fileHandle == nil )
[[NSNotificationCenter defaultCenter] 
postNotificationName:kVideoURLCacheErrorOccuredNotification object:self];
}
return fileHandle;
}

I also have a did finish delegate handling method like this

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
if( hasCachedData == NO )
{
[[NSNotificationCenter defaultCenter] 
postNotificationName:kVideoURLCacheHasDataNotification object:self];
hasCachedData = YES;
}
hasFinishedCaching = YES;
[[NSNotificationCenter defaultCenter] 
postNotificationName:kVideoURLCacheDidFinishLoadingNotification object:self];
}

I then have a method to observer the notification like the following

- (void)videoURLCacheHasDataNotification:(NSNotification *)aNotification
{
[self.videoController play];
}

where the videoController is an instance of MPMoviePlayerController created 
like below, cachedURL is the same one defined above.

- (MPMoviePlayerController *)videoController
{
if( videoController == nil )
{
NSURL   * theURL = self.videoURLCache.cachedURL;
NSLog( @Video URL = '%@', theURL );
videoController = [[MPMoviePlayerController alloc] 
initWithContentURL:theURL];
videoController.shouldAutoplay = NO;
[videoController setFullscreen:NO animated:NO];
videoController.view.autoresizingMask = 
UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight;
videoController.repeatMode = MPMovieRepeatModeOne;
videoController.controlStyle = MPMovieControlStyleEmbedded;
videoController.view.frame = self.videoView.bounds;
[videoView addSubview:self.videoController.view];
}
NSParameterAssert(videoController != nil);
return videoController;
}


Now this work fine in the iPhone simulator but on my actually iPodTouch it 
stops at what I am assuming is 16, (I haven't check this). To get the 
entire video to play on my iPodTouch I have to move the [self.videoController 
play]; to a notification observer for the video did finish loading notification.


On 26/06/2011, at 8:05 PM, Nathan Day wrote:

 I am trying to playback video in my iOS app while I am loading and caching it 
 at the same time. I fetch the video using a NSURLConnection and then store it 
 in a local file, I start video playback of the local video file after a 
 certain number of bytes are received. I have it working great in the 
 simulator, I can start playing the video before I have received all of it, 
 but when I go to run my app on my iPodTouch, I can only seem to play up to 
 the number of bytes I had already received before I started playback. I can 
 only play the entire video if I wait until I have receive the entire file 
 before I start playback. I can also get the video to play completely if I 
 stop the failed attempt with a [video stop] message and then start playing it 
 again, pausing the video only doesn't work.
 
 Has anybody got this working, is it possible.
 
 
 Nathan Day
 Software Engineer
 home page:http://homepage.mac.com/nathan_day/

Nathan Day
Software Engineer
home page:  http://homepage.mac.com/nathan_day/







___

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

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

Help/Unsubscribe/Update your Subscription:

Re: NSBrowser matrix

2011-06-27 Thread Raleigh Ledet
Your instantiating your NSBrowser from a nib file. Try over riding 
- (id)initWithCoder:(NSCoder *)coder

-raleigh

On Jun 26, 2011, at 4:18 AM, Ari Black wrote:

 On 11-06-26 7:04 AM, Fritz Anderson wrote:
 
 On 25 Jun 2011, at 7:05 PM, Ari Black wrote:
 
 @implementation SpecialMatrix
 
 - (id)initWithFrame:(NSRect)frameRect mode:(NSMatrixMode)aMode 
 prototype:(NSCell *)aCell numberOfRows:(NSInteger)numRows 
 numberOfColumns:(NSInteger)numColumns {
int x;
x = 0; // I put a breakpoint here
 
return self;
 }
 
 @end
 
 You don't get to this point, so it's not the problem you have now, but I 
 assume your real code invokes [super initWithFrame:...]?
 
 I hadn't put a call to [super ...] yet as I wanted to verify that my 
 initWithFrame: was being called. Once I get this problem worked out, I will 
 call [super ...].
 
 
 This is in the implementation of the class that controls  the window the 
 browser is in:
 
 - (void)awakeFromNib {
[browser setMatrixClass:[SpecialMatrix class]];
 
[browser loadColumnZero];
 
NSMatrix *matrix = [storyLine matrixInColumn:0];  //- return nil
matrix = [storyLine matrixInColumn:1]; //- returns nil
 }
 
 First step: Break in -awakeFromNib and verify that browser is not nil.
 
 I've tested this and it's not nil. browser is an outlet I created and 
 connected with IB. The NSBrowser works for adding items to all of the columns 
 and I check to make sure that SpecialMatrix is set to be the matrix class in 
 browser after the call to setMatrixClass:
 
 
 Second step: Maybe an NSBrowser doesn't instantiate any matrices until you 
 have responded to browser:numberOfRowsInColumn: with a non-zero value?
 
  — F
 
 That's possible, but I've tested adding items to the columns and 
 SpecialMatrix's initWith...: doesn't get called.
 
 I do want to point out that I'm implementing
 browser:numberOfChildrenOfItem: not browser:numberOfRowsInColumn, does that 
 make a difference?
 
  Thanks!
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/ledet%40apple.com
 
 This email sent to le...@apple.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: Event Objects Return 1-Based Y Coordinate Values

2011-06-27 Thread Raleigh Ledet
Cocoa coordinates are all 0,0 based. If you have a reproducible test case that 
says otherwise, please file a radar and attach it.

-raleigh


On Jun 25, 2011, at 7:59 AM, Richard Somers wrote:

 The Cocoa Drawing Guide states Cocoa event objects return y coordinate 
 values that are 1-based instead of 0-based. Thus, a mouse click on the bottom 
 left corner of a window or view would yield the point (0, 1) in Cocoa and not 
 (0, 0). Only y-coordinates are 1-based.
 
 Why are the y-coordianate values of Cocoa event objects 1-based?
 
 Do most developers simply subtract 1.0 from the y-coordianate value obtained 
 from an event object to make it 0-based before using the x-y-coordinate 
 values?
 
 --Richard
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/ledet%40apple.com
 
 This email sent to le...@apple.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: Event Objects Return 1-Based Y Coordinate Values

2011-06-27 Thread Bill Cheeseman

On Jun 27, 2011, at 1:26 PM, Raleigh Ledet wrote:

 Cocoa coordinates are all 0,0 based. If you have a reproducible test case 
 that says otherwise, please file a radar and attach it.
 
 -raleigh
 
 
 On Jun 25, 2011, at 7:59 AM, Richard Somers wrote:
 
 The Cocoa Drawing Guide states Cocoa event objects return y coordinate 
 values that are 1-based instead of 0-based. Thus, a mouse click on the 
 bottom left corner of a window or view would yield the point (0, 1) in Cocoa 
 and not (0, 0). Only y-coordinates are 1-based.
 
 Why are the y-coordianate values of Cocoa event objects 1-based?
 
 Do most developers simply subtract 1.0 from the y-coordianate value obtained 
 from an event object to make it 0-based before using the x-y-coordinate val


I think the OP misunderstood the document. Although Cocoa coordinates are 
0-based, the 0 point on the Y axis of the screen is just beyond the bottom of 
the screen. That is, if you click at the bottom of the screen, the Y coordinate 
will be 1. 0 is still a valid Y coordinate. I'm not aware that programmers make 
any overall adjustments of coordinates for this. They just remember that the 
bottommost clickable Y coordinate is 0.

-- 

Bill Cheeseman - b...@cheeseman.name

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Event Objects Return 1-Based Y Coordinate Values

2011-06-27 Thread Richard Somers
The documentation matches the behavior. Cocoa event objects do indeed return y 
coordinate values that are 1-based. A mouse click on the bottom left corner of 
a window or view yields the point (0, 1) in Cocoa and not (0, 0).

I recently submitted bug 9639143 on another issue but it has a sample 
application that readily demonstrates this behavior. You are more than welcome 
to check this out yourself. Unless I am doing something horribly wrong, as far 
as I can tell, the documentation does indeed match the behavior so there is 
certainly very little to be gained in submitting a bug report.

If you have not read the documentation I would suggest you do so. It is on page 
49 of the Cocoa Drawing Guide under the heading Converting from Window to View 
Coordinates.

The documentation is very clear on this behavior. The only thing that is left 
unsaid in the documentation is why this unusual behavior exists or what purpose 
it has.

--Richard

On Jun 27, 2011, at 11:26 AM, Raleigh Ledet wrote:

 Cocoa coordinates are all 0,0 based. If you have a reproducible test case 
 that says otherwise, please file a radar and attach it.
 
 -raleigh
 
 On Jun 25, 2011, at 7:59 AM, Richard Somers wrote:
 
 The Cocoa Drawing Guide states Cocoa event objects return y coordinate 
 values that are 1-based instead of 0-based. Thus, a mouse click on the 
 bottom left corner of a window or view would yield the point (0, 1) in Cocoa 
 and not (0, 0). Only y-coordinates are 1-based.
 
 Why are the y-coordianate values of Cocoa event objects 1-based?
 
 Do most developers simply subtract 1.0 from the y-coordianate value obtained 
 from an event object to make it 0-based before using the x-y-coordinate 
 values?
 
 --Richard

___

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

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

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

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


Re: Event Objects Return 1-Based Y Coordinate Values

2011-06-27 Thread Jens Alfke

On Jun 27, 2011, at 11:39 AM, Richard Somers wrote:

 The documentation matches the behavior. Cocoa event objects do indeed return 
 y coordinate values that are 1-based. A mouse click on the bottom left corner 
 of a window or view yields the point (0, 1) in Cocoa and not (0, 0).
 ...
 The documentation is very clear on this behavior. The only thing that is left 
 unsaid in the documentation is why this unusual behavior exists or what 
 purpose it has.

It makes sense to me. Integer coordinates denote the grid lines between pixels, 
not the pixel centers. Likewise, the hot-spot of the cursor is in between 
pixels, not in the center of a pixel. In the case of the default arrow cursor, 
the hot-spot is at the tip of the arrow.

Put that together, and what you get is that if the tip pixel of the arrow 
cursor is positioned over the bottom pixel of the view, the hot-spot is 
actually at y=1.0.

This may seem a little unexpected, but I don’t think most programmers ever 
worry about it. Hit-testing shouldn’t require single-pixel accuracy anyway, so 
I doubt the user would notice if your calculations were a pixel off.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: -(id)init methods, NSExceptions, and returning nil

2011-06-27 Thread Jens Alfke

On Jun 27, 2011, at 6:22 AM, William Squires wrote:

 What if I have an init method, and - in the above '// Do something here' 
 section - my initializations fail (maybe a resource can't be located/loaded) 
 - should I raise an NSException, or set self=nil so that any subclasses will 
 get a nil when they call my class' init through the [super init] part?

If your initializer fails, it should call [self release], so self doesn’t get 
leaked, and return nil. It shouldn’t raise an exception except for some kind of 
assertion failure like an invalid parameter.

(If you do this, your -dealloc method must be prepared to handle a receiver 
that’s been only partially initialized. Usually that’s not an issue since 
instance variables are pre-initialized to nil.)


Kyle Sluder wrote:
 These are equivalent. All you did was move the self assignment out of
 the if statement.
 
 I actually prefer to use `if (!(self = [super init])) return nil;`.
 Again, it is equivalent.

The original form listed, with the assignment in the ‘if’, will generate a 
compiler warning* suggesting that you might have typed ‘=‘ instead of ‘==‘. 
It’s good practice not to put assignments into conditional/loop expressions, 
because that == vs. = mistake is so easy to make.

—Jens

* At least it will if you have most compiler warnings enabled (e.g. -Wall), 
which IMHO you should.

smime.p7s
Description: S/MIME cryptographic signature
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Event Objects Return 1-Based Y Coordinate Values

2011-06-27 Thread Richard Somers
On Jun 27, 2011, at 1:13 PM, Jens Alfke wrote:

 It makes sense to me. Integer coordinates denote the grid lines between 
 pixels, not the pixel centers. Likewise, the hot-spot of the cursor is in 
 between pixels, not in the center of a pixel. In the case of the default 
 arrow cursor, the hot-spot is at the tip of the arrow.
 
 Put that together, and what you get is that if the tip pixel of the arrow 
 cursor is positioned over the bottom pixel of the view, the hot-spot is 
 actually at y=1.0.
 
 This may seem a little unexpected, but I don’t think most programmers ever 
 worry about it. Hit-testing shouldn’t require single-pixel accuracy anyway, 
 so I doubt the user would notice if your calculations were a pixel off.


This seems like a correct interpretation. Thanks for the insight.

--Richard

___

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

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

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

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


App Delegate method not being called

2011-06-27 Thread koko
Under what conditions or causes would preclude an app delegate meth from being 
called?

At start up in appDidFinishLaunching I log the delegate for reference.

Then I execute a method and at the end of the method I log the delegate again 
for comparison and it checks out.

Now when I click the red close button the app delegate method 
applicationShouldTerminate is not called.

However, if I do not execute the method referenced above 
applicationShouldTerminate is called when clicking the close button.


Where should I look for ?corruption of the deleagate ... or just what.

-koko
 

___

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

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

2011-06-27 Thread Corbin Dunn
I can elaborate why this delay exists. If you have two or more rows selected, 
there is a slight delay so one can double click on all the selected rows and 
perform an action on all of them (ie: open all). After the delay passes with no 
second click (we wait for the double click interval), the original single click 
is an indication to select just that single row.

corbin

On Jun 25, 2011, at 8:39 AM, Andre Masse wrote:

 Double-click speed was at about 80% max. Setting it full speed indeed reduce 
 the delay. It's barely noticeable now.
 
 Thanks for your help,
 
 Andre Masse
 
 
 On 25/06/2011, at 11:34 , Andy Lee wrote:
 
 Ah, I didn't read carefully enough. Indeed if I select multiple rows and 
 click one of them, I see a delay that correlates with my double-click 
 setting.
 
 But if your double-click setting is almost full speed (i.e., close to the 
 Fast end in System Preferences) you should see barely any delay. Do you 
 mean you have a long delay or a short delay (meaning you have to click very 
 fast to double-click)?
 
 --Andy
 
 On Jun 25, 2011, at 11:17 AM, Andre Masse wrote:
 
 Are you clicking on one of the selected rows? Clicking on non selected rows 
 doesn't show the delay... My double-click speed is almost at full speed.
 
 Thanks for testing this,
 
 Andre Masse
 
 
 On 25/06/2011, at 10:52 , Andy Lee wrote:
 
 On Jun 25, 2011, at 10:23 AM, Fritz Anderson wrote:
 On 25 Jun 2011, at 9:14 AM, Andre Masse wrote:
 
 Select a couple of rows in a table view then click on one. There's a 
 half a second delay before the selection change to the clicked row. I 
 was trying to find the reason for this delay in my application then 
 tried it in Mail, same behavior... Can anyone check this on his mac? I 
 may have some background app messing up...
 
 A click may signify a selection or the beginning of a drag. The table has 
 to wait to see which it will be.
 
 I thought the same thing but I set my double-click speed to be as slow as 
 possible and couldn't reproduce the delay.
 
 --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/corbind%40apple.com
 
 This email sent to corb...@apple.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


How Do I get informed when -showHelp: has been called?

2011-06-27 Thread Ulf Dunkel
In a simple app of mine, I use the standard Help menu and MyApp Help 
menu item, which is bound to -showHelp:.


I would like to have my AppDelegate being informed when the Help Viewer 
has been launched and opened from this menu item.


It seems as if the method -showHelp: cannot be overridden. Which other 
way can I use to receive any information when -showHelp: has been called?


TY in advance,
---Ulf Dunkel
___

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

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

2011-06-27 Thread Jens Alfke

On Jun 27, 2011, at 12:48 PM, koko wrote:

 Now when I click the red close button the app delegate method 
 applicationShouldTerminate is not called.

So, by default closing the window wouldn’t quit the app. If it is, that implies 
that your delegate also has a -applicationShouldTerminateAfterLastWindowClosed: 
method, that is returning YES. You might set a breakpoint there and see that 
it’s returning the correct value.

 However, if I do not execute the method referenced above 
 applicationShouldTerminate is called when clicking the close button.

If that method opened another window somehow, then closing your main window 
would not cause the app to terminate, because it wouldn’t be the last window.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

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

2011-06-27 Thread Jerry Krinock

On 2011 Jun 27, at 12:48, koko wrote:

 Where should I look for ?corruption of the deleagate ... or just what.

You could set a breakpoint on -[NSApplication setDelegate:]


___

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

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

2011-06-27 Thread koko

On Jun 27, 2011, at 3:10 PM, Jens Alfke wrote:

 
 On Jun 27, 2011, at 12:48 PM, koko wrote:
 
 Now when I click the red close button the app delegate method 
 applicationShouldTerminate is not called.
 
 So, by default closing the window wouldn’t quit the app. If it is, that 
 implies that your delegate also has a 
 -applicationShouldTerminateAfterLastWindowClosed: method, that is returning 
 YES. You might set a breakpoint there and see that it’s returning the correct 
 value.

The App has only one window and no method 
applicationShouldTerminateAfterLastWindowClosed
 
 
 However, if I do not execute the method referenced above 
 applicationShouldTerminate is called when clicking the close button.
 
 If that method opened another window somehow, then closing your main window 
 would not cause the app to terminate, because it wouldn’t be the last window.
 

The method make now windows


___

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

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

2011-06-27 Thread koko

On Jun 27, 2011, at 3:18 PM, Jerry Krinock wrote:

 
 On 2011 Jun 27, at 12:48, koko wrote:
 
 Where should I look for ?corruption of the deleagate ... or just what.
 
 You could set a breakpoint on -[NSApplication setDelegate:]

In the Breakpoint Window I entered [NSApplication setDelegate:] 

It is never called.

The App Delegate is wired up in IB



 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/koko%40highrolls.net
 
 This email sent to k...@highrolls.net
 

___

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

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

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

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


Re: [SOLVED] App Delegate method not being called

2011-06-27 Thread koko

I overlooked -windowShouldClose returning the wrong value.

Excuse the noise ... -koko



On Jun 27, 2011, at 4:11 PM, koko wrote:

 
 On Jun 27, 2011, at 3:18 PM, Jerry Krinock wrote:
 
 
 On 2011 Jun 27, at 12:48, koko wrote:
 
 Where should I look for ?corruption of the deleagate ... or just what.
 
 You could set a breakpoint on -[NSApplication setDelegate:]
 
 In the Breakpoint Window I entered [NSApplication setDelegate:] 
 
 It is never called.
 
 The App Delegate is wired up in IB
 
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/koko%40highrolls.net
 
 This email sent to k...@highrolls.net
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/koko%40highrolls.net
 
 This email sent to k...@highrolls.net
 

___

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

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

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

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


NSPersistentDocument and custom window controller

2011-06-27 Thread Philip Dow
I am exploring using a custom window controller for a core data document based 
application and wanted to ask those more knowledgeable than myself if there are 
any caveats I must consider.

Following the documentation, I am overriding NSDocument's makeWindowControllers 
method in my NSPersistentDocument subclass and am initializing the window 
controller here before calling addWindowController. Everything works as 
expected in a simple trial run.

The critical difference is that I am not using my document subclass as the 
window controller's owner, and neither will my document subclass be the 
window's delegate. I am pursuing this route because the custom window 
controller is based on existing code which I am integrating into my application 
and which requires that the window controller itself be the nib owner and 
window delegate.

My concern is that I will lose some built-in essential functionality if the 
persistent document assumes that it is the owner of the nib file and the window 
delegate. I don't know that it does, which is why I'm checking here. An example 
is the undo functionality which is normally provided by the managed object 
context in a persistent document.

Does the persistent document framework make any assumptions about the 
persistent document normally owning its nib file and acting as its window 
delegate which I must make up for when using a custom window controller that 
takes over these two roles?

~Phil___

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

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

2011-06-27 Thread Quincey Morris
On Jun 27, 2011, at 15:58, Philip Dow wrote:

 I am exploring using a custom window controller for a core data document 
 based application and wanted to ask those more knowledgeable than myself if 
 there are any caveats I must consider.
 
 Following the documentation, I am overriding NSDocument's 
 makeWindowControllers method in my NSPersistentDocument subclass and am 
 initializing the window controller here before calling addWindowController. 
 Everything works as expected in a simple trial run.
 
 The critical difference is that I am not using my document subclass as the 
 window controller's owner, and neither will my document subclass be the 
 window's delegate. I am pursuing this route because the custom window 
 controller is based on existing code which I am integrating into my 
 application and which requires that the window controller itself be the nib 
 owner and window delegate.
 
 My concern is that I will lose some built-in essential functionality if the 
 persistent document assumes that it is the owner of the nib file and the 
 window delegate. I don't know that it does, which is why I'm checking here. 
 An example is the undo functionality which is normally provided by the 
 managed object context in a persistent document.
 
 Does the persistent document framework make any assumptions about the 
 persistent document normally owning its nib file and acting as its window 
 delegate which I must make up for when using a custom window controller that 
 takes over these two roles?

Nope, what you're proposing is perfectly normal. It's within NSDocument's 
intended behavior that a NSWindowController should take over the role of being 
the window nib's File's Owner. All you need to do is have your 
NSWindowContoller subclass' init method use [super initWithNibName:] -- or, 
what is the same thing, [super initWithNibName: ... owner: self] -- and 
NSDocument bows out of the nib picture.

The fact that it's really a NSPersistentDocument isn't important. This part of 
the behavior comes directly from NSDocument. Undo (in the sense of its 
relationship to Core Data) is a data model function, so it doesn't care what 
kind of controller sits between the data model and the user interface.

The only factor I can think of to consider is that the Core Data model and 
managed context come from the document. However, addWindowController: sets the 
window controller's document property to the document object, so you can 
always get to document-based information via windowController.document (once 
nib loading reaches the awakeFromNib point, that is).


___

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

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

2011-06-27 Thread Philip Dow

On Jun 27, 2011, at 6:17 PM, Quincey Morris wrote:

 On Jun 27, 2011, at 15:58, Philip Dow wrote:
 
 I am exploring using a custom window controller for a core data document 
 based application and wanted to ask those more knowledgeable than myself if 
 there are any caveats I must consider.
 
 Following the documentation, I am overriding NSDocument's 
 makeWindowControllers method in my NSPersistentDocument subclass and am 
 initializing the window controller here before calling addWindowController. 
 Everything works as expected in a simple trial run.
 
 The critical difference is that I am not using my document subclass as the 
 window controller's owner, and neither will my document subclass be the 
 window's delegate. I am pursuing this route because the custom window 
 controller is based on existing code which I am integrating into my 
 application and which requires that the window controller itself be the nib 
 owner and window delegate.
 
 My concern is that I will lose some built-in essential functionality if the 
 persistent document assumes that it is the owner of the nib file and the 
 window delegate. I don't know that it does, which is why I'm checking here. 
 An example is the undo functionality which is normally provided by the 
 managed object context in a persistent document.
 
 Does the persistent document framework make any assumptions about the 
 persistent document normally owning its nib file and acting as its window 
 delegate which I must make up for when using a custom window controller that 
 takes over these two roles?
 
 Nope, what you're proposing is perfectly normal. It's within NSDocument's 
 intended behavior that a NSWindowController should take over the role of 
 being the window nib's File's Owner. All you need to do is have your 
 NSWindowContoller subclass' init method use [super initWithNibName:] -- or, 
 what is the same thing, [super initWithNibName: ... owner: self] -- and 
 NSDocument bows out of the nib picture.
 
 The fact that it's really a NSPersistentDocument isn't important. This part 
 of the behavior comes directly from NSDocument. Undo (in the sense of its 
 relationship to Core Data) is a data model function, so it doesn't care what 
 kind of controller sits between the data model and the user interface.
 
 The only factor I can think of to consider is that the Core Data model and 
 managed context come from the document. However, addWindowController: sets 
 the window controller's document property to the document object, so you 
 can always get to document-based information via windowController.document 
 (once nib loading reaches the awakeFromNib point, that is).

Fantastic. Yes, I did discover that I needed a way to pass the managed context 
to other objects such as view controllers which might require it in their turn. 
The code I'm integrating uses other objects in the control layer alongside the 
window controller to create the view controllers which manage the window 
content -- it is a tabs system based on the Chrome code -- and I've subclassed 
that class to pass the managed object context around. It works nicely.

~Phil___

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

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


CocoaTouch; Float Button on UITableView?

2011-06-27 Thread Jeffrey Walton
Hi All,

I have a table view and would like to float a button on top of the
table view. The button is a will function as a refresh, and have a PNG
image.

When I try and place a button on the table in Interface Builder, the
drag/drop is rejected. Can someone point me in the right direction?

Thanks in advance,
Jeff
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: CocoaTouch; Float Button on UITableView?

2011-06-27 Thread Conrad Shultz
This sort of thing is more commonly handled by a button in a toolbar either 
above or below the table. 

Another approach is the drag/release to reload (as seen in some Twitter apps 
for example).

A button partially occluding the table sounds awkward to me, and IB is likely 
trying to block you for just this reason. 

Are you sure you want to do it that way?

(Sent from my iPhone.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Jun 27, 2011, at 19:22, Jeffrey Walton noloa...@gmail.com wrote:

 Hi All,
 
 I have a table view and would like to float a button on top of the
 table view. The button is a will function as a refresh, and have a PNG
 image.
 
 When I try and place a button on the table in Interface Builder, the
 drag/drop is rejected. Can someone point me in the right direction?
 
 Thanks in advance,
 Jeff
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/conrad%40synthetiqsolutions.com
 
 This email sent to con...@synthetiqsolutions.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


Assigning to property with 'readonly' atribute not allowed

2011-06-27 Thread Fernando Aureliano
I' doing the implementation of AQGridView, and everything was going well.

But, now I'm getting the error below.


- (AQGridViewCell *) gridView: (AQGridView *)inGridView cellForItemAtIndex:
(NSUInteger) index;
{
 MagazineCell *cell = (MagazineCell *)[inGridView
dequeueReusableCellWithIdentifier:@cell];
if (!cell) {
 cell = [MagazineCell cell];
*cell.reuseIdentifier = @cell;*
//Assigning to property with 'readonly' atribute not allowed
 }
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = AQGridViewCellSelectionStyleGlow;
  cell.edicaoLabel.text = [[edicoesArray objectAtIndex:index] name];
cell.dataLabel.text = [[edicoesArray objectAtIndex:index] name];
 return cell;
}


I tried to do this on head file

   @property(nonatomic, readwrite) NSString * reuseIdentifier;


I also tried


@property(nonatomic, assign) NSString * reuseIdentifier;


But still no work.

I downloaded de example of project '*Actors for Netflix*'
https://github.com/adrianco/Actors-for-Netflix-on-iPad/

And this code have the same problem when I try to build, and the
pre-processor also see it.

This example dont declare the property on header of class file, I tried it
on my project as an attempt to fix the problem.

Someone can see the what is the problem?

thanks!

-- 
*Fernando Aureliano*
___

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

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