Re: NSPopover + Bindings + Validation = Weirdness

2014-05-26 Thread Jonathan Mitchell
On 26 May 2014, at 01:04, Keary Suska wrote: > I am implementing an editing view in a popover, and discovered that > validations messages will cause exceptions because AppKit is broken in that > regard...anyway so I set "always use application modal alerts" and that seems > to work although t

Prevent NSColorWell gets textColor

2014-05-26 Thread Leonardo
Hi, I have several NSColorWells. One for the textColor, one for the guideColor, one for the pageBackgroundColor. If the pageBackgroundColor colorWell is active while I am editing a text in a NSTextView, the pageBackgroundColor colorWell gets the text color so the page background changes color. And

EXC_BAD_ACCESS in NSData

2014-05-26 Thread Pax
I'm utterly perplexed by this problem because I thought that I'd been so careful in ensuring that my data can be read safely with no problems. This is my snippet of code: [datastream getBytes:&bytes range:NSMakeRange(positionCounter, datasize)]; // Length of packet content

EXC_BAD_ACCESS in NSData

2014-05-26 Thread Pax
I'm utterly perplexed by this problem because I thought that I'd been so careful in ensuring that my data can be read safely with no problems. This is my snippet of code: [datastream getBytes:&bytes range:NSMakeRange(positionCounter, datasize)]; // Length of packet content

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Uli Kusterer
On 26 May 2014, at 06:02, Pax <45rpmli...@googlemail.com> wrote: > This is my snippet of code: >[datastream getBytes:&bytes > range:NSMakeRange(positionCounter, datasize)]; // Length of packet content >positionCounter+= datasize; What is bytes declared as,

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Pax
Apologies - the obvious important detail, and I missed it out entirely. I have tried both of the following with the same result: unsigned char* databuffer = (unsigned char*)malloc(datasize); [datastream getBytes:&databuffer range:NSMakeRange(positionCounter, datasize)]; // Packet content

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Pax
Apologies - the obvious important detail, and I missed it out entirely. I have tried both of the following with the same result: unsigned char* databuffer = (unsigned char*)malloc(datasize); [datastream getBytes:&databuffer range:NSMakeRange(positionCounter, datasize)]; // Packet content

Re: NSPopover + Bindings + Validation = Weirdness

2014-05-26 Thread Keary Suska
On May 26, 2014, at 3:05 AM, Jonathan Mitchell wrote: > > On 26 May 2014, at 01:04, Keary Suska wrote: > >> I am implementing an editing view in a popover, and discovered that >> validations messages will cause exceptions because AppKit is broken in that >> regard...anyway so I set "always us

Re: NSPopover + Bindings + Validation = Weirdness

