Core Data validateForUpdate

2009-12-20 Thread Gerriet M. Denkmann
I have a document based Core Data app.

MyDocument.nib contains an NSTableView bound to an NSArrayController.
There also are + and - buttons, which send add: resp. remove: to the 
array controller.

SomeEntity.m (subclass of NSManagedObject) implements validateForInsert:, 
validateForUpdate: and validateForDelete: - none of which are ever called. Why?

What I try to accomplish:
SomeEntity has a property called uniqueKey and this is (no big surprise) 
meant to be unique.

When the UniqueKey column in my table view gets edited, 
validateUniqueKey:error: gets called, I check the new value for uniqueness and 
all is fine.

But hitting the + button several times inserts several objects with the same 
key (Default Value).

What should I do? How to make validateForInsert: get called? 10.6.2.


Kind regards,

Gerriet.

___

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

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

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

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


Re: Core Data validateForUpdate

2009-12-20 Thread Mike Abdullah
I think you misunderstand what -validateForInsert: and friends are for. They 
use insert here in the sense of inserting into the persistent store.

So -validateForInsert: is called the first time the object is added to the 
store (calling -[NSManagedObjectContext save:] ). From then on, 
-validateForUpdate: will be called at each save that will modify the object. 
And finally, -validateForDelete: if removing from the store.

On 20 Dec 2009, at 08:19, Gerriet M. Denkmann wrote:

 I have a document based Core Data app.
 
 MyDocument.nib contains an NSTableView bound to an NSArrayController.
 There also are + and - buttons, which send add: resp. remove: to the 
 array controller.
 
 SomeEntity.m (subclass of NSManagedObject) implements validateForInsert:, 
 validateForUpdate: and validateForDelete: - none of which are ever called. 
 Why?
 
 What I try to accomplish:
 SomeEntity has a property called uniqueKey and this is (no big surprise) 
 meant to be unique.
 
 When the UniqueKey column in my table view gets edited, 
 validateUniqueKey:error: gets called, I check the new value for uniqueness 
 and all is fine.
 
 But hitting the + button several times inserts several objects with the 
 same key (Default Value).
 
 What should I do? How to make validateForInsert: get called? 10.6.2.
 
 
 Kind regards,
 
 Gerriet.
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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


passing a method name?

2009-12-20 Thread Chunk 1978
i have a bunch of methods that will call one method.  currently, i'm
passing a string object so the called method will know which method
had called it, and complete the proper task based on the method that
called it.

instead of creating strings and passing them, is it possible to pass
the method 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: passing a method name?

2009-12-20 Thread Graham Cox

On 21/12/2009, at 12:18 AM, Chunk 1978 wrote:

 i have a bunch of methods that will call one method.  currently, i'm
 passing a string object so the called method will know which method
 had called it, and complete the proper task based on the method that
 called it.

Good programming practice encourages the idea that functions and methods are 
complete in and of themselves, and are invariant under different calling 
conditions. Variations should be accomplished using properly passed parameters, 
not information about where the function has been called from. I'd say this 
approach is going to bite you very, very hard if you persist with it. Nobody 
does this in professional programming, and where it is done inadvertently, it 
will usually be rejected and revised when code is peer-reviewed. So you might 
consider this comment part of a peer review.

The only situation this is considered acceptable is when passing a callback or 
completion method, where the called method calls the passed method but no part 
of its internal state depends on it.

 instead of creating strings and passing them, is it possible to pass
 the method name?

You can pass a SEL (selector) type but unless it's for the specific purpose of 
indicating a callback or completion method, I would strongly advise against it.

--Graham


___

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

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

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

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


Re: NSTableview datasource issues

2009-12-20 Thread Alexander Spohr
Did you set a breakpoint on the data source methods?

Please reread about memory management. Your code is full of wrong retains.

Why is segmentDict a global variable? You just assign to it but never release 
it.
segmentIndustry is a class and should be named with a capital S.

segmentIndustryData is always empty. How should it populate your table view?

atze




