Re: View Based TableView - how to use bindings?

2013-05-01 Thread Gerriet M. Denkmann

On 2 May 2013, at 03:16, Quincey Morris  
wrote:

I got it working.
Formerly I had:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.dataArray = [ NSMutableArray array ];  //  this is the 
content of my ArrayController
for(...) { fill self.dataArray with 39 Dictionaries };
}

I changed this to:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSMutableArray *tempArray = [ NSMutableArray array ];
for(...) { fill tempArray with 39 Dictionaries };
self.dataArray = tempArray;
}

And now it works.
In the bad old style the ArrayController knew it had 39 objects, but the 
TableView still thought there were 0.
Now everything is in sync.

>> Just bound the image to "objectValue.AbsoluteNonsense" and did not get any 
>> error messages. Is this normal?
> 
> If it's not creating any cell views, there won't be any errors.
Now that cell view ARE created, there are still no errors. There just are no 
images in my table.

Anyway - thanks a LOT for your help!


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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Double tap inside a UICollectionViewCell

2013-05-01 Thread koko
The code below from Collection View Programming Guide for iOS: Incorporating 
Gesture Support does not work as expected.  Is there something Apple has left 
out?

Does not work as expected means @selector(handleTapGesture:)is not called if a 
double tap occurs in a UICollectionViewCell.  @selector(handleTapGesture:) is 
called if the double tap occurs outside a UICollectionViewCell.

The question is how to get a double tap inside a UICollectionViewCell.

-koko


UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] 
initWithTarget:self action:@selector(handleTapGesture:)];
NSArray* recognizers = [self.collectionView gestureRecognizers];
for (UIGestureRecognizer* aRecognizer in recognizers)
{
if ([aRecognizer isKindOfClass:[UITapGestureRecognizer class]])

[aRecognizer requireGestureRecognizerToFail:tapGesture];
}
[tapGesture setNumberOfTapsRequired:2];
[self.collectionView addGestureRecognizer:tapGesture];

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Close All Documents

2013-05-01 Thread Steve Mills
On May 1, 2013, at 14:58:47, Seth Willits  wrote:

> To be clear, are you suggesting that when quitting your app with unsaved 
> documents open it's not asking you to review unsaved docs and you want it to 
> that and are therefore having to somewhat implement that yourself?

No.

> Quitting with unsaved documents open (according to Apple HIG) should now quit 
> immediately and when the app reopens restore those same unsaved documents to 
> their prior state so there's no need for review. It's separate from the (I 
> completely agree) silly and maddening "quit when last doc is closed" behavior.

That's only valid if the app is using the new autosave mechanism that saves 
changes in place. I am not.

> However, unless your windows are marked as restorable I believe it should 
> still be showing that review alert. So perhaps you might double check that.
> 
> As far as your implementation goes it looks right to me.

I'm not asking about closing docs when quitting, but handling the Close All 
Documents menu item, hence the possibly somewhat unclear subject line. We've 
offered this menu item in the past and will continue to offer it into the 
future. I just needed to implement it in a way that would live peacefully with 
Cocoa and make use of the "review changes" dealy-bob. Thanks for your input!

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: View Based TableView - how to use bindings?

2013-05-01 Thread Quincey Morris
On May 1, 2013, at 12:52 , "Gerriet M. Denkmann"  wrote:

> Can't find the method: 'tableView:viewWithIdentifier…'. But 
> makeViewWithIdentifier:... is never called. It was used in 
> ...viewForTableColumn:... which was never called and has just been removed.
> I guess this is the root of the problem: I do not know where to call 
> makeViewWithIdentifier.
> But do I need to? both things in the NSTableCellView have bindings already.

The header comments for 'tableView:viewForTableColumn:' say:

> Bindings: This method is optional if at least one identifier has been 
> associated with the TableView at design time. If this method is not 
> implemented, the table will automatically call -[self 
> makeViewWithIdentifier:[tableColumn identifier] owner:[tableView delegate]] 
> to attempt to reuse a previous view, or automatically unarchive an associated 
> prototype view.

So you don't need the method (because you have bindings), but you need to make 
sure that the table column identifier matches the interface identifier of the 
"prototype" view.

>   id g = [ self.arrayController arrangedObjects ];//  
> _NSControllerArrayProxy
>   NSLog(@"%s arrangedObjects %ld ",__FUNCTION__, [g count]);
> prints 39 as expected. So the array controller is not empty. It also contains 
> correct objects.
> 
> Just bound the image to "objectValue.AbsoluteNonsense" and did not get any 
> error messages. Is this normal?