2014-05-26 Thread Jonathan Mitchell
On 26 May 2014, at 14:50, Keary Suska wrote: > > The bug is triggered when trying to display a sheet on a popover window, so > even if I capture error presentation I would still have to present a modal > alert of some kind. I was hoping the API would do that for me gracefully, but > I was ap

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Sandy McGuffog
Well, I find your code to be a bit confusing, but I’d say that both of those are wrong. I think that what you need is: unsigned char* databuffer = (unsigned char*)malloc(datasize); [datastream getBytes:databuffer range:NSMakeRange(positionCounter, datasize)]; // Packet content On May 26,

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Pax
Just to answer my own question, I find that: bytes=[[datastream subdataWithRange:NSMakeRange(positionCounter, datasize)]bytes]; Works perfectly. I should, I know, find out what was going wrong initially - but since I'd rather not have a copy anyway, this really is the all-round better solution

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Roland King
So you have unsigned char *bytes; and then datasize = (unsigned int)bytes; which sets datasize to the address of bytes cast to an unsigned integer which has nothing to do with the data in bytes at all and in some cases just truncates the address (OSX for instance) datasize = *((unsigned in

UICollectionViewCell and UIScrollView and autolayout

2014-05-26 Thread Torsten Curdt
I've built a little demo project where I am struggling with autolayout. https://github.com/tcurdt/paging-and-zooming I basically have a fullscreen collection view to page through some scroll views that allow zooming into an image. When the UICollectionViewCells are being configured https:/

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Scott Ribe
On May 26, 2014, at 8:43 AM, Pax <45rpmli...@googlemail.com> wrote: > I should, I know, find out what was going wrong initially - but since I'd > rather not have a copy anyway, this really is the all-round better solution. What was wrong was that instead of passing the address of the buffer you

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Roland King
The first one of those is ok - as long as you remember to free databuffer later. The second is wrong, the argument to getBytes:range: has to be an allocated buffer of size at least the length of the range you pass in. That second one is just copying data to a random place in memory, probably zer

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Scott Ribe
On May 26, 2014, at 9:05 AM, Roland King wrote: > The first one of those is ok... No, it's not--take a closer look ;-) > unsigned char* databuffer = (unsigned char*)malloc(datasize); > [datastream getBytes:&databuffer range:NSMakeRange(positionCounter, > datasize)]; -- Scott Ribe scott_r...

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Uli Kusterer
On 26 May 2014, at 06:44, Pax <45rpmli...@googlemail.com> wrote: > Apologies - the obvious important detail, and I missed it out entirely. I > have tried both of the following with the same result: > > unsigned char* databuffer = (unsigned char*)malloc(datasize); > [datastream getBytes:&data

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Roland King
Too true. That was a lot of bugs in 4 lines! > On 26 May, 2014, at 11:18 pm, Scott Ribe wrote: > >> On May 26, 2014, at 9:05 AM, Roland King wrote: >> >> The first one of those is ok... > > No, it's not--take a closer look ;-) > >> unsigned char* databuffer = (unsigned char*)malloc(datasize)

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Scott Ribe
On May 26, 2014, at 9:32 AM, Uli Kusterer wrote: > Oh, and as Roland wrote, don’t forget to free() the pointer once you’re done > with it. But, just to be 100% clear, *not* the one you get from calling the bytes method ;-) -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com

Re: UICollectionViewCell and UIScrollView and autolayout

2014-05-26 Thread Torsten Curdt
OK, so it seems I explicitly need to call [cell setNeedsLayout]; [cell layoutIfNeeded]; after the cell is configured. I didn't think the `layoutIfNeeded` was necessary. That's a bit of a surprise. The centering of the `UIScrollView` is still a bit funky though. Based on the `contentOffs

Re: UICollectionViewCell and UIScrollView and autolayout

2014-05-26 Thread Luke Hiesterman
Why is autolayout assigning a frame to the cell? Are you putting autolayout constraints on your cell? If so, shouldn’t be. The collection view assigns the cell’s frame (according to the wishes of the assigned collectionViewLayout). Setting the frame yourself, either by calling -setFrame or somet

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Pax
Shameful. I need more sleep! :-) I also need to reread my code more carefully before asking questions. As I say though, I think that the solution I posted is the better solution anyway - since who wants a copy, with the additional overhead that a copy entails, when you don't need to have on

Re: UICollectionViewCell and UIScrollView and autolayout

2014-05-26 Thread Torsten Curdt
I am not assigning a frame - but I am indeed assigning constraints to the subviews of the UICollectionViewCell's content view: https://github.com/tcurdt/paging-and-zooming/blob/master/Paging/TCPagingView.m#L17 That is not supported? cheers, Torsten On Mon, May 26, 2014 at 5:59 PM, Luke Hiesterm

Re: UICollectionViewCell and UIScrollView and autolayout

2014-05-26 Thread Luke Hiesterman
That is fine, but the statement made in your original email said “autolayout has assigned a frame to the cell.” You’re free to use autolayout inside the content view - just don’t try to layout the cell itself. Luke On May 26, 2014, at 9:07 AM, Torsten Curdt mailto:tcu...@vafer.org>> wrote: I

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Scott Ribe
On May 26, 2014, at 10:06 AM, Pax <45rpmli...@googlemail.com> wrote: > As I say though, I think that the solution I posted is the better solution > anyway - since who wants a copy, with the additional overhead that a copy > entails, when you don't need to have one? Absolutely. (For read-only ac

Re: UICollectionViewCell and UIScrollView and autolayout

2014-05-26 Thread Torsten Curdt
Ah - so that was the `UICollectionViewFlowLayout` that did that (if understand you correctly)? ___ 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-de

Re: UICollectionViewCell and UIScrollView and autolayout

2014-05-26 Thread Kyle Sluder
> On May 26, 2014, at 12:10 PM, Luke Hiesterman wrote: > > That is fine, but the statement made in your original email said “autolayout > has assigned a frame to the cell.” You’re free to use autolayout inside the > content view - just don’t try to layout the cell itself. In practice, this res

Mutating NSLayoutConstraint -constant at run time

2014-05-26 Thread Jonathan Mitchell
So: 1. I have a NSView V within a view hierarchy. 2. V holds a layout constraint C that offsets a subview S from the bottom edge of V. 3. At runtime I mutate -constant on constraint C. The question is should the view hierarchy automatically recalculate its layout in response to changing the con

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Jens Alfke
On May 26, 2014, at 6:02 AM, Pax <45rpmli...@googlemail.com> wrote: > When this gets run, I get EXC_BAD_ACCESS code = 2 here. I'm demonstrably > reading less data than the file contains, and I've been able to read through > the file successfully up to this point. Please could someone suggest

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Graham Cox
On 27 May 2014, at 12:54 am, Roland King wrote: > datasize = *((unsigned int*)bytes); > > is a bit closer to what you might want but is endian-unaware. That's just as wrong - you are using the first few bytes of the data as the length, which it certainly isn't (except for possibly a very fe

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Jens Alfke
On May 26, 2014, at 4:20 PM, Graham Cox wrote: > That's just as wrong - you are using the first few bytes of the data as the > length, which it certainly isn't (except for possibly a very few special > cases that just so happen to have the length as the first field of the data). No, it’s extr

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Uli Kusterer
On 26 May 2014, at 16:20, Graham Cox wrote: > On 27 May 2014, at 12:54 am, Roland King wrote: >> datasize = *((unsigned int*)bytes); >> >> is a bit closer to what you might want but is endian-unaware. > > That's just as wrong - you are using the first few bytes of the data as the > length, w

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Graham Cox
On 27 May 2014, at 10:13 am, Jens Alfke wrote: > No, it’s extremely common to have a data format where a variable-length field > is prefixed with its length. That looks like what this code is trying to read. Alright, but you have to know that. I was looking at the code from a general standpoi

Re: EXC_BAD_ACCESS in NSData

2014-05-26 Thread Charles Srstka
On May 26, 2014, at 7:43 PM, Uli Kusterer wrote: > Regarding endian-swapping, that depends on the file format. If you wrote that > file yourself, you don’t usually need to do any swapping. That's true. For example, back in the PowerPC days, we never had to endian-swap our file formats, because