Am 20.12.2009 um 02:09 schrieb aronis...@afroamerica.net:

 I know this has been discussed before, but I have been going through the 
 issue of reloadData and datasource methods not running. I cannot figure out 
 what is going on with my datasource methods.
 Everything is connected. But when on [segmentTableView reloadData], no 
 datasource method is run.
 After the application was running, I debugged the code and checked the 
 classes of SelectorController and TableSource. They are all connected in 
 runtime.For table view, I only connected it to SelectorController - 
 segmentTableView, and its dataSource to SelectorController - 
 segmentTableView. All of them are connected properly in runtime.In Log, when 
 I print the datasource and delegate of SegmentTableView, it shows 
 SelectorController.
 
 This is troublesome as I have 4 other tables in the same application that are 
 loaded properly through their dedicated datasources.
 It is only in this table that nothing is working. What am I missing? Your 
 help is invaluable.
 
 
 Her is some of the relevant code:
 
 
 // SelectorController.h
 #import Cocoa/Cocoa.h
 @classsegmentIndustry;
 
 
 @interface SelectorController : NSObject {
 NSMutableArray *segmentIndustryData;
 IBOutletNSTableView *segmentTableView;
 IBOutletNSArrayController *segmentDataController;
 
 IBOutletNSButton *stockSelectButton;
 intmodelRS;
 
 }
 
 -(void) insertObject:(segmentIndustry *) s inSectorDataAtIndex:(int)index;
 
 -(IBAction) initializeSectorSegmentData:(id) sender;
 @end
 
 
 
 // SelectorController.m
 
 
 
 #import SelectorController.h
 #import segmentIndustry.h
 #import MyDocument.h
 
 
 NSDictionary *segmentDict;
 
 
 @implementation SelectorController
 
 
 - (id)init
 {
 self = [superinit];
 if (self) {
 
 // Add your subclass-specific initialization here.
 // If an error occurs here, send a [self release] message and return nil.
 segmentDict =[NSMutableDictionarydictionary];
 [segmentDictretain];
 
 }
 return (self);
 }
 - (void)awakeFromNib
 {
 segmentIndustryData=[[NSMutableArrayalloc] init];
 [segmentIndustryDataretain];
 segmentDataController=[[NSArrayControlleralloc] init];
 [segmentDataControllerretain];
 
 
 }
 //Load into TableView in the GUI
 #pragma mark Table view dataSource methods
 
 
 - (int) numberOfRowsInTableView:(NSTableView *) TableView
 {
 return [segmentIndustryDatacount];
 
 }
 
 
 -(id)tableView:(NSTableView *)aTableView
 ObjectValueForTableColumn:(NSTableColumn *)aTableColumn
 row:(int)rowIndex
 {
 
 NSString *identifier =[aTableColumn identifier];
 segmentIndustry *stock =[segmentIndustryDataobjectAtIndex:rowIndex];
 return [stock valueForKey:identifier];
 
 }
 
 
 -(void) tableView:(NSTableView *) aTableView
 setObjectValue:(id)anObject
 forTableColumn:(NSTableColumn *) aTableColumn
 row:(int) rowIndex
 {
 NSString *identifier =[aTableColumn identifier];
 //What stock?
 segmentIndustry *stock =[segmentIndustryDataobjectAtIndex:rowIndex];
 [stock setValue:anObject forKey:identifier];
 
 //Set the value for the attribute named identifier
 }
 
 
 
 
 
 
 
 -(IBAction)initializeSectorSegmentData:(id) sender
 {
 segmentDict=[[MyDocumentgetSectorSegmentData:(id) sender] mutableCopy];
 [segmentDictretain];
 NSWindow *w =[segmentTableViewwindow];
 [wmakeKeyWindow];
 //Fill the table row by row;
 int i=0;
 NSMutableArray *aXtemp;
 if ([segmentIndustryDatacount]0) [segmentIndustryDataremoveAllObjects];
 [[segmentDataControllercontent] removeAllObjects];
 for (idkeyinsegmentDict)
 {
 aXtemp = [NSMutableArrayarrayWithArray:[(NSArray 
 *)[segmentDictobjectForKey:key] mutableCopy]];
 if ([(NSString *) [aXtemp lastObject] intValue]== modelRS) {
 [aXtemp insertObject:(NSString*) keyatIndex:(NSUInteger)1];
 segmentIndustry *s = [[segmentIndustryalloc] init];
 [s setSegName:(NSString *)[aXtemp objectAtIndex:(NSUInteger) 0]];
 [s setSegOther:(NSString *)[aXtemp objectAtIndex:(NSUInteger)1]];
 [s setSegIndustry:(NSString*)[aXtemp objectAtIndex:(NSUInteger)2]];
 [s setSegSector:(NSString *)[aXtemp objectAtIndex:(NSUInteger) 3]];
 // Add it to the content array of 'stockDataController'
 [segmentDataControlleraddObject:s];
 [selfinsertObject: s inSectorDataAtIndex:(int)i];
 ++i;
 }
 }
 
 //Re-sort (in case the user has sorted a column
 [segmentDataControllerrearrangeObjects];
 
 // Get the sorted array
 
 NSArray *a = [segmentDataController arrangedObjects];
 for ( i=0;i[a count];++i) {
 [segmentTableView editColumn:0 row:i withEvent:nil select:YES];
 
 [segmentTableViewreloadData];
 
 }
 
 
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 

Re: Core Data - Importing using NSOperation - Problems on main thread

2009-12-20 Thread Greg Reichow

 Hi,
 
 I have an application that persists its data using core data.  
 
 It uses an NSOperation to download new versions of the data asynchronously.  
 This NSOperation uses its own MOC (moc2) (as opposed to the MOC (moc1) used 
 in the main thread, which is used by the UI).  Both MOCs share the same 
 persistent store which, as I understand it, this is the paradigm recommended 
 by Apple (for using Core with multiple threads).
 
 My problem occurs when the NSOperation is almost complete and deletes all the 
 old Managed Objects (that have been replaced by the new data) performs a 
 [managedObjectContext save:error] with the intent of making the new data 
 available in the other MOC (moc1).  
 
 The old data is deleted using [managedObjectContext 
 deleteObject:objectToDelete] after the new data has been added. 
 
 At the same point in time as the update is taking place, the user may be 
 scrolling through the data in a UITableView (using custom cells populated 
 with data from managed objects in the main thread MOC moc1)).  The heavy 
 lifting is performed by a NSFetchedResultsController - using code similar to 
 that in the Apple CoreDataBooks example
 
 There are a number of problems with this approach  If the user happens to 
 select the view causing the fetched results controller to be initialised 
 
 i.e.  [self.fetchedResultsController performFetch: error]
 
 whilst the NSOperation is deleting the old Managed Objects, and attempts to 
 scroll an exception is thrown in cellForRowAtIndexPath (as the object that it 
 is referring to has just been deleted)
 
 Problems also occur in the fetched results controller delegate methods, where 
 the didChangeObject methods gets called with NSFetchedResultsChangeUpdate 
 instead of NSFetchedResultsChangeDelete if the user is scrolling up and down 
 the list at the same time (though everything works if the user is not 
 scrolling).
 
 Any ideas on how I can avoid these problems, or come up with a more elegant 
 solution?
 

Are you using the contextDidSaveNotification to pass the updates to the main 
thread MOC?  This has worked for me in the exact same case you describe above.

In your NSOperation, you register for the contextDidSaveNotification (for your 
moc2), which calls a method in the NSOperation when it is received that then 
passes back the notification data to a method on the main thread (using 
performSelectorOnMainThread).  This keeps both MOC's in sync.  I think this is 
documented in the Core Data docs.

Greg
___

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

Please do not post admin requests or moderator comments to the list.
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 Simulator auto-rotation touches detection bug?

2009-12-20 Thread Matt Neuburg
On or about 12/19/09 12:08 PM, thus spake Randall Meadows
cocoa-...@not-pc.com:

 On Dec 19, 2009, at 12:53 PM, Matt Neuburg wrote:
 
 The iPhone app I'm currently writing is autorotated at startup (see my
 previous posts on this topic). I've noticed that there's an area about 24
 pixels wide at the left end of the iPhone Simulator screen where I don't
 receive any touches. But the very same app running on my actual device does
 receive touches there. (All of this has been confirmed with extensive
 logging.) Since this width is about the height of the status bar, I'm
 thinking there's a bug in the iPhone Simulator where it fails to move its
 internal idea of where the status bar is in an autorotated-at-startup app.
 Is this a known bug? Naturally I'm considering submitting a bug report...!
 m.
 
 It definitely is a bug, and I'm pretty sure it's known, but it never hurts to
 pile on your vote to increase its importance the the good folks at Apple.
 

Submitted as bug ID# 7488113. I was able to reduce this to a simple project
with about two lines of code. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring  Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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: Core Data validateForUpdate

2009-12-20 Thread Mark Townsend
I think that you want to implement the awakeFrom* methods on NSManagedObject
rather than the validate* methods for your purposes.

But as for them never getting called, make sure that your NSArrayController
bindings are correct.  Specifically that it's mapped to your NSManagedObject
subclass.  Also, check the method signature on your validate* methods.  Do
they return a BOOL and pass in a NSError ** for a parameter?

Cheers,
Mark

---
Mark Townsend
http://www.markltownsend.com


On Sun, Dec 20, 2009 at 4:00 AM, Mike Abdullah cocoa...@mikeabdullah.netwrote:

 I think you misunderstand what -validateForInsert: and friends are for.
 They use insert here in the sense of inserting into the persistent store.

 So -validateForInsert: is called the first time the object is added to the
 store (calling -[NSManagedObjectContext save:] ). From then on,
 -validateForUpdate: will be called at each save that will modify the object.
 And finally, -validateForDelete: if removing from the store.

 On 20 Dec 2009, at 08:19, Gerriet M. Denkmann wrote:

  I have a document based Core Data app.
 
  MyDocument.nib contains an NSTableView bound to an NSArrayController.
  There also are + and - buttons, which send add: resp. remove: to
 the array controller.
 
  SomeEntity.m (subclass of NSManagedObject) implements validateForInsert:,
 validateForUpdate: and validateForDelete: - none of which are ever called.
 Why?
 
  What I try to accomplish:
  SomeEntity has a property called uniqueKey and this is (no big
 surprise) meant to be unique.
 
  When the UniqueKey column in my table view gets edited,
 validateUniqueKey:error: gets called, I check the new value for uniqueness
 and all is fine.
 
  But hitting the + button several times inserts several objects with the
 same key (Default Value).
 
  What should I do? How to make validateForInsert: get called? 10.6.2.
 
 
  Kind regards,
 
  Gerriet.
 
  ___
 
  Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
  Please do not post admin requests or moderator comments to the list.
  Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
  Help/Unsubscribe/Update your Subscription:
 
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
  This email sent to cocoa...@mikeabdullah.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/mltownsend%40gmail.com

 This email sent to mltowns...@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


