Binding to a view's model object
I have a xib with a top-level view and a bunch of subviews which represents one view of a given model object. The top-level NSView subclass has a readwrite property which is the model object of which it's a view. I thought this was a pretty standard pattern, especially in OSX which only just recently started to really make use of view controllers. Many of the subviews just show strings and other values from the model object, and some of them allow editing as well. So what I wanted to do is use bindings to bind modelObject.someStringProperty to the value of one of the text fields, for instance. Doing that would take care of 90% of the easy properties on the model, leaving just a few I'd need to hand-code. However IB doesn't let me make bindings to a property of the top-level view. I can bind to files owner, the shared defaults controller and the application only, or to any other standalone Object I put in the NIB, but none of those help. The view in this case is going in a stack view, which wants an NSView. I thought about moving the logic into a view controller which could be the Files Owner, but I would have then to separately retain those view controllers as their views don't retain them and the stackview just wants the view, so that feels a little clunky. The views are meant to be reusable, hence the single readwrite model object property on the view. Is there a way to do these bindings? Can it be done in IB if so or do I need to call bind:toObject:withKeyPath:options: Is there some other object I could put in the NIB which would intermediate this for me? ___ 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
Trying to create a collection view with evenly distributed cell
Hi, I'm trying to create a 3 cell per row collection, and I want no margin (horizontally or vertically) between each cell. So in xcode I set Min Spacing For Cells / For Lines to 1, Indicator insets (all 4 values) to 0, then I write code like this: - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 9; } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@Cell forIndexPath:indexPath]; [cell setFrame: CGRectMake (cell.frame.origin.x, cell.frame.origin.y, self.collectionView.frame.size.width / 3, cell.frame.size.height)]; cell.backgroundColor = [UIColor whiteColor]; return cell; } If you run that code you will see the horizontal margin still exists and is very huge compared to the vertical one. What's the correct way to do it? -- Best Regards, Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33 ___ 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: Trying to create a collection view with evenly distributed cell
On 25 Jan 2015, at 10:12, Aaron Lewis the.warl0ck.1...@gmail.com wrote: Hi, I'm trying to create a 3 cell per row collection, and I want no margin (horizontally or vertically) between each cell. So in xcode I set Min Spacing For Cells / For Lines to 1, Indicator insets (all 4 values) to 0, then I write code like this: - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 9; } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@Cell forIndexPath:indexPath]; [cell setFrame: CGRectMake (cell.frame.origin.x, cell.frame.origin.y, self.collectionView.frame.size.width / 3, cell.frame.size.height)]; Time to back up and re-learn the basics of collection views. Collection views are in charge of the layout of their cells, including sizing. You don’t get to set the cell’s frame directly. Instead you want to set the collection view’s item size appropriate to match the view’s width. This may help: http://dativestudios.com/blog/2015/01/08/collection_view_layouts_on_wide_phones/ cell.backgroundColor = [UIColor whiteColor]; return cell; } If you run that code you will see the horizontal margin still exists and is very huge compared to the vertical one. What's the correct way to do it? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Detecting Managed Object Property Change From Undo Redo
On 25 Jan 2015, at 06:35, Richard Charles rcharles...@gmail.com wrote: Core Data generated primitive accessors are used to get and set values from and to the managed object's private internal store. Core Data generated primitive accessors do not have change notification. If primitive accessors are present, Core Data will use them during undo and redo. A managed object may have resources that need to be updated when a property changes. During undo and redo primitive accessors are used to change the property but because primitive accessors do not have change notification there is no way for the managed object to be notified that the property has changed. The only solution seems to be to use custom primitive accessors that have change notification. What am I doing wrong? You are mistaken. Core Data *does* fire KVO notifications during undo/redo. Its internal implementation does something along these lines: [object willChangeValueForKey:key]; [object setPrimitiveValue:previousValue forKey:key]; [object didChangeValueForKey:key]; ___ 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: Binding to a view's model object
On 25 Jan 2015, at 10:34, Roland King r...@rols.org wrote: I have a xib with a top-level view and a bunch of subviews which represents one view of a given model object. The top-level NSView subclass has a readwrite property which is the model object of which it's a view. I thought this was a pretty standard pattern, especially in OSX which only just recently started to really make use of view controllers. I would embrace NSViewController and use -representedObject. Bindings + MVC have an established track record and it does correct memory management that can be tricky to get right otherwise. Your pattern is not very MVC at the moment! I can bind to files owner, the shared defaults controller and the application only, or to any other standalone Object I put in the NIB, but none of those help. You can if your file’s owner has an outlet for the top level view (NSViewController does of course): myFilesOwner.myTopLevelView.myObject.myProperty Jonathan ___ 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
Adding constrains for anonymous buttons
Hi, I'm trying to create a label group, so I decided to generate 3 buttons and put them in a single line, evenly sized and evenly spaced. But these buttons are un-named, is it impossible to use constraintsWithVisualFormat now? e.g UIButton *buttons[3]; for (int i = 0; i 3; ++ i) { buttons[i] = [[UIButton alloc] init]; } Is there any suggestion? -- Best Regards, Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33 ___ 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
What's the right way to use UIActivityIndicatorView? After it's stopped
Hi, I'm trying to show another UI Control when the stopAnimation method is called. But in xcode if I drag the UIActivityIndicatorView first, any other UI Control seems to be replacing it. Now it looked like I had to do create the other UI Control and add it manually when the animation is stopped. That is wrong right? What's the suggestion -- Best Regards, Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33 ___ 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: Binding to a view's model object
I think you can bring an object controller into your xib from the IB pallet. Bind the content object of the controller to your NSView subclass and expose the binding of modelObject.someStringProperty through the object controller's attributes inspector panel. The all your subviews will bind to the object controller. This assumes you can make your NSView visible in IB through an NSObject IB widget. Typically, I would have the model in a controller object or delegate object which are more common to materialize in the xib. Sandor Szatmari On Jan 25, 2015, at 05:34, Roland King r...@rols.org wrote: I have a xib with a top-level view and a bunch of subviews which represents one view of a given model object. The top-level NSView subclass has a readwrite property which is the model object of which it's a view. I thought this was a pretty standard pattern, especially in OSX which only just recently started to really make use of view controllers. Many of the subviews just show strings and other values from the model object, and some of them allow editing as well. So what I wanted to do is use bindings to bind modelObject.someStringProperty to the value of one of the text fields, for instance. Doing that would take care of 90% of the easy properties on the model, leaving just a few I'd need to hand-code. However IB doesn't let me make bindings to a property of the top-level view. I can bind to files owner, the shared defaults controller and the application only, or to any other standalone Object I put in the NIB, but none of those help. The view in this case is going in a stack view, which wants an NSView. I thought about moving the logic into a view controller which could be the Files Owner, but I would have then to separately retain those view controllers as their views don't retain them and the stackview just wants the view, so that feels a little clunky. The views are meant to be reusable, hence the single readwrite model object property on the view. Is there a way to do these bindings? Can it be done in IB if so or do I need to call bind:toObject:withKeyPath:options: Is there some other object I could put in the NIB which would intermediate this for me? ___ 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/admin.szatmari.net%40gmail.com This email sent to admin.szatmari@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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding to a view's model object
On Jan 25, 2015, at 3:34 AM, Roland King r...@rols.org wrote: I have a xib with a top-level view and a bunch of subviews which represents one view of a given model object. The top-level NSView subclass has a readwrite property which is the model object of which it's a view. I thought this was a pretty standard pattern, especially in OSX which only just recently started to really make use of view controllers. There is nothing standard about this pattern. It is not, AFAIK, a pattern at all, but an anti-pattern. Previous to a view controller the only view controller was a window controller, and finer grained control was necessary. For this very purpose it is the view controller, and not its view, which tends to hold the model object. Hence Xcode is balking at your attempts. Many of the subviews just show strings and other values from the model object, and some of them allow editing as well. So what I wanted to do is use bindings to bind modelObject.someStringProperty to the value of one of the text fields, for instance. Doing that would take care of 90% of the easy properties on the model, leaving just a few I'd need to hand-code. However IB doesn't let me make bindings to a property of the top-level view. I can bind to files owner, the shared defaults controller and the application only, or to any other standalone Object I put in the NIB, but none of those help. Yes--that's MVC. Views should only bind to controllers, not other views. The view in this case is going in a stack view, which wants an NSView. I thought about moving the logic into a view controller which could be the Files Owner, but I would have then to separately retain those view controllers as their views don't retain them and the stackview just wants the view, so that feels a little clunky. The views are meant to be reusable, hence the single readwrite model object property on the view. Someone has to own the xib, why not have it serve up the model object? Or own the NSViewController(s) that do? These would represent standard patterns and don't seem clunky. Note, however, that objects of NSWindowController and NSViewController have some built-in binding break-down when they are released, and are usually more bindings-friendly. Is there a way to do these bindings? Can it be done in IB if so or do I need to call bind:toObject:withKeyPath:options: Is there some other object I could put in the NIB which would intermediate this for me? Well, it's hard to say since you haven't listed the items that you don't believe you can use bindings for, but in general, yes, more or less. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Crash in libsystem_kernel.dylib`__workq_kernreturn:
On Jan 25, 2015, at 12:33 , Trygve Inda cocoa...@xericdesign.com wrote: It does seem like if I remove a call to NSData* imageData = [[self myImageRep] representationUsingType:NSJPEGFileType properties:imageProperties]; It no longer crashes, but the crash happens 3-5 seconds after this call when my program should be idle. It sounds like a memory management bug. What’s the context of the above line of code? Is it in a block? Are you using ARC? No ARC and not in a block. I am trying to make a jpg file from a NSBitmapImageRep which works fine, but sometimes I get a crash... Even though the file is correctly produced. ___ 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: Detecting Managed Object Property Change From Undo Redo
On 2015 Jan 25, at 01:20, Mike Abdullah mabdul...@karelia.com wrote: You are mistaken. Core Data *does* fire KVO notifications during undo/redo. Although I wasn’t aware of this, I just did a little experiment and found that Mike is correct… http://youtu.be/PUHBAq-Me_4 On 25 Jan 2015, at 06:35, Richard Charles rcharles...@gmail.com wrote: The only solution seems to be to use custom primitive accessors that have change notification. What am I doing wrong? I would not override the primitive accessors; instead I would override the regular accessors, or if you are using mogenerator, that has already been done for you. The reason I had to run that test is because I don’t use KVO for observing managed object properties. Instead, I use NSNotificationCenter, which has these advantages… • Amount of code required is the same or less • Ability to coalesce and filter notifications per object or name • When an observer is being torn down you can remove all observers with one line of code, [NSNotificationCenter removeObserver:self]. With KVO, if I recall correctly, you need to remember and remove each observance, arg. Just my two cents. There are many ways to do this. ___ 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
Any way to force a window under the menu bar?
I have created a borderless NSWindow. Is there a way to force it to appear under the menu bar so that the content of the window shows through the translucent menu bar? The OS seems to be resizing or repositioning my window to prevent it from sliding under the menu bar even when positioned programmatically (ie not dragging). Thanks, Trygve ___ 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: Any way to force a window under the menu bar?
On Jan 25, 2015, at 8:39 PM, Trygve Inda cocoa...@xericdesign.com wrote: I have created a borderless NSWindow. Is there a way to force it to appear under the menu bar so that the content of the window shows through the translucent menu bar? Even if you force it under the menubar, you won’t see its content show up in the menubar; the menubar window pulls its blurred content exclusively from the desktop image. -eric ___ 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: Detecting Managed Object Property Change From Undo Redo
On Sun, Jan 25, 2015, at 05:16 PM, Jerry Krinock wrote: • Amount of code required is the same or less • Ability to coalesce and filter notifications per object or name • When an observer is being torn down you can remove all observers with one line of code, [NSNotificationCenter removeObserver:self]. This is a dangerous API. If your superclass has registered for any observations, you will unregister before your superclass hears about it. With KVO, if I recall correctly, you need to remember and remove each observance, arg. You can use the magic of C's sizeof keyword to avoid repeating yourself for each observed keypath: static void *observationContext = observationContext; static NSString *observedKeypaths[] = {@prop1, @prop2}; - (void)startObservingModelObject:(MyModelObject *)obj { for (int i = 0; i sizeof(observedKeypaths) / sizeof(*observedKeypaths); i++) [obj addObserver:self forKeyPath:observedKeypaths[i] options:0 context:observationContext]; } - (void)stopObservingModelObject:(MyModelObject *)obj { for (int i = 0; i sizeof(observedKeypaths) / sizeof(*observedKeypaths); i++) [obj removeObserver:self forKeyPath:observedKeypaths[i] context:observationContext]; } --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding to a view's model object
On Jan 25, 2015, at 6:07 PM, Roland King r...@rols.org wrote: On 25 Jan 2015, at 23:15, Keary Suska cocoa-...@esoteritech.com wrote: On Jan 25, 2015, at 3:34 AM, Roland King r...@rols.org wrote: I have a xib with a top-level view and a bunch of subviews which represents one view of a given model object. The top-level NSView subclass has a readwrite property which is the model object of which it's a view. I thought this was a pretty standard pattern, especially in OSX which only just recently started to really make use of view controllers. There is nothing standard about this pattern. It is not, AFAIK, a pattern at all, but an anti-pattern. Previous to a view controller the only view controller was a window controller, and finer grained control was necessary. For this very purpose it is the view controller, and not its view, which tends to hold the model object. Hence Xcode is balking at your attempts. And yet I was certain I'd stolen it from somewhere, and woke up remembering where. NSTableCellView, is a view, has an objectValue property. When you drag an NSTableCellView into IB and add subviews to it, the bindings inspector dropdown for those subviews includes the table cell view, called something like XXX Cell View. So you bind to 'XXX cell view' with path 'objectValue.someProperty'. The NSTableCellView is really the VC and objectValue is the model object. Of course--in this case, NSTableCellView is really just acting as an intermediary for its subviews. In a way, the subviews are really binding *through* NSTableCellView , although it is hiding those implementation details. That may be what you are after but it didn't seem to be what you were describing. What I have is a direct rip off of that pattern. I've embedded a stack view in a class and given it a datasource which serves up NSView subclasses for an item at a given index, you can register a nib against an identifier and ask the class to create you a new view or give you a reused one. The method names are even stolen pretty much straight from NSTableView. It's like an NSTableView or a NSOutlineView in usage, just uses a stack view under the hood (because stack view uses autolayout and this makes dynamic row sizing etc super easy when you have rows which use autolayout). IB however knows about NSTableCellViews and adds them into the bindings inspector dropdown for their subviews, it doesn't know about my top-level view class, RKStackCellView, and doesn't. I can add them in awakeFromNib pretty easily, do in code what IB does for NSTableCellViews graphically, or I could change my datasource method from returning an NSView*, like NSTableView's does, to returning a view controller, and then keep track of the VCs and their associated views in my stack view using class, as the stack view only wants the NSView but I'd need to keep the VCs referenced somehow to stop them being deallocated. I'll try them both, see which one I like best. You can do what you want, you would just have to manage the bindings programmatically. It still seems easier to me--and possibly saner--for each view to have a VC that holds the model, and to which the subviews are bound. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Detecting Managed Object Property Change From Undo Redo
On 2015 Jan 25, at 22:03, Kyle Sluder k...@ksluder.com wrote: On Sun, Jan 25, 2015, at 05:16 PM, Jerry Krinock wrote: • When an observer is being torn down you can remove all observers with one line of code, [NSNotificationCenter removeObserver:self]. This is a dangerous API. If your superclass has registered for any observations, you will unregister before your superclass hears about it. I see what you mean, that if the superclass needed for some reason to receive some notification at the bitter end of an object’s life, that line of code would break it. I’m trying to imagine such a requirement. Maybe to push changes to a data model in a view that was editing? But we have various -endEditing methods for that. On the other hand, I’ve seen many crashes occur from not removing observers early enough. In general, as soon as it’s confirmed that an object is going away, the very first thing I do is to remove all of its observances. It has worked for me, but from now on I’ll think about what you said. You can use the magic of C's sizeof keyword to avoid repeating yourself for each observed keypath: And C arrays. Very cool, Kyle. ___ 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
[RESOLVED] Re: Trying to create a collection view with evenly distributed cell
Thanks Mike, I followed the tutorial and did the exact same thing in objc, works. On Sun, Jan 25, 2015 at 6:21 PM, Mike Abdullah mabdul...@karelia.com wrote: On 25 Jan 2015, at 10:12, Aaron Lewis the.warl0ck.1...@gmail.com wrote: Hi, I'm trying to create a 3 cell per row collection, and I want no margin (horizontally or vertically) between each cell. So in xcode I set Min Spacing For Cells / For Lines to 1, Indicator insets (all 4 values) to 0, then I write code like this: - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 9; } - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return 1; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ CollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@Cell forIndexPath:indexPath]; [cell setFrame: CGRectMake (cell.frame.origin.x, cell.frame.origin.y, self.collectionView.frame.size.width / 3, cell.frame.size.height)]; Time to back up and re-learn the basics of collection views. Collection views are in charge of the layout of their cells, including sizing. You don’t get to set the cell’s frame directly. Instead you want to set the collection view’s item size appropriate to match the view’s width. This may help: http://dativestudios.com/blog/2015/01/08/collection_view_layouts_on_wide_phones/ cell.backgroundColor = [UIColor whiteColor]; return cell; } If you run that code you will see the horizontal margin still exists and is very huge compared to the vertical one. What's the correct way to do it? -- Best Regards, Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/ Finger Print: 9F67 391B B770 8FF6 99DC D92D 87F6 2602 1371 4D33 ___ 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: Adding constrains for anonymous buttons
On 25 Jan 2015, at 7:32 am, Aaron Lewis the.warl0ck.1...@gmail.com wrote: I'm trying to create a label group, so I decided to generate 3 buttons and put them in a single line, evenly sized and evenly spaced. What do you mean by label group? Would UILabel be more suitable than UIButton? (I presume that your for-loop preamble was just illustrative, since it seems atypical to assign buttons into a C array and without any target/action.) But these buttons are un-named, is it impossible to use constraintsWithVisualFormat now? e.g Given your code, what about something like this: NSString *format = @|[button0][button1(==button0)][button2(==button0)]|; NSDictionary *views = @{ @button0 : buttons[0], @button1 : buttons[1], @button2 : buttons[2], }; NSArray *constrants = [NSLayoutConstraint constraintsWithVisualFormat:format options:0L metrics:nil views:views]; b -- Ben Kennedy, chief magician Zygoat Creative Technical Services http://www.zygoat.ca ___ 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: Crash in libsystem_kernel.dylib`__workq_kernreturn:
On Jan 25, 2015, at 12:33 , Trygve Inda cocoa...@xericdesign.com wrote: It does seem like if I remove a call to NSData* imageData = [[self myImageRep] representationUsingType:NSJPEGFileType properties:imageProperties]; It no longer crashes, but the crash happens 3-5 seconds after this call when my program should be idle. It sounds like a memory management bug. What’s the context of the above line of code? Is it in a block? Are you using ARC? ___ 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: Crash in libsystem_kernel.dylib`__workq_kernreturn:
What are you using for memory management then? Manual, GC? Sent from my iPad On 25 Jan 2015, at 22:57, Trygve Inda cocoa...@xericdesign.com wrote: On Jan 25, 2015, at 12:33 , Trygve Inda cocoa...@xericdesign.com wrote: It does seem like if I remove a call to NSData* imageData = [[self myImageRep] representationUsingType:NSJPEGFileType properties:imageProperties]; It no longer crashes, but the crash happens 3-5 seconds after this call when my program should be idle. It sounds like a memory management bug. What’s the context of the above line of code? Is it in a block? Are you using ARC? No ARC and not in a block. I am trying to make a jpg file from a NSBitmapImageRep which works fine, but sometimes I get a crash... Even though the file is correctly produced. ___ 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/ktam%40yvs.eu.com This email sent to k...@yvs.eu.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Crash in libsystem_kernel.dylib`__workq_kernreturn:
What are you using for memory management then? Manual, GC? Sent from my iPad On 25 Jan 2015, at 22:57, Trygve Inda cocoa...@xericdesign.com wrote: On Jan 25, 2015, at 12:33 , Trygve Inda cocoa...@xericdesign.com wrote: It does seem like if I remove a call to NSData* imageData = [[self myImageRep] representationUsingType:NSJPEGFileType properties:imageProperties]; It no longer crashes, but the crash happens 3-5 seconds after this call when my program should be idle. It sounds like a memory management bug. What’s the context of the above line of code? Is it in a block? Are you using ARC? No ARC and not in a block. I am trying to make a jpg file from a NSBitmapImageRep which works fine, but sometimes I get a crash... Even though the file is correctly produced. Manual (no GC). I am also using memory-mapped files with mmap and munmap. Trygve ___ 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: Crash in libsystem_kernel.dylib`__workq_kernreturn:
I agree that it sounds like a memory management bug. Especially since you aren't using ARC. Try turning on NSZombies and see if it crashes at a more helpful point. http://michalstawarz.pl/2014/02/22/debug-exc_bad_access-nszombie-xcode-5/ On Sun, Jan 25, 2015 at 4:57 PM, Trygve Inda cocoa...@xericdesign.com wrote: On Jan 25, 2015, at 12:33 , Trygve Inda cocoa...@xericdesign.com wrote: It does seem like if I remove a call to NSData* imageData = [[self myImageRep] representationUsingType:NSJPEGFileType properties:imageProperties]; It no longer crashes, but the crash happens 3-5 seconds after this call when my program should be idle. It sounds like a memory management bug. What’s the context of the above line of code? Is it in a block? Are you using ARC? No ARC and not in a block. I am trying to make a jpg file from a NSBitmapImageRep which works fine, but sometimes I get a crash... Even though the file is correctly produced. ___ 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/stephen.butler%40gmail.com This email sent to stephen.but...@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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Binding to a view's model object
On 25 Jan 2015, at 23:15, Keary Suska cocoa-...@esoteritech.com wrote: On Jan 25, 2015, at 3:34 AM, Roland King r...@rols.org wrote: I have a xib with a top-level view and a bunch of subviews which represents one view of a given model object. The top-level NSView subclass has a readwrite property which is the model object of which it's a view. I thought this was a pretty standard pattern, especially in OSX which only just recently started to really make use of view controllers. There is nothing standard about this pattern. It is not, AFAIK, a pattern at all, but an anti-pattern. Previous to a view controller the only view controller was a window controller, and finer grained control was necessary. For this very purpose it is the view controller, and not its view, which tends to hold the model object. Hence Xcode is balking at your attempts. And yet I was certain I'd stolen it from somewhere, and woke up remembering where. NSTableCellView, is a view, has an objectValue property. When you drag an NSTableCellView into IB and add subviews to it, the bindings inspector dropdown for those subviews includes the table cell view, called something like XXX Cell View. So you bind to 'XXX cell view' with path 'objectValue.someProperty'. The NSTableCellView is really the VC and objectValue is the model object. What I have is a direct rip off of that pattern. I've embedded a stack view in a class and given it a datasource which serves up NSView subclasses for an item at a given index, you can register a nib against an identifier and ask the class to create you a new view or give you a reused one. The method names are even stolen pretty much straight from NSTableView. It's like an NSTableView or a NSOutlineView in usage, just uses a stack view under the hood (because stack view uses autolayout and this makes dynamic row sizing etc super easy when you have rows which use autolayout). IB however knows about NSTableCellViews and adds them into the bindings inspector dropdown for their subviews, it doesn't know about my top-level view class, RKStackCellView, and doesn't. I can add them in awakeFromNib pretty easily, do in code what IB does for NSTableCellViews graphically, or I could change my datasource method from returning an NSView*, like NSTableView's does, to returning a view controller, and then keep track of the VCs and their associated views in my stack view using class, as the stack view only wants the NSView but I'd need to keep the VCs referenced somehow to stop them being deallocated. I'll try them both, see which one I like best. ___ 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
Crash in libsystem_kernel.dylib`__workq_kernreturn:
I am getting a very weird, random crash in: libsystem_kernel.dylib`__workq_kernreturn: 0x7fff8381de60: movl $0x2000170, %eax 0x7fff8381de65: movq %rcx, %r10 0x7fff8381de68: syscall 0x7fff8381de6a: jae0x7fff8381de74; __workq_kernreturn + 20 0x7fff8381de6c: movq %rax, %rdi 0x7fff8381de6f: jmp0x7fff8381a175; cerror_nocancel 0x7fff8381de74: retq 0x7fff8381de75: nop 0x7fff8381de76: nop 0x7fff8381de77: nop How can I track this down since it does not seem to be tied to anything specific. It does seem like if I remove a call to NSData* imageData = [[self myImageRep] representationUsingType:NSJPEGFileType properties:imageProperties]; It no longer crashes, but the crash happens 3-5 seconds after this call when my program should be idle. Thanks Never seen anything like this and have spent several hours trying to track it down. Trygve ___ 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: setApplicationIconImage:
Got it Jens and thanks everyone for the help it’s much appreciated… :-) On Jan 24, 2015, at 1:05 AM, Jens Alfke j...@mooseyard.com wrote: On Jan 23, 2015, at 1:53 AM, Rick C. rickcort...@gmail.com mailto:rickcort...@gmail.com wrote: Unfortunately setApplicationIconImage: works great it’s just I can’t find a method to put it in that will cause the change before the app launches. It always takes place a second after the app launches… What you're asking for is impossible, because -setApplicationIconImage is a TEMPORARY change to the icon that only takes effect when the method is called, and goes away when the app quits. Read that word again: TEMPORARY. We explained this to you already. If you ask questions and then ignore the answers, it makes people less likely to help you in the future. :-p —Jens ___ 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