If it's not creating any cell views, there won't be any errors.

I think you still need to find out whether it's the table view binding or the 
cell view binding that's failing. You could insert a line of code, after the 
table view is supposedly initialized, to query the number of rows and see if 
it's 39.

Note that the fact that the array controller contains the right objects doesn't 
necessarily mean anything, if KVO compliance is messed up. It's a matter of 
timing, in that case, as to what results you get. You could try throwing in a 
'reloadData' for the table, once you're sure the array controller has the right 
content, and see if that changes things. If so, you have a KVO compliance 
problem earlier in the initialization.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Close All Documents

2013-05-01 Thread Seth Willits
On May 1, 2013, at 12:03 PM, Steve Mills wrote:

> Since this is no longer handled by the OS (probably in lieu of the silly new 
> "quit when last doc is closed" behavior), is there a better way to handle it 
> than what I have below?

To be clear, are you suggesting that when quitting your app with unsaved 
documents open it's not asking you to review unsaved docs and you want it to 
that and are therefore having to somewhat implement that yourself?

Quitting with unsaved documents open (according to Apple HIG) should now quit 
immediately and when the app reopens restore those same unsaved documents to 
their prior state so there's no need for review. It's separate from the (I 
completely agree) silly and maddening "quit when last doc is closed" behavior.

However, unless your windows are marked as restorable I believe it should still 
be showing that review alert. So perhaps you might double check that.

As far as your implementation goes it looks right to me.


--
Seth Willits




___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: View Based TableView - how to use bindings?

2013-05-01 Thread Gerriet M. Denkmann

On 2 May 2013, at 02:16, Quincey Morris  
wrote:

> On May 1, 2013, at 11:52 , "Gerriet M. Denkmann"  wrote:
> 
>> The Array Controller has it's content bound to some array of dictionaries, 
>> which have the keys "Name" and "Image".
>> The table view's content is bound to Array Controller arrangedObjects. The 
>> only TableColumn is not bound to anything.
>> The Image View of the Table Cell View has it's Value bound to Table Cell 
>> View objectValue.Image.
>> The Static Text of the Table Cell View has it's Value bound to Table Cell 
>> View objectValue.Name.
>> 
>> But still - the table remains empty.
> 
> What kind of empty?
Completely.
> Are there any rows?
Can't see any.
> Can you select rows by clicking on them, even if their content is blank?
No, there really seem to be no rows at all.
> 
> Are you sure there aren't any exception or other messages in the Console log 
> that you didn't see?
No exceptions in Xcode - none in Console.app.
> 
> You could try temporarily unbinding the image and text properties of the cell 
> view, so that they should display whatever they're showing in IB. That might 
> give a clearer idea of whether it's the binding from the table to the array 
> controller that's at fault, or the bindings from the cell subviews to the 
> cell view.
Did unbind both image and name. Still no rows.
> 
> Do you still have a 'tableView:objectValue…' method, or do you set 
> objectValue in 'tableView:viewWithIdentifier…'? Neither should be necessary 
> when using the table view binding to the array controller.
I had "-tableView: viewForTableColumn: row:" - have just removed it. Still no 
rows.

> 
> Is your cell view a subclass of NSTableCellView, or something else? Are you 
> trying to use the built-in (design-time) table cell view, or have you 
> registered a nib to provide the cell views?
Just a plain NSTableCellView. 
> 
> 
> Are you sure you're using the correct view identifier in 
> 'tableView:viewWithIdentifier…'? Are you sure 'makeViewWithIdentifer:' isn't 
> returning nil?
Can't find the method: 'tableView:viewWithIdentifier…'. But 
makeViewWithIdentifier:... is never called. It was used in 
...viewForTableColumn:... which was never called and has just been removed.
I guess this is the root of the problem: I do not know where to call 
makeViewWithIdentifier.
But do I need to? both things in the NSTableCellView have bindings already.

> 
> Are you sure this is a table view issue, and not a KVO compliance issue with 
> the property that's supplying the array controller content?
id g = [ self.arrayController arrangedObjects ];//  
_NSControllerArrayProxy
NSLog(@"%s arrangedObjects %ld ",__FUNCTION__, [g count]);
prints 39 as expected. So the array controller is not empty. It also contains 
correct objects.

Just bound the image to "objectValue.AbsoluteNonsense" and did not get any 
error messages. Is this normal?

Well - will try more tomorrow. It is almost three in the morning an I am tired.

Thanks for your help!


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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

[MEET] Toronto Cocoaheads / tacow - May 14