Customizing NSTableViewHeader

2009-12-20 Thread Gustavo Pizano
Hello, 
After reading some post, and coding my own class, I was able to set up a custom 
glossy background color,  then I realize the title was behind it, so I just 
place it above the background..

So, so far so good.

But now when I click in the header of a column, of course because its a custom 
one, no highlight color appear... (yes the light aqua blue color) and also the 
sort indicator.. all this seems to be under the background..  I have been 
trying to check different approaches like, in the drawRect of the 
CustomNSTableHeaderView method, when sending to draw each column headerCell 
(which are subclasses also), check if the column is selected, of course this 
will work, if I have column selection enable, not my case, I also tried, 
directly in the headerCell, checking if isHiglighted, but always returns NO. So 
unless Im able to know where exactly I can check if the user clicked the column 
header, to place the sort indicator or call the method - 
(void)drawSortIndicatorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView 
ascending:(BOOL)ascending priority:(NSInteger)priority; on the HeaderCell, I 
can't draw the background color for highlighted neither the sort indicator.
I tried also to override, the method :
- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView 
*)controlView

but it was never called.

Any ideas?

Thanks

Gustavo

___

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

Please do not post admin requests or moderator comments to the list.
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 trap uncaught exceptions on Snow Leopard

2009-12-20 Thread Matt Neuburg
On Sat, 19 Dec 2009 13:27:01 +0200, Oleg Krupnov oleg.krup...@gmail.com
said:

Anyway, I have just found that the following code works:

NSExceptionHandler *handler = [NSExceptionHandler defaultExceptionHandler];
 [handler setExceptionHandlingMask:NSLogAndHandleEveryExceptionMask];
 [handler setDelegate:self];

The delegate method DOES get called:

- (BOOL)exceptionHandler:(NSExceptionHandler *)sender
shouldHandleException:(NSException *)exception mask:(unsigned
int)aMask
{ [NSApp reportException:exception];
 return YES;

But this has nothing to do with Snow Leopard. I've got projects going back
many years that use that code. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

Please do not post admin requests or moderator comments to the list.
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: passing a method name?

2009-12-20 Thread Matt Neuburg
On Sun, 20 Dec 2009 08:18:36 -0500, Chunk 1978 chunk1...@gmail.com said:
i have a bunch of methods that will call one method.  currently, i'm
passing a string object so the called method will know which method
had called it, and complete the proper task based on the method that
called it.

instead of creating strings and passing them, is it possible to pass
the method name?

What I do in this situation is pass _cmd. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

Please do not post admin requests or moderator comments to the list.
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


Charisse Marie Napenas/Cebu/Lexmark is out of the office.

2009-12-20 Thread Charisse Marie Napenas
I will be out of the office starting  12/18/2009 and will not return until
01/05/2010.

I will respond to your message when I return.

___

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

Please do not post admin requests or moderator comments to the list.
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: Adding a shadow to a UIImage in a UIImageview

2009-12-20 Thread Development
Ok so after a couple suggestions and rereading the Quartz information on 
shadows I modified my code but it's mostly all redundant since the shadow color 
is whatever the image color is and I cant seem to change that. Anyway Below is 
the code I am trying to use to draw a drop shadow under a UIImage inside of a 
UIImage view and it just isn't working. Sometimes I get a duplicate of the 
image with no color change, sometimes the image is clipped randomly and other 
times the image simply vanishes from the image view: P.S. I realize some of 
this code is useless but as you can see it was based on the apple example code.

UIGraphicsBeginImageContext(self.frame.size);
CGContextRef myContext =  UIGraphicsGetCurrentContext();
CGSize  myShadowOffset = CGSizeMake (5,  10);// 2
float   myColorValues[] = {0, 0, 0, .3};// 3
CGColorRef  myColor;// 4
CGColorSpaceRef myColorSpace;// 5
CGImageRef imgRef = rotatingView.image.CGImage;
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);

CGContextSaveGState(myContext);// 6

CGContextSetShadow (myContext, myShadowOffset, 5); // 7
// Your drawing code here// 8
CGContextSetRGBFillColor (myContext, 0, 1, 0, 1);
   // CGContextDrawImage(myContext, CGRectMake(0, 0, width, height), imgRef);
[rotatingView.image drawInRect:self.frame];
myColorSpace = CGColorSpaceCreateDeviceRGB ();// 9
myColor = CGColorCreate (myColorSpace, myColorValues);// 10
CGContextSetShadowWithColor (myContext, myShadowOffset, 5, myColor);// 11
// Your drawing code here// 12
CGContextSetRGBFillColor (myContext, 0, 0, 1, 1);
//CGContextDrawImage(myContext, CGRectMake 
(width/3-75,height/2-100,width/4,height/4),imgRef);
[rotatingView.image drawInRect:CGRectMake 
(width/3-75,height/2-100,width/4,height/4)];
CGColorRelease (myColor);// 13
CGColorSpaceRelease (myColorSpace); // 14

UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext();
CGContextRestoreGState(myContext);
UIGraphicsEndImageContext();

rotatingView.image = 
imageCopy;___

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

Please do not post admin requests or moderator comments to the list.
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: Core Data - Importing using NSOperation - Problems on main thread

2009-12-20 Thread Nick Banks
Thanks Greg,

Yes I did use the [managedObjectContext save:error], in the same fashion as in 
some of the examples provided by Apple.  Interestingly, I am using the same 
mechanism in a completely unrelated project with no problems, and have studied 
the Core Data documentation for some time.

If I delete an object in the import moc (moc2) will that immediately cause the 
object in moc1 to be deleted also (thus causing problems when referenced by the 
UI i.e. it will no longer exist) or will this only happen when I call 
[managedObjectContext save:error]?

Regards,

Nick

On 20 Dec 2009, at 17:01, Greg Reichow wrote:

 
 Hi,
 
 I have an application that persists its data using core data.  
 
 It uses an NSOperation to download new versions of the data asynchronously.  
 This NSOperation uses its own MOC (moc2) (as opposed to the MOC (moc1) used 
 in the main thread, which is used by the UI).  Both MOCs share the same 
 persistent store which, as I understand it, this is the paradigm recommended 
 by Apple (for using Core with multiple threads).
 
 My problem occurs when the NSOperation is almost complete and deletes all 
 the old Managed Objects (that have been replaced by the new data) performs a 
 [managedObjectContext save:error] with the intent of making the new data 
 available in the other MOC (moc1).  
 
 The old data is deleted using [managedObjectContext 
 deleteObject:objectToDelete] after the new data has been added. 
 
 At the same point in time as the update is taking place, the user may be 
 scrolling through the data in a UITableView (using custom cells populated 
 with data from managed objects in the main thread MOC moc1)).  The heavy 
 lifting is performed by a NSFetchedResultsController - using code similar to 
 that in the Apple CoreDataBooks example
 
 There are a number of problems with this approach  If the user happens to 
 select the view causing the fetched results controller to be initialised 
 
 i.e.  [self.fetchedResultsController performFetch: error]
 
 whilst the NSOperation is deleting the old Managed Objects, and attempts to 
 scroll an exception is thrown in cellForRowAtIndexPath (as the object that 
 it is referring to has just been deleted)
 
 Problems also occur in the fetched results controller delegate methods, 
 where the didChangeObject methods gets called with 
 NSFetchedResultsChangeUpdate instead of NSFetchedResultsChangeDelete if the 
 user is scrolling up and down the list at the same time (though everything 
 works if the user is not scrolling).
 
 Any ideas on how I can avoid these problems, or come up with a more elegant 
 solution?
 
 
 Are you using the contextDidSaveNotification to pass the updates to the main 
 thread MOC?  This has worked for me in the exact same case you describe above.
 
 In your NSOperation, you register for the contextDidSaveNotification (for 
 your moc2), which calls a method in the NSOperation when it is received that 
 then passes back the notification data to a method on the main thread (using 
 performSelectorOnMainThread).  This keeps both MOC's in sync.  I think this 
 is documented in the Core Data docs.
 
 Greg

Nick Banks
Managing Director
Synchromation Ltd.
www.synchromation.com

Office: +33 9 62 60 47 88 (FR)
SkypeIn:+44 20 7193 6114 (UK)
iPhone: +33 6 45 44 54 93 (FR)
iPhone: +44 7763 839 430 (UK)

inline: email logo.png

___

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

Please do not post admin requests or moderator comments to the list.
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: passing a method name?

2009-12-20 Thread Nathan Day
You can pass the hidden parameter _cmd which is of type SEL you can then use 
@selector(selector_name) to do your test, this whole thing you are doing 
sounds really strange, it would be good to see what you are doing to find a 
better approach. based on what little information your are giving us I would be 
sending an enum with each enum describing then option.

On 21/12/2009, at 12:18 AM, Chunk 1978 wrote:

 i have a bunch of methods that will call one method.  currently, i'm
 passing a string object so the called method will know which method
 had called it, and complete the proper task based on the method that
 called it.
 
 instead of creating strings and passing them, is it possible to pass
 the method 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/nathan_day%40mac.com
 
 This email sent to nathan_...@mac.com

Nathan Day
Software Engineer
mobile: +61 (0)4 3863 2407
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: NSTableview datasource issues

2009-12-20 Thread aronisoft
Alexander,
Thanks for your help.
Yes, I set the breakpoint on the data source methods? The datasource methods 
are not reached at all.
I did not give you all the methods in my code (it is too lengthy). segmentDict 
is a global variable because I need it somewhere else.


segmentIndustryData is populated with the method [self insertObject: s 
inSectorDataAtIndex:(int)i] implemented as follows:


-(void) insertObject:(segmentIndustry *) s inSectorDataAtIndex:(int)index
{

//Add the inverse of this operation to the undo stack
NSUndoManager *undo = [[segmentTableView window] undoManager];
[[undo prepareWithInvocationTarget:self] 
removeObjectFromSectorDataAtIndex:index];
if (![undo isUndoing]){
[undo setActionName:@Insert Stock];
}
//Add the stock to Array
[self startObservingSelector:s];
[segmentIndustryData insertObject:s atIndex:index];
}


a dealloc method takes care of releasing the arrays and dictionary. Anyway, 
even without retain, the table doesn't reload data.



I do not think naming is the issue, it is more of the good habit to have.


 Thanks.




-Original Message-
From: Alexander Spohr [mailto:a...@freeport.de]
Sent: Sunday, December 20, 2009 09:52 AM
To: aronis...@afroamerica.net
Cc: cocoa-dev@lists.apple.com
Subject: Re: NSTableview datasource issues

Did you set a breakpoint on the data source methods?Please reread about memory 
management. Your code is full of wrong retains.Why is segmentDict a global 
variable? You just assign to it but never release it.segmentIndustry is a class 
and should be named with a capital S.segmentIndustryData is always empty. How 
should it populate your table view? atzeAm 20.12.2009 um 02:09 schrieb 
aronis...@afroamerica.net: I know this has been discussed before, but I have 
been going through the issue of reloadData and datasource methods not running. 
I cannot figure out what is going on with my datasource methods. Everything is 
connected. But when on [segmentTableView reloadData], no datasource method is 
run. After the application was running, I debugged the code and checked the 
classes of SelectorController and TableSource. They are all connected in 
runtime.For table view, I only connected it to SelectorController - 
segmentTableView, and its dataSource to SelectorController - segmentTableView. 
All of them are connected properly in runtime.In Log, when I print the 
datasource and delegate of SegmentTableView, it shows SelectorController.  
This is troublesome as I have 4 other tables in the same application that are 
loaded properly through their dedicated datasources. It is only in this table 
that nothing is working. What am I missing? Your help is invaluable.   Her 
is some of the relevant code:   // SelectorController.h #import  
@classsegmentIndustry;   @interface SelectorController : NSObject { 
NSMutableArray *segmentIndustryData; IBOutletNSTableView *segmentTableView; 
IBOutletNSArrayController *segmentDataController;  IBOutletNSButton 
*stockSelectButton; intmodelRS;  }  -(void) insertObject:(segmentIndustry 
*) s inSectorDataAtIndex:(int)index;  -(IBAction) 
initializeSectorSegmentData:(id) sender; @end// SelectorController.m 
   #import SelectorController.h #import segmentIndustry.h #import 