2013-05-01 Thread Karl Moskowski
tacow's next meeting is scheduled for 6:30 PM on Tuesday, May 14, 2013 in 
meeting room 310 of Metro Hall.

Ryder Mackay will be discussing AVFoundation. For more details and to RSVP, 
head over to .

In addition, we’d like to gauge how many plan to join us for the traditional 
post-meeting pub visit. Please let us know if you’re going to stick around by 
RSVPing here.


Thanks, and see you there!


Karl Moskowski 




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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: View Based TableView - how to use bindings?

2013-05-01 Thread Quincey Morris
On May 1, 2013, at 11:52 , "Gerriet M. Denkmann"  wrote:

> The Array Controller has it's content bound to some array of dictionaries, 
> which have the keys "Name" and "Image".
> The table view's content is bound to Array Controller arrangedObjects. The 
> only TableColumn is not bound to anything.
> The Image View of the Table Cell View has it's Value bound to Table Cell View 
> objectValue.Image.
> The Static Text of the Table Cell View has it's Value bound to Table Cell 
> View objectValue.Name.
> 
> But still - the table remains empty.

What kind of empty? Are there any rows? Can you select rows by clicking on 
them, even if their content is blank?

Are you sure there aren't any exception or other messages in the Console log 
that you didn't see?

You could try temporarily unbinding the image and text properties of the cell 
view, so that they should display whatever they're showing in IB. That might 
give a clearer idea of whether it's the binding from the table to the array 
controller that's at fault, or the bindings from the cell subviews to the cell 
view.

Do you still have a 'tableView:objectValue…' method, or do you set objectValue 
in 'tableView:viewWithIdentifier…'? Neither should be necessary when using the 
table view binding to the array controller.

Is your cell view a subclass of NSTableCellView, or something else? Are you 
trying to use the built-in (design-time) table cell view, or have you 
registered a nib to provide the cell views?

Are you sure you're using the correct view identifier in 
'tableView:viewWithIdentifier…'? Are you sure 'makeViewWithIdentifer:' isn't 
returning nil?

Are you sure this is a table view issue, and not a KVO compliance issue with 
the property that's supplying the array controller content?

There's lots that can go wrong here. :)

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Close All Documents

2013-05-01 Thread Steve Mills
Since this is no longer handled by the OS (probably in lieu of the silly new 
"quit when last doc is closed" behavior), is there a better way to handle it 
than what I have below?

-(void) documentController:(NSDocumentController*)documentController 
didReviewAll:(BOOL)didReviewAll contextInfo:(void*)contextInfo
{
UNUSED_VAR(contextInfo);

if(didReviewAll)
for(MusicDocument* doc in [documentController documents])
[doc close];
}


-(IBAction)closeAllDocuments:(id)sender
{
UNUSED_VAR(sender);

[self reviewUnsavedDocumentsWithAlertTitle:nil cancellable:YES 
delegate:self 
didReviewAllSelector:@selector(documentController:didReviewAll:contextInfo:) 
contextInfo:nil];
}


--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Built-in Activity Types

2013-05-01 Thread koko
I should also note that I want to add my custom activities as well and 
understand I need to subclass UIActivity but some details would be helpful.


On May 1, 2013, at 12:39 PM, koko  wrote:

> How does one specify which of the built-in Activity Types should be displayed 
> in the UIActivityViewController?
> 
> If I do this:
> 
>   NSArray *activityItems = [NSArray arrayWithObject:@"STRING"];
>   self.activityViewController = [[UIActivityViewController alloc] 
> initWithActivityItems:activityItems applicationActivities:nil];
> 
> 
> I get Mail, Message and Copy activities but would like to customize this list 
> to be Mail, Print,FaceBook.
> 
> I am stumped!
> 
> -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:
> https://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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


View Based TableView - how to use bindings?

2013-05-01 Thread Gerriet M. Denkmann
I have a view-based table view which currently uses a DataSource. 
But I would like to use bindings instead.
I know how to do this with a cell-based table view - and I was following 
"Populating View-Based Table Views using Cocoa Bindings".

My array controller has arrangedObjects which seem to be right.
But my table is absolutely empty.

The Array Controller has it's content bound to some array of dictionaries, 
which have the keys "Name" and "Image".
The table view's content is bound to Array Controller arrangedObjects. The only 
TableColumn is not bound to anything.
The Image View of the Table Cell View has it's Value bound to Table Cell View 
objectValue.Image.
The Static Text of the Table Cell View has it's Value bound to Table Cell View 
objectValue.Name.