MyDocument.h   NSDictionary *segmentDict;   @implementation 
SelectorController   - (id)init { self = [superinit]; if (self) {  // 
Add your subclass-specific initialization here. // If an error occurs here, 
send a [self release] message and return nil. segmentDict 
=[NSMutableDictionarydictionary]; [segmentDictretain];  } return (self); 
} - (void)awakeFromNib { segmentIndustryData=[[NSMutableArrayalloc] init]; 
[segmentIndustryDataretain]; segmentDataController=[[NSArrayControlleralloc] 
init]; [segmentDataControllerretain];   } //Load into TableView in the 
GUI #pragma mark Table view dataSource methods   - (int) 
numberOfRowsInTableView:(NSTableView *) TableView { return 
[segmentIndustryDatacount];  }   -(id)tableView:(NSTableView *)aTableView 
ObjectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { 
 NSString *identifier =[aTableColumn identifier]; segmentIndustry *stock 
=[segmentIndustryDataobjectAtIndex:rowIndex]; return [stock 
valueForKey:identifier];  }   -(void) tableView:(NSTableView *) 
aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *) 
aTableColumn row:(int) rowIndex { NSString *identifier =[aTableColumn 
identifier]; //What stock? segmentIndustry *stock 
=[segmentIndustryDataobjectAtIndex:rowIndex]; [stock setValue:anObject 
forKey:identifier];  //Set the value for the attribute named identifier }  
  -(IBAction)initializeSectorSegmentData:(id) sender { 
segmentDict=[[MyDocumentgetSectorSegmentData:(id) sender] mutableCopy]; 
[segmentDictretain]; NSWindow *w =[segmentTableViewwindow]; 
[wmakeKeyWindow]; //Fill the table row by row; int i=0; NSMutableArray 
*aXtemp; if ([segmentIndustryDatacount]0) 
[segmentIndustryDataremoveAllObjects]; [[segmentDataControllercontent] 

Re: passing a method name?

2009-12-20 Thread Jeffrey Oleander
 On Sun, 2009/12/20, Graham Cox graham@bigpond.com wrote:
 From: Graham Cox graham@bigpond.com
 Subject: Re: passing a method name?
 To: Chunk 1978 chunk1...@gmail.com
 Cc: cocoa-dev Dev cocoa-dev@lists.apple.com
 Date: Sunday, 2009 December 20, 07:29 
 On 2009/12/21, at 00:18, Chunk 1978 wrote:
 i have a bunch of methods that will call one
 method.  currently, i'm passing a string object
 so the called method will know which method
 had called it, and complete the proper task
 based on the method that called it.

 Good programming practice encourages the idea that
 functions and methods are complete in and of themselves, and
 are invariant under different calling conditions. Variations
 should be accomplished using properly passed parameters, not
 information about where the function has been called from.
 I'd say this approach is going to bite you very, very hard
 if you persist with it. Nobody does this in professional
 programming, and where it is done inadvertently, it will
 usually be rejected and revised when code is peer-reviewed.
 So you might consider this comment part of a peer review.
 
 The only situation this is considered acceptable is when
 passing a callback or completion method, where the called
 method calls the passed method but no part of its internal
 state depends on it.
 
  instead of creating strings and passing them, is it
 possible to pass
  the method name?
 
 You can pass a SEL (selector) type but unless it's for the
 specific purpose of indicating a callback or completion
 method, I would strongly advise against it.

OTOH

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ActionMessages/Concepts/TargetsAndActions.html

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/SearchFields/Articles/ConfiguringTargetAction.html

- (IBAction)updateFilter:sender

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html

- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename; // 
NSApplication
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication 
*)sender; // NSApplication

An action is the message a control sends to the target or, from the perspective 
of the target, the method it implements to respond to the action. A control or— 
as is frequently the case in the Application Kit—a control’s cell stores an 
action as an instance variable of type SEL. SEL is an Objective-C data type 
used to specify the signature of a message. An action message must have a 
simple, distinct signature. The method it invokes returns nothing and has a 
sole argument of type id. This argument, by convention, is named sender. Here 
is an example from the NSResponder class, which defines a number of action 
methods:

- (void)capitalizeWord:(id)sender;
Action methods declared by Cocoa classes can also have the equivalent signature:

- (IBAction) deleteRecord:(id)sender;
In this case, IBAction does not designate a data type for a return value; no 
value is returned. IBAction is a type qualifier that Interface Builder notices 
during application development to synchronize actions added programmatically 
with its internal list of action methods defined for a project...

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/EventOverview/EventHandlingBasics/EventHandlingBasics.html

From Interface Builder you can generate a header file and implementation file 
for your Xcode project that include a declaration and skeletal implementation, 
respectively, for each action method defined for a class. These Interface 
Builder–defined methods have a return “value” of IBAction, which acts as a tag 
to indicated that the target-action connection is archived in a nib file. You 
can also add the declarations and skeletal implementations of action methods 
yourself; in this case, the return type is void.) The remaining required part 
of the signature is a single parameter typed as id and named (by convention) 
sender.

Listing 3-1 illustrates a straightforward implementation of an action method 
that toggles a clock’s AM-PM indicator when a user clicks a button.

Listing 3-1  Simple implementation of an action method
- (IBAction)toggleAmPm:(id)sender
{
...
}
...





___

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

Please do not post admin requests or moderator comments to the list.
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: passing a method name?

2009-12-20 Thread Matt Neuburg
On Mon, 21 Dec 2009 00:29:00 +1100, Graham Cox graham@bigpond.com
said:

On 21/12/2009, at 12:18 AM, Chunk 1978 wrote:

 i have a bunch of methods that will call one method.  currently, i'm
 passing a string object so the called method will know which method
 had called it, and complete the proper task based on the method that
 called it.

Good programming practice encourages the idea that functions and methods are
complete in and of themselves, and are invariant under different calling
conditions. Variations should be accomplished using properly passed parameters,
not information about where the function has been called from. I'd say this
approach is going to bite you very, very hard if you persist with it. Nobody
does this in professional programming, and where it is done inadvertently, it
will usually be rejected and revised when code is peer-reviewed. So you might
consider this comment part of a peer review.

The only situation this is considered acceptable is when passing a callback or
completion method, where the called method calls the passed method but no part
of its internal state depends on it.

Not everyone would agree. I've written a professional application
(professional meaning I was paid for it and it was used in an enterprise
situation) that depended on this, and it never bit me, hard or otherwise.
Certain aspects of the framework (for example, the way sheets work), and the
dynamism of Objective-C messaging (for example, you can construct the name
of the method to be called, in real time, based on the name of another
method, and then call it), sometimes make this a very sensible way to
implement a state machine. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings



___

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

Please do not post admin requests or moderator comments to the list.
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: passing a method name?

2009-12-20 Thread Andy Lee
On Dec 20, 2009, at 1:05 PM, Jeffrey Oleander wrote:

 On Sun, 2009/12/20, Graham Cox graham@bigpond.com wrote:
 
[...]
 Good programming practice encourages the idea that
 functions and methods are complete in and of themselves, and
 are invariant under different calling conditions. Variations
 should be accomplished using properly passed parameters, not
 information about where the function has been called from.
 I'd say this approach is going to bite you very, very hard
 if you persist with it. Nobody does this in professional
 programming, and where it is done inadvertently, it will
 usually be rejected and revised when code is peer-reviewed.
 So you might consider this comment part of a peer review.
 
 The only situation this is considered acceptable is when
 passing a callback or completion method, where the called
 method calls the passed method but no part of its internal
 state depends on it.
 
 instead of creating strings and passing them, is it
 possible to pass
 the method name?
 
 You can pass a SEL (selector) type but unless it's for the
 specific purpose of indicating a callback or completion
 method, I would strongly advise against it.
 
 OTOH
 
 http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ActionMessages/Concepts/TargetsAndActions.html
 
 http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/SearchFields/Articles/ConfiguringTargetAction.html
[...other links to documentation snipped...]

Yes, SELs are used all over the place in Cocoa, but none of the linked examples 
shows a method using the name of the method that called it.  Rather, they show 
a method being given the SEL of a message to *send*.

I agree it probably makes more sense to use an enum to indicate intent.  
Another possibility is to factor things so that there are multiple methods for 
multiple intents, so instead of methods A1, A2, A3, etc. passing their own 
method names to method B, they instead call methods B1, B2, B3, etc., which 
might in turn call a private method _B that performs common logic.

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


Re: NSTableview datasource issues

2009-12-20 Thread Alexander Spohr

Am 20.12.2009 um 18:32 schrieb aronis...@afroamerica.net:

 I did not give you all the methods in my code (it is too lengthy).  
 segmentDict is a global variable because I need it somewhere else.

Sounds like bad design ;)

 a dealloc method takes care of releasing the arrays and dictionary.

Nope! First you alloc a dict in init:
 segmentDict =[NSMutableDictionarydictionary];
 [segmentDictretain];
And later you copy:
 -(IBAction)initializeSectorSegmentData:(id) sender
 {
 segmentDict=[[MyDocumentgetSectorSegmentData:(id) sender] mutableCopy];
// and retain
 [segmentDictretain];

That are three retains on segmentDict - and only one release in dealloc.

 - (void)awakeFromNib
 {
 segmentIndustryData=[[NSMutableArrayalloc] init];
 [segmentIndustryDataretain];
// double init/retain

 segmentDataController=[[NSArrayControlleralloc] init];
 [segmentDataControllerretain];
// double init/retain


 Anyway, even without retain, the table doesn't reload data.
 
 I do not think naming is the issue, it is more of the good habit to have. 

It makes clear what you have at hand - if you stick to it.

Really, I don’t want to offend you but the code you show is buggy and leaks. I 
did not check the rest of your code after finding the release bugs.

atze

___

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

Please do not post admin requests or moderator comments to the list.
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: Core Data - Importing using NSOperation - Problems on main thread

2009-12-20 Thread Quincey Morris
On Dec 20, 2009, at 09:16, Nick Banks wrote:

 Yes I did use the [managedObjectContext save:error], in the same fashion as 
 in some of the examples provided by Apple.  Interestingly, I am using the 
 same mechanism in a completely unrelated project with no problems, and have 
 studied the Core Data documentation for some time.

It sounds like you're Doing It Wrong™. Here's what the Core Data docs have to 
say about multi-threaded access:

A persistent store coordinator provides to its managed object contexts the 
façade of one virtual store.
For completely concurrent operations you need a different coordinator for each 
thread.

and:

There are three patterns you can adopt to support multi-threading in a Core 
Data application; in order of preference they are:

• Create a separate managed object context for each thread and share a single 
persistent store coordinator.
If you need to “pass” managed objects between threads, you just pass their 
object IDs.

If you want to aggregate a number of operations in one context together as if 
a virtual single transaction, you can lock the persistent store coordinator to 
prevent other managed object contexts using the persistent store coordinator 
over the scope of several operations.

• Create a separate managed object context and persistent store coordinator 
for each thread.
If you need to “pass” managed objects between threads, you just pass their 
object IDs.

Using a separate persistent store coordinator for each thread allows for 
completely concurrent operations.

[etc]

Deleting objects that are actively being fetched and/or displayed sure sounds 
like a completely concurrent operation. Sounds like you need a separate 
persistent store controller for each thread. (And even then you might have to 
deal with concurrency issues in your user interface, but that's a general 
multithreading headache, not Core Data specific.)

 If I delete an object in the import moc (moc2) will that immediately cause 
 the object in moc1 to be deleted also (thus causing problems when referenced 
 by the UI i.e. it will no longer exist) or will this only happen when I call 
 [managedObjectContext save:error]?

Deletions occur in the persistent store, not in the managed content. When you 
delete an object in a MOC, it's merely flagged so that the underlying data is 
removed from the store when the next save occurs. Neither the store nor any 
other MOC knows about the deletion until at least then.

Nothing can cause the object in moc1 to be deleted because the objects (the 
in-memory Objective-C objects) aren't deleted at all. Instead they are 
dealloc'ed or finalized when no longer referenced, according to the normal 
memory management rules. However, still-referenced objects that correspond to a 
saved persistent store deletion (the scenario you describe) will presumably 
produce errors if you cause fetching of their properties to be attempted.


___

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

Please do not post admin requests or moderator comments to the list.
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: Customizing NSTableViewHeader.. I think I got it.

2009-12-20 Thread Gustavo Pizano
.. I think I got it... I overwrote the mouseDown method from NSResponder, and 
the sorting doesn't happen... so I guess I must aim my efforts starting form 
this method.

I will let you know my progress.

G.

On Dec 20, 2009, at 5:30 PM, Gustavo Pizano wrote:

 Hello, 
 After reading some post, and coding my own class, I was able to set up a 
 custom glossy background color,  then I realize the title was behind it, so I 
 just place it above the background..
 
 So, so far so good.
 
 But now when I click in the header of a column, of course because its a 
 custom one, no highlight color appear... (yes the light aqua blue color) and 
 also the sort indicator.. all this seems to be under the background..  I have 
 been trying to check different approaches like, in the drawRect of the 
 CustomNSTableHeaderView method, when sending to draw each column headerCell 
 (which are subclasses also), check if the column is selected, of course this 
 will work, if I have column selection enable, not my case, I also tried, 
 directly in the headerCell, checking if isHiglighted, but always returns NO. 
 So unless Im able to know where exactly I can check if the user clicked the 
 column header, to place the sort indicator or call the method - 
 (void)drawSortIndicatorWithFrame:(NSRect)cellFrame inView:(NSView 
 *)controlView ascending:(BOOL)ascending priority:(NSInteger)priority; on the 
 HeaderCell, I can't draw the background color for highlighted neither the 
 sort indicator.
 I tried also to override, the method :
 - (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:(NSView 
 *)controlView
 
 but it was never called.
 
 Any ideas?
 
 Thanks
 
 Gustavo
 

___

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

Please do not post admin requests or moderator comments to the list.
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 datasource issues

2009-12-20 Thread Greg Guerin
Yes, I set the breakpoint on the data source methods? The  
datasource methods are not reached at all.



Then you must consider the possibility that your table view has a nil  
data source, or a data source of a different class.


If the methods definitely aren't being called, then simple logic  
suggests your problem lies somewhere other than that data-source  
class.  Perhaps in the creation or assignment of the data-source.   
Perhaps in the creation or use of the table view.  You'll have to  
backtrack it to find out.


Another possibility is some kind of error or mismatch between your  
source and your compiled code, where what's loaded and debugged isn't  
what you have in your source.  Doing a Clean build usually fixes such  
errors.




-(id)tableView:(NSTableView *)aTableView
ObjectValueForTableColumn:(NSTableColumn *)aTableColumn
 row:(int)rowIndex
{


I'm pretty sure that's the wrong method name.  Check the capitalization.

If your source code is correct, then it was probably mangled by  
mailing.  The list-archives post was also stripped of a lot of  
necessary whitespace, so capital-mangling would not surprise me.


http://lists.apple.com/archives/cocoa-dev/2009/Dec/msg01215.html



-(IBAction)initializeSectorSegmentData:(id) sender
{
segmentDict=[[MyDocument getSectorSegmentData:(id) sender]  
mutableCopy];

[segmentDict retain];
NSWindow *w =[segmentTableView window];
[w makeKeyWindow];
//Fill the table row by row;
int i=0;
NSMutableArray *aXtemp;
if ([segmentIndustryData count]0) [segmentIndustryData  
removeAllObjects];

[[segmentDataController content] removeAllObjects];
for (id key in segmentDict)



(Note: I have inserted spaces in the above based on what seems  
reasonable.  I may have guessed wrong.)


This code looks odd, especially considering you're also setting  
segmentDict to an empty dictionary in the -init method.  The  
assignment to segmentDict in -init may be problematic, depending on  
where else that global variable is used.


First, getSectorSegmentData appears to be a class method.  That seems  
unusual to me.  It may be justified, but it still seems unusual.


Second, it's unclear whether the returned dict assigned to  
segmentDict actually contains anything or not.  If not, then the  
'for' loop will get no keys, the loop body will never execute, and  
self's ivars will contain no objects.  If that happens, then the data- 
source has a count of 0 and contains nothing.


A data-source which contains nothing differs from a data-source's  
methods never being called or a data-source object being nil.  The  
visible effect may be similar, an empty table-view, but the execution  
path is different.


  -- GG

___

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

Please do not post admin requests or moderator comments to the list.
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


passing around Protocols like passing SEL?

2009-12-20 Thread aaron smith
Hey all, quick question. How you do pass around protocol references?

I'm looking to do something like what NSDistantObject uses to set a
protocol, (setProtocolForProxy:). That method takes a (Proxy *), and all
I've found is that in some headers they declare a class (@class Protocol).
So does this mean that sending @protocol(SomeProtocol) is just passing a
Class? I haven't been able to find anything else in the objc docs about
doing this.

Thanks much!
___

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

Please do not post admin requests or moderator comments to the list.
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


Localization strategies?

2009-12-20 Thread Ricky Sharp

In getting quotes from many localization companies, I've found that some have 
different processes.  For example, one company would prefer if I just provide 
.string files.  During their QA process, they'll then run the app and look at 
everything in context.

While generating .strings from nibs is easy to do, there's a problem in that 
there seems to be no method of putting contextual comments into a nib.  And 
there's no way I would hand-edit comments in the generated .strings files.

Thus, I'm wondering if it would ultimately be worth it to externalize all 
strings from my nibs and just put everything in my single .strings file.  This 
will clearly involve me adding tons of IBOutlet ivars just so that at runtime I 
can set their text with NSLocalizedString APIs.

I still plan on having separate nibs though for each language (to account for 
text bounds, font sizes, etc.)

How have others tackled localization?

___
Ricky A. Sharp mailto:rsh...@instantinteractive.com
Instant Interactive(tm)   http://www.instantinteractive.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


tracking EXC_BAD_ACCESS error in applescript command

2009-12-20 Thread François Guillet
Hi All,

I'm trying to implement an object-first command targeted at the document of a 
document based app. Doing so  always results in the same EXC_BAD_ACCESS error :
#0  0x7fff86951466 in -[NSScriptCommand _sendToRemainingReceivers] ()
#1  0x7fff86951fe5 in -[NSScriptCommand executeCommand] ()
#2  0x7fff8696902e in -[NSScriptingAppleEventHandler 
handleCommandEvent:withReplyEvent:] ()
#3  0x7fff86861156 in -[NSAppleEventManager 
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()
#4  0x7fff86860f86 in _NSAppleEventManagerGenericHandler ()
#5  0x7fff868b941e in _NSAppleEventManagerPreDispatchHandler ()
#6  0x7fff806fe292 in aeDispatchAppleEvent ()
#7  0x7fff806fe18b in dispatchEventAndSendReply ()
#8  0x7fff806fe095 in aeProcessAppleEvent ()
#9  0x7fff821f8879 in AEProcessAppleEvent ()
#10 0x7fff87e303d5 in _DPSNextEvent ()
#11 0x7fff87e2fb41 in -[NSApplication 
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#12 0x7fff87df5747 in -[NSApplication run] ()
#13 0x7fff87dee468 in NSApplicationMain () 

I posted at applescript-implement...@lists.apple.com and was replied that the 
error was likely due to over-releasing an object and wasn't a problem with 
applescript implementation per se.

The problem is that the object first command calls a very simple method with no 
other object implied than the document which is properly retained. I 
implemented a subclass of NSScriptCommand used both for verb first or object 
first command : everything works fine, I can call [[self evaluatedReceivers] 
handleCommmand:self] from  executeCommand without any problem. The 
EXC_BAD_ACCESS error, though, always happens if I try to call NSScriptCommand's 
executeCommand.

Any idea on how can I further investigate this problem ?
 
(10.6.2, XCode 3.2.1, NSZombie enabled)

Thanks, 
François



___

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

Please do not post admin requests or moderator comments to the list.
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: passing around Protocols like passing SEL?

2009-12-20 Thread Mike Abdullah
See 
http://developer.apple.com/mac/library/documentation/cocoa/conceptual/ObjectiveC/Articles/ocProtocols.html#//apple_ref/doc/uid/TP30001163-CH15-TPXREF149

On 20 Dec 2009, at 20:15, aaron smith wrote:

 Hey all, quick question. How you do pass around protocol references?
 
 I'm looking to do something like what NSDistantObject uses to set a
 protocol, (setProtocolForProxy:). That method takes a (Proxy *), and all
 I've found is that in some headers they declare a class (@class Protocol).
 So does this mean that sending @protocol(SomeProtocol) is just passing a
 Class? I haven't been able to find anything else in the objc docs about
 doing this.
 
 Thanks much!
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
 
 This email sent to cocoa...@mikeabdullah.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: passing a method name?

2009-12-20 Thread Graham Cox

On 21/12/2009, at 5:05 AM, Jeffrey Oleander wrote:

 OTOH
[]
 An action is the message a control sends to the target


Target/action is not what I was talking about at all. It's OK to store a SEL 
which is invoked as a response - the signature of that SEL does not change the 
behaviour or state of the control that invokes it.

What I took the OP to mean, and what I consider bad practice, is something like 
this:



- (void)someMethodCalledBy:(SEL) caller
{
if( caller == firstCaller )
DoAction1();
else
DoAction2();
}

that is quite different from simply invoking a SEL that you are passed:

- (void)someMethodWithCompletionMethod:(SEL) completion target:(id) 
target
{
DoAction1();
DoAction2();

objc_msg_send( target, completion );
}


Note that in the second case you also need a target - a naked SEL is not much 
use unless it has a target, either passed explicitly or implied. The first 
example is bad because its behaviour can't be predicted without knowing where 
it is called from, so it cannot be analysed or debugged in isolation.


 Not everyone would agree. I've written a professional application
 (professional meaning I was paid for it and it was used in an enterprise
 situation) that depended on this, and it never bit me, hard or otherwise.
 Certain aspects of the framework (for example, the way sheets work), and the
 dynamism of Objective-C messaging (for example, you can construct the name
 of the method to be called, in real time, based on the name of another
 method, and then call it), sometimes make this a very sensible way to
 implement a state machine. m.


This is still a different thing. Deciding on which method to call dynamically 
is fine, as long as the method called does not depend further on where it was 
called from. What you're basically talking about here is table-based dispatch, 
which is of course the fundamental mechanism for all object-oriented languages. 
I think what the OP was talking about was making a called method sensitive to 
its caller, which is a no-no.

Sheets require a completion method but the sheet itself will not behave 
differently according to that method - it simply invokes it when it's done. 
Completion methods and callbacks are also fine, because they do not change the 
state of the method they are passed to.

--Graham


___

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

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

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

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


Re: passing a method name?

2009-12-20 Thread Dave Carrigan

On Dec 20, 2009, at 3:29 PM, Graham Cox wrote:

 I think what the OP was talking about was making a called method sensitive to 
 its caller, which is a no-no.


That's what I thought the OP was saying, and I agree. It would mean that doing 
a refactor and changing a method's name, or even adding a new parameter to a 
method, would break the code in some unrelated method. That's a huge 
maintenance problem.

-- 
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

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

Please do not post admin requests or moderator comments to the list.
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 datasource issues

2009-12-20 Thread aronisoft
 Greg,


I understand your proposition. For some reason, the spaces are stripped off by 
the e-mail system, but you got it right.
 Actually, segmentDict contains the copy of a global dictionary created by the 
method [[MyDocument getSectorSegmentData:(id) sender]  mutableCopy]. 
Unfortunately i cannot give here all the code. Also, when I print the 
datasource and delegate for segmentTableView, it is clear that it is not nil: 
the log shows SelectorController, which is what it should be.
My major puzzle is that all other TableView in the application using different 
datasources get loaded. Cleaning all targets does not change anything.
Brief, the major problem is this: the datasource methods do not get called.
Datasource is not nil at run time, no error in the code. The ArrayController is 
not empty, the code looks fine.


I will go back and review for the thousandth time the code from scratch and all 
the bindings, but up to now, I can't figure out what is wrong.


Thank you.


-Original Message-
From: Greg Guerin [mailto:glgue...@amug.org]
Sent: Sunday, December 20, 2009 03:08 PM
To: 'list-cocoa-dev'
Subject: Re: NSTableview datasource issues

 Yes, I set the breakpoint on the data source methods? The  datasource 
 methods are not reached at all.Then you must consider the possibility that 
 your table view has a nil data source, or a data source of a different 
 class.If the methods definitely aren't being called, then simple logic 
 suggests your problem lies somewhere other than that data-source class. 
 Perhaps in the creation or assignment of the data-source. Perhaps in the 
 creation or use of the table view. You'll have to backtrack it to find 
 out.Another possibility is some kind of error or mismatch between your source 
 and your compiled code, where what's loaded and debugged isn't what you have 
 in your source. Doing a Clean build usually fixes such errors. 
 -(id)tableView:(NSTableView *)aTableView 
 ObjectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex 
 {I'm pretty sure that's the wrong method name. Check the capitalization.If 
 your source code is correct, then it was probably mangled by mailing. The 
 list-archives post was also stripped of a lot of necessary whitespace, so 
 capital-mangling would not surprise 
 me.http://lists.apple.com/archives/cocoa-dev/2009/Dec/msg01215.html 
 -(IBAction)initializeSectorSegmentData:(id) sender { 
 segmentDict=[[MyDocument getSectorSegmentData:(id) sender]  mutableCopy]; 
 [segmentDict retain]; NSWindow *w =[segmentTableView window]; [w 
 makeKeyWindow]; //Fill the table row by row; int i=0; NSMutableArray 
 *aXtemp; if ([segmentIndustryData count]0) [segmentIndustryData  
 removeAllObjects]; [[segmentDataController content] removeAllObjects]; for 
 (id key in segmentDict)(Note: I have inserted spaces in the above based on 
 what seems reasonable. I may have guessed wrong.)This code looks odd, 
 especially considering you're also setting segmentDict to an empty dictionary 
 in the -init method. The assignment to segmentDict in -init may be 
 problematic, depending on where else that global variable is used.First, 
 getSectorSegmentData appears to be a class method. That seems unusual to me. 
 It may be justified, but it still seems unusual.Second, it's unclear whether 
 the returned dict assigned to segmentDict actually contains anything or not. 
 If not, then the 'for' loop will get no keys, the loop body will never 
 execute, and self's ivars will contain no objects. If that happens, then the 
 data- source has a count of 0 and contains nothing.A data-source which 
 contains nothing differs from a data-source's methods never being called or a 
 data-source object being nil. The visible effect may be similar, an empty 
 table-view, but the execution path is different. -- 
 GG___Cocoa-dev mailing list 
 (Cocoa-dev@lists.apple.com)Please do not post admin requests or moderator 
 comments to the list.Contact the moderators at 
 cocoa-dev-admins(at)lists.apple.comHelp/Unsubscribe/Update your 
 Subscription:http://lists.apple.com/mailman/options/cocoa-dev/aronisoft%40afroamerica.netThis
  email sent to aronis...@afroamerica.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: NSTableview datasource issues

2009-12-20 Thread Greg Guerin
I understand your proposition. For some reason, the spaces are  
stripped off by the e-mail system, but you got it right.



Did your email system also capitalize ObjectValueForTableColumn?


 Actually, segmentDict contains the copy of a global dictionary  
created by the method [[MyDocument getSectorSegmentData:(id)  
sender]  mutableCopy]. Unfortunately i cannot give here all the  
code. Also, when I print the datasource and delegate for  
segmentTableView, it is clear that it is not nil: the log shows  
SelectorController, which is what it should be.
My major puzzle is that all other TableView in the application  
using different datasources get loaded. Cleaning all targets does  
not change anything.
Brief, the major problem is this: the datasource methods do not get  
called.
Datasource is not nil at run time, no error in the code. The  
ArrayController is not empty, the code looks fine.



I will go back and review for the thousandth time the code from  
scratch and all the bindings, but up to now, I can't figure out  
what is wrong.


Maybe you can add some assertions in your code.  For example, given  
the way segmentDict is used, it strongly suggests your design is  
effectively a singleton.  That is, there must only be a single  
instance of SelectorController created and init'ed.


The other thing that occurred to me is if an instance of  
SelectorController is recreated by the nib, and another instance is  
created in your code, then the instance you see with valid datasource  
and delegate may not be the instance that the nib is using.  One  
instance may not be getting completely initialized.


As a last resort, try stripping classes, xibs, etc. in order to  
produce a simplified test case that still exhibits the problem.  In  
the process of simplifying, sometimes you do something that causes  
the problem to go away.  Tracking down the change that causes things  
to work then leads to identifying the cause of the problem.  Even if  
the simplified case still has the problem, you still have something  
that others can run and help debug.


  -- GG

___

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

Please do not post admin requests or moderator comments to the list.
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: tracking EXC_BAD_ACCESS error in applescript command

2009-12-20 Thread Jerry Krinock

On 2009 Dec 20, at 13:50, François Guillet wrote:

  EXC_BAD_ACCESS error :
 #0  0x7fff86951466 in -[NSScriptCommand _sendToRemainingReceivers] ()
 #1  0x7fff86951fe5 in -[NSScriptCommand executeCommand] ()
 #2  0x7fff8696902e in -[NSScriptingAppleEventHandler 
 handleCommandEvent:withReplyEvent:] ()

 I implemented a subclass of NSScriptCommand used both for verb first or 
 object first command : everything works fine, I can call [[self 
 evaluatedReceivers] handleCommmand:self] from  executeCommand without any 
 problem. The EXC_BAD_ACCESS error, though, always happens if I try to call 
 NSScriptCommand's executeCommand.

Not sure about the crash, but if you've subclassed NSScriptCommand, should not 
your subclass name appear in the call stack shown above, instead of 
NSScriptCommand?  In your sdef, have you specified your subclass to be the 
Cocoa Class of this command?

___

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

Please do not post admin requests or moderator comments to the list.
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


IKImageBrowserView managing the number of columns manually

2009-12-20 Thread Nicolas Berloquin
Hi !

I'm using an IKImageBrowserView to show a series of image captures
and it works really well. I would like to be able to manage the number
of images shown in a row in a precise way, and I'd like to know if there
is any public way to do this ?
The zoom variable is nice, but I don't like having to rely on calculations
from the view size, and zoom value just to guess how many images will
be shown...
Is there something I missed ?
Oh, and I'd also like to be able to determine the height (or widths) of
cells...
Right now cells are square, but my capture are have a 4/3 ratio, which
leaves
a lot of empty space between rows...
Should I hack into the hidden variables in order to do that ?

And one more thing :)
I tried saving the browserview as a jpeg. After searching the net I found
out that
it was using opengl to render. Could someone please point me to an easy
way to save the whole view (if bigger than what's shown on screen) to a file
?

thanks for any help ! :)
(I'm starting to think that I should rather use the NSCollectionView if I
want more
handles into what is done, am I right ?)
___

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

Please do not post admin requests or moderator comments to the list.
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


Core Data Migration

2009-12-20 Thread Chaitanya Pandit

Hello, List,

I'm working on the migration for one of my Core Data document based 
application, i've created a mapping model in XCode and am using the 
NSMigratePersistentStoresAutomaticallyOption property by overriding the 
configurePersistentStoreCoordinatorForURL:... method. as described in this 
awesome link: http://www.timisted.net/blog/archive/core-data-migration/

One weird thing that is happening is that just after the 
configurePersistentStoreCoordinatorForURL... call, the contents of my 
document on the disk are changed, even if i didn't save the document, that's 
totally weird because if i open a document created by app version 1.0, using 
the version 2.0, and just close it without doing anything, i can no longer open 
that document in 1.0 as it has changed the data and it throws an alert saying 
the version of the model has been changed

I'd really appreciate any help.

Thanks,
Chaitanya Pandit
Expersis Software Inc.
http://www.expersis.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