But still - the table remains empty.

What might I be missing?

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Built-in Activity Types

2013-05-01 Thread koko
How does one specify which of the built-in Activity Types should be displayed 
in the UIActivityViewController?

If I do this:

   NSArray *activityItems = [NSArray arrayWithObject:@"STRING"];
   self.activityViewController = [[UIActivityViewController alloc] 
initWithActivityItems:activityItems applicationActivities:nil];


I get Mail, Message and Copy activities but would like to customize this list 
to be Mail, Print,FaceBook.

I am stumped!

-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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: View Based Table - where is my data?

2013-05-01 Thread Gerriet M. Denkmann

On 1 May 2013, at 23:51, Quincey Morris  
wrote:

> On May 1, 2013, at 08:34 , "Gerriet M. Denkmann"  wrote:
> 
>> - (id)tableView:(NSTableView *)aTableView 
>> objectValueForTableColumn:(NSTableColumn *)aTableColumn 
>> row:(NSInteger)rowIndex
>> {
>>  NSDictionary *aLine = self.dataArray[rowIndex];
>>  NSTableCellView *cellView = [ aTableView makeViewWithIdentifier: 
>> @"DieSpalte" owner: self ];
>>  [ cellView.textField setStringValue: aLine[kNameKey] ];
>>  [ cellView.imageView setImage: aLine[kImageKey] ];
>>  NSLog(@"%s %ld %@",__FUNCTION__, rowIndex, cellView);
>>  return cellView;
>> }
> 
> This is wrong. You should not create a cell view in this method, and you 
> should not return a cell view as a result. The value returned from this 
> method becomes the the "objectValue"  property of the cell view. Because 
> you're trying to create the cell view in the wrong place, the table view is 
> creating one for you (a different one), and that view isn't getting its text 
> or image set to anything useful.
> 
> Instead, you should be putting the above code in a 
> 'tableView:viewForTableColumn:row:' delegate method. Since you're 
> (apparently) not using any bindings within your cell view, you don't need 
> objectValue at all -- neither the data source method nor the property.

You are absolutely right. 
And I was confused, because before I implemented my data-source method 
numberOfRowsInTableView: I was told: " *** Illegal NSTableView data source 
().  Must implement numberOfRowsInTableView: and 
tableView:objectValueForTableColumn:row:" which seems not really true after all.

Thanks a lot!


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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: View Based Table - where is my data?

2013-05-01 Thread Quincey Morris
On May 1, 2013, at 08:34 , "Gerriet M. Denkmann"  wrote:

> - (id)tableView:(NSTableView *)aTableView 
> objectValueForTableColumn:(NSTableColumn *)aTableColumn 
> row:(NSInteger)rowIndex
> {
>   NSDictionary *aLine = self.dataArray[rowIndex];
>   NSTableCellView *cellView = [ aTableView makeViewWithIdentifier: 
> @"DieSpalte" owner: self ];
>   [ cellView.textField setStringValue: aLine[kNameKey] ];
>   [ cellView.imageView setImage: aLine[kImageKey] ];
>   NSLog(@"%s %ld %@",__FUNCTION__, rowIndex, cellView);
>   return cellView;
> }

This is wrong. You should not create a cell view in this method, and you should 
not return a cell view as a result. The value returned from this method becomes 
the the "objectValue"  property of the cell view. Because you're trying to 
create the cell view in the wrong place, the table view is creating one for you 
(a different one), and that view isn't getting its text or image set to 
anything useful.

Instead, you should be putting the above code in a 
'tableView:viewForTableColumn:row:' delegate method. Since you're (apparently) 
not using any bindings within your cell view, you don't need objectValue at all 
-- neither the data source method nor the property.

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: View Based Table - where is my data?

2013-05-01 Thread Seth Willits
On May 1, 2013, at 8:34 AM, Gerriet M. Denkmann wrote:

> A NSTableView with one column which uses NSTableCellViews. Uses DataSource:
> 
> - (id)tableView:(NSTableView *)aTableView 
> objectValueForTableColumn:(NSTableColumn *)aTableColumn 
> row:(NSInteger)rowIndex

This method does not get used at all.


See the documentation:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/TableView/PopulatingView-TablesProgrammatically/PopulatingView-TablesProgrammatically.html


--
Seth Willits






___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


View Based Table - where is my data?

2013-05-01 Thread Gerriet M. Denkmann
A NSTableView with one column which uses NSTableCellViews. Uses DataSource:

- (id)tableView:(NSTableView *)aTableView 
objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSDictionary *aLine = self.dataArray[rowIndex];
NSTableCellView *cellView = [ aTableView makeViewWithIdentifier: 
@"DieSpalte" owner: self ];
[ cellView.textField setStringValue: aLine[kNameKey] ];
[ cellView.imageView setImage: aLine[kImageKey] ];
NSLog(@"%s %ld %@",__FUNCTION__, rowIndex, cellView);
return cellView;
}

This method gets called as expected and returns non-nil NSTableCellViews.

The Table has the right number of columns, but each column has the same picture 
(NSImageNameActionTemplate?) and the text of every row is: "Table View Cell".
This is NOT what I want to see.
How do I get the table to display my data?

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: How to implement readonly property

2013-05-01 Thread Andreas Grosam
This is a somewhat older but quite interesting thread - nonetheless I felt the 
final conclusion was still too vague.


So, I did my best to put up a simple "worst case" sample and tried to trick 
dispatch_once into a race. But I failed. That is, dispatch_once was doing what 
one would like to expect. While this is eventually no proof, it at least 
increases the probability that certain use cases are "quite safe", for a given 
environment.

Maybe someone else will detect a race? Or perhaps, somebody is able to find an 
even worser worst case? ;)


Note: if a race has been occurred, it would print "x" to stdout.


#include 
#include 
#include 
#include 
struct Bar {

void setResult(long value) {
dispatch_once(&_once, ^{
_result = value;
});
}

long getResult() const {
return _result;
}

dispatch_once_t _once;
long _result;
};


int main(int argc, const char * argv[])
{
dispatch_semaphore_t finished_sem = dispatch_semaphore_create(0);

const int N = 100;
int n = N;
typedef std::aligned_storage::value>::type storage_t;
storage_t storage;

while (n) {
//memset(storage, -1, sizeof(storage));
Bar* bar = new (&storage) Bar();
dispatch_async(dispatch_get_global_queue(0, 0), ^{
bar->setResult(n);
dispatch_semaphore_signal(finished_sem);
});
dispatch_semaphore_wait(finished_sem, DISPATCH_TIME_FOREVER);
if (bar->getResult() != n) {
dispatch_async(dispatch_get_global_queue(0, 0), ^{
printf("x");
});
}
--n;
}

printf("finished");

return 0;
}



Andreas





On 09.12.2012, at 17:52, Ken Thomases wrote:

> On Dec 9, 2012, at 10:37 AM, Kyle Sluder wrote:
> 
>> On Dec 9, 2012, at 6:53 AM, Ken Thomases  wrote:
>> 
>>> On Dec 9, 2012, at 1:27 AM, Kyle Sluder wrote:
>>> 
 If dispatch_once() really is unsuitable for use with a dispatch_once_t
 stored in Objective-C instance storage, then the correct example in the
 paper I've cited might be a sufficient workaround.
>>> 
>>> I thought we had established that, in all sane use cases, an instance 
>>> variable once predicate is fine.
>> 
>> Hence the hedge. ;-)
>> 
>>> The cases where an instance variable once predicate would be unsafe are 
>>> exactly the cases where it would be unsafe to access any instance variable, 
>>> including the isa pointer.  So, if you're using the instance in any way, 
>>> you've already assumed conditions that make the once predicate fine. (And, 
>>> hopefully, you've more than assumed it, you've ensured it by proper 
>>> inter-thread communication of the object pointer.)
>> 
>> Yes, but as Greg pointed out the real danger comes from not understanding 
>> all the nuances of this, and assuming that dispatch_once is a more powerful 
>> synchronization primitive than it really is.
> 
> I'm still not understanding the circumspection.  The use of dispatch_once() 
> never _contributes_ to unsafe access.  It is unsafe if the situation is 
> already unsafe.  If you try to avoid using dispatch_once() using other 
> techniques like @synchronized(self), etc., that doesn't help anything.
> 
> Intellectually, I understand the concern that people will assume that 
> dispatch_once() introduces safety where it doesn't, but as a practical matter 
> I'm finding it hard to imagine a scenario where a) that comes up or b) 
> avoiding dispatch_once() for some vague (to the naive developer) notion that 
> it's unsafe would lead to better safety.  Can you or Greg illustrate with an 
> example?
> 
> I feel that dispatch_once() with an instance variable once predicate _is_ the 
> right answer for the class of problems where people would be tempted to use 
> it and that we should be encouraging developers to rely on it rather than 
> invariably worse alternatives.
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/agrosam%40onlinehome.de
> 
> This email sent to agro...@onlinehome.de


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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