Re: Root URL and URLByDeletingLastPathComponent

2016-07-18 Thread thatsanicehatyouhave

On Jul 18, 2016, at 7:37 AM, Mike Abdullah  wrote:

> Fair enough, thanks! I would say then yes, it’s a mismatch between the docs 
> and the implementation.
> 
> File a radar, but don’t expect the real-world behaviour to change, especially 
> any time soon! It’s far more likely they will declare it to be a mistake in 
> the docs and correct those.

Done: rdar://problem/27405026 if anyone comes across this and wants to +1 it.

Thanks,
Demitri
___

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: Root URL and URLByDeletingLastPathComponent

2016-07-17 Thread thatsanicehatyouhave
Hi,

On Jul 17, 2016, at 6:30 AM, Mike Abdullah  wrote:

> It might be a mishandling of the two sorts of rot URL. If you try feeding in 
> this URL manually:
> 
> file://localhost/
> 
> and removing the last component, what do you end up with?

That just treats it as a file called "localhost" in the current directory.

NSURL *rootURL = [NSURL fileURLWithPath:@"localhost"];
NSLog(@"%@", rootURL.path);
NSLog(@"%@", [rootURL URLByDeletingLastPathComponent].path);

Output:

2016-07-17 09:47:06.867 RootURLTest[88149:5248066] 
/Users/demitri/Library/Developer/Xcode/DerivedData/RootURLTest-fbffessbrdfkihacrrlbhzzsoumv/Build/Products/Debug/localhost
2016-07-17 09:47:06.868 RootURLTest[88149:5248066] 
/Users/demitri/Library/Developer/Xcode/DerivedData/RootURLTest-fbffessbrdfkihacrrlbhzzsoumv/Build/Products/Debug

Demitri
___

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

Root URL and URLByDeletingLastPathComponent

2016-07-16 Thread thatsanicehatyouhave
Hello,

Sanity check here. I have this code:

NSURL *rootURL = [NSURL fileURLWithPath:@"/"];
NSLog(@"%@", rootURL, [rootURL URLByDeletingLastPathComponent]);

Based on the NSURL documentation:

> If the receiver’s URL represents the root path, this property contains a copy 
> of the original URL. 

I'd expect the output to be:

file:///, file:///

Instead, I get this:

file:///, file:///../

Am I misunderstanding something here, or is this a bug? Technically, if you "cd 
../" from root you stay at root, but this is still contradicting the 
documentation.

Cheers,
Demitri



___

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: Yosemite NSCollectionView appropriate for spreadsheet-like view?

2016-05-03 Thread thatsanicehatyouhave

On May 3, 2016, at 2:53 PM, Jens Alfke  wrote:

> No, because it eagerly creates a view for every item in the collection. So if 
> you have a spreadsheet with 100,000 cells, it’s going to create 100,000 
> NSViews when the window opens.

I should have been more specific - my understanding was that NSCollectionView 
from 10.11 onward did not do this... which Alex Kac just beat me to mentioning! 
I was curious if anyone was aware of limitations of this scope with that caveat.

I will note that I found this by Matt Ball which looks interesting:

https://github.com/mattball/mbtablegrid/

While seven years old (and a bit glitchy) it does compile. Tommy van der Vorst 
forked it a while back and has updated it, so for anyone looking this is a 
great starting point. Well, actually pretty complete as it's used in a shipping 
product.

https://github.com/pixelspark/mbtablegrid

Cheers,
Demitri
___

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

Yosemite NSCollectionView appropriate for spreadsheet-like view?

2016-05-01 Thread thatsanicehatyouhave
Hi,

I have an NSTableView that may sometimes be called upon to display very large 
amounts of data. I can handle this in the vertical aspect - while my data 
source may have many thousands of rows, I only load batches of 500 at a time, 
and NSTableView doesn't slow down for rows not displayed. This is not true for 
columns, however. My performance/responsiveness is great below some number of 
columns (~15), but increase this much more (e.g. 200) and the performance lags. 
My guess is that since the basic unit here is NSTableRowView, all of the 
columns are loaded into each row view whether they are on the screen or not.

As I've been thinking about this problem it occurred to me that the new(ish) 
NSCollectionView might be a viable replacement in this case. Before I go down 
the rabbit hole, is it reasonable to use to create a spreadsheet-like view? 
What I'd like from this view is basically what you'd find in a spreadsheet - 
horizontal and vertical headers that scroll, editable cells, discontiguous 
selection, and high performance regardless of the number of data points.

(As a note; I am aware that displaying tens of thousands of cells in a view 
isn't immediately useful from a UI point of view and I have two preferred views 
as an alternate, but sometimes you just want to access the raw values.)

Cheers,
Demitri


___

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: LGPL code in the Mac App Store?

2016-01-29 Thread thatsanicehatyouhave

On Jan 29, 2016, at 11:37 AM, Dru Satori  wrote:

> Keep in mind that LGPL restrictions got tighter in v3, and I know there 
> remain many projects out there that are LGPL but have refused v3 for these 
> reasons.

True. Based on my understanding, what I outlined should satisfy both v2 and v3.

One thing I forget to add; probably the *very best way* to address this issue 
is to contact the library author and say, “Hey, I want to use your LGPL code in 
my Mac app and put it on the App Store; is that ok? Do you mind if people can’t 
dynamically link their own copy, because really, no one will want to?” 
(Unfortunately, that hasn’t been an option for me to date.)

Cheers,
Demitri
___

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: LGPL code in the Mac App Store?

2016-01-29 Thread thatsanicehatyouhave
Hi,

Thanks to everyone who answered or commented on this question. This is my 
understanding of one path forward. (And everybody sing along, I am not a 
lawyer, and the fact that the license is so convoluted that almost literally 
everyone feels the need to make this disclaimer is one of the things that 
really annoys me about GPL…).

* LGPL code should be placed into its own framework and be dynamically loaded.
* It can be distributed in this manner in the Mac App Store.
* Create an Xcode project that builds the framework (along with the source 
files) into a public GitHub repository. Make this a dependency of your 
application project.
* Mac App Store apps cannot load executable code not signed (i.e. delivered) by 
the app.
* The LGPL license requires that users have the ability to modify the LGPL part 
and link that to the app. Users are free to download the framework source from 
GitHub, modify it (without changing the API) and build it. They can then strip 
all the code signing from the app, replace the framework in the app bundle, and 
run. This should satisfy the letter of the license. (Of course no one will ever 
do this. I am assuming this process doesn’t strip the DRM as well!)

I’d be happy to hear about a better/easier way to satisfy the last point while 
still distributing through the App Store.

Cheers,
Demitri


___

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

LGPL code in the Mac App Store?

2016-01-26 Thread thatsanicehatyouhave
Hi,

I’m working on a program that I will be submitting to the Mac App Store that 
uses LGPL code. I have recently learned that the license requires the 
capability for the end user to create their own version of the LGPL library to 
link against the application (I have been compiling the source directly into 
the library). This means at run time I need to either load the library from 
what I provide in the application bundle (default, obviously), or, if present, 
load one that the user provides. I can imagine wrapping the library in a 
framework could be an answer. It would be up to the user to build a framework 
in the correct format (I could easily make an Xcode project to do so available 
on GitHub).

Is this possible/allowed for an App Store application? If so, is this the best 
approach? How would I load the library at runtime given that I normally link 
against it when I build the application?

Cheers,
Demitri
___

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

Caching CIContext?

2015-11-27 Thread thatsanicehatyouhave
Hi,

I have an NSImageView with a custom drawing routine. It works as expected most 
of the time, but sometimes the image is not drawn - the reason was not obvious. 
Once when this happened, I opened a popover window and saw that image drawn in 
its background, so it appears I’m doing something incorrect with the context.

This view draws a lot, and I heard in a WWDC video that it’s a good idea to 
cache the context as it’s “expensive” to create. It looks roughly like this:

- (CIContext*)ciContext
{
if (_ciContext == nil) {
CGContextRef cgContext;
if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_10) {
// anything up to 10.9.x
cgContext = NSGraphicsContext.currentContext.graphicsPort;
} else {
// 10.10 or higher
cgContext = NSGraphicsContext.currentContext.CGContext;
}

# create context
_ciContext = [CIContext contextWithCGContext:cgContext ...
}
return _ciContext;
}

In drawRect:, I use CoreImage to create a CIImage, draw it, then draw an 
overlay on top of that:

- (void)drawRect:(NSRect)dirtyRect
{
// ... build image, then draw:
[self.ciContext drawImage:image inRect:inRect fromRect:image.extent];

// draw overlay, obtaining the CGContextRef the same way as in the 
CIContext above.
}

Another data point: the image overlay is *always* drawn; the CIImage sometimes 
is not.

Is it appropriate to cache a CIContext in this way? It feels like I’m missing a 
lock/unlock, store/restore, or losing the context somewhere, but I’m not sure 
exactly the correct approach.

Thanks!

Demitri



___

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

Draggable area of NSPopover

2015-08-12 Thread thatsanicehatyouhave
Hi,

I’ve implemented an NSPopover. Currently part of the view is empty, and part 
contains a graph (of class CPTGraphHostingView, an NSView subclass from Core 
Plot). When the popover is attached, the entire view is draggable, which means 
I can’t interact with the plot as the mouse events are being captured. (The 
cursor changes appropriately when moved over certain graph elements.)

When detached, I can interact with the view as expected. I’m using two 
instances of the same NSViewController class. I subclassed CPTGraphHostingView 
to override the “opaque” property to always return TRUE, but this made no 
difference.

What am I missing to be able to interact with my graph while the popover window 
is attached?

Thanks,
Demitri
___

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

Auto Layout with NSSplitView, NSScrollView

2014-01-04 Thread thatsanicehatyouhave
Hi,

I have a couple of questions about using auto layout (AL) with NSSplitView and 
NSScrollView. I have watched the (excellent) WWDC videos from 2012, but am 
having problems.

I'm trying to implement an NSSplitView (not a custom view that's similar to 
NSSplitView) and want to retain the behavior I expect from it, particularly 
being able to set a minimum width on a pane such that when I drag a divider far 
enough to close it, it will collapse. Easy enough with delegate methods, not at 
all clear with auto layout. Similarly, I'd like to have a button to toggle such 
a view and am not sure how to do that with auto layout as well. It seems to me 
that one could replace several of the delegate methods with constraints, but at 
least the same amount of code will have to be written to reproduce the original 
behavior.

I have not been able to find any sample code online that demonstrates this. To 
this end, I've created a sample project on GitHub. If anyone can help me with 
this, I'll be happy to implement it in the demo project to help anyone else 
with the same problem.

https://github.com/demitri/SplitViewAutoLayout

Secondly, I have a button that loads a large image into an NSScrollView into 
one of the split view's panes. I have a slider to scale the image down. As the 
image scales, I'd like it to remain centered. I have this working with auto 
layout, but the container NSImageView is not resizing. It needs to resize down 
to but not smaller than the clip view (I want to show a background color). Can 
someone suggest how to do this as well?

Thanks for any help, and hopefully this can help others as well.

Cheers,
Demitri
___

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: Getting mouse events in view placed in NSTableRowView

2012-11-23 Thread thatsanicehatyouhave
Hi Kyle,

Thanks for the comments.

On Nov 23, 2012, at 3:32 PM, Kyle Sluder  wrote:

> Are you sure you don't want to make it a subview of the cell view instead?

Sorry, I should have mentioned; I want the cell view that I click to remain 
where it is, and the custom detail view will be rather large and span multiple 
columns, so it can't be a subview of any single cell view.

>> Stepping through the debugger, I see that my NSTableRowView subclass is 
>> indeed being used, that it contains no other subviews than all of the 
>> NSTableRowView instances for each column plus the one I manually added. I 
>> put an NSLog statement in the NSTableRowView's mouseDown method, but no 
>> mouse downs are being recorded in the open space created by updating the 
>> height of the table. I have called "noteHeightOfRowsWithIndexesChanged" when 
>> making these changes.
> 
> You seem to be confusing NSTableCellView with NSTableRowView.

Typo above, I meant to say that the NSTableRowView contains only the expected 
NSTableCellView instances (one for each column) plus the custom view I added.

>> Where are the mouse clicks going!?? This is driving me batty.
> 
> You could try breaking on -[NSTableView hitTest:] and see what return value 
> it puts in %rax on return. Or just compute a point within your control's 
> frame and call -hitTest: from the debugger.

I tried hit test in a point that should be in my custom view, and it returned 
the NSTableView. I don't understand why the event seems to pass through my 
custom view and the NSTableRowView.

Cheers,
Demitri

___

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


Getting mouse events in view placed in NSTableRowView

2012-11-23 Thread thatsanicehatyouhave
Hi,

I'm having a problem with a subclass of NSTableRowView I'm trying to implement. 
I have custom NSTableCellView that contains a button. When I press the button, 
I want that row to expand in height. I would like to then place a custom NSView 
into that new space (think of it as a detail view of the cell that was clicked).

I created an NSTableRowView subclass, but currently have no custom code (except 
to trap mouse events and immediately call "super" with them). When the button 
is clicked, I add my custom view as a subview of my custom NSTableRowView, and 
it appears. The problem is that this custom view does not see any mouse events. 
As a simple test, I placed a slider control into the view, but I can't move it.

Stepping through the debugger, I see that my NSTableRowView subclass is indeed 
being used, that it contains no other subviews than all of the NSTableRowView 
instances for each column plus the one I manually added. I put an NSLog 
statement in the NSTableRowView's mouseDown method, but no mouse downs are 
being recorded in the open space created by updating the height of the table. I 
have called "noteHeightOfRowsWithIndexesChanged" when making these changes.

Where are the mouse clicks going!?? This is driving me batty.

Cheers,
Demitri
___

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


Bulletproof way to create a new CGBitmapContext from an existing image?

2009-11-02 Thread thatsanicehatyouhave

Hi,

I have some code where I'm downloading images from the internet.  
They're probably all going to be jpegs, but I'm not making that  
assumption in my code. I have no control over the images. I'm creating  
a CGBitmapContext to manipulate them. Further, I'm scaling the image  
(could be up or down depending on the original size) by creating the  
context with the size I want and drawing the original image into that.


I'm trying to write code to avoid messages such as this:

: CGBitmapContextCreate: unsupported parameter combination: 8  
integer bits/component; 16 bits/pixel; 1-component colorspace;  
kCGImageAlphaPremultipliedFirst; 352 bytes/row.


I only rarely get these now, but I want to make that "never". I'm  
pasting my code below that I have so far - can anyone suggest  
something better? (I'm working on an iPhone if it makes any difference.)


Cheers,
Demitri

size_t bitsPerComponent = CGImageGetBitsPerComponent(image.CGImage);
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);

// The value returned by CGImageGetBytesPerRow might be smaller than  
the final

// image if we are scaling to a larger size.
float contextWidth = (float)ceil((double)scaleX*image.size.width) * 4.0;
int bytesPerRow = (CGImageGetBytesPerRow(image.CGImage) >  
contextWidth) ? CGImageGetBytesPerRow(image.CGImage)


: contextWidth;

context = CGBitmapContextCreate(NULL, // let the OS manage the memory  
for me

// image 
dimensions (desired width, desired height)

scaleFactorX*image.size.width, scaleFactorY*image.size.height,

bitsPerComponent,
bytesPerRow,
colorSpace,

kCGImageAlphaPremultipliedFirst);


___

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


NSDateFormatter and NSCell oddness

2008-07-08 Thread thatsanicehatyouhave

Hello,

I'm trying to replicate the Finder's behaviour for date fields when  
resizing. I found this on the archives which pretty much has the answer:


http://www.cocoabuilder.com/archive/message/cocoa/2005/8/9/143911

I'm trying to update it so that it returns the correct value for the  
current localisation. This is the full code of my NSCell subclass  
(debugging commented out):


@implementation DMSquishableDateCell

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
{
	NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]  
autorelease];
	[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; //  
needed?


int width = cellFrame.size.width;

if (width < 130)
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
else if (width < 145)
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
else // if (width < 170)
[dateFormatter setDateStyle:NSDateFormatterLongStyle];

[dateFormatter setTimeStyle:NSDateFormatterNoStyle];

[self setFormatter:dateFormatter];
[super drawWithFrame:cellFrame inView:controlView];

	//NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate: 
118800];

//NSLog(@"formatted date: %@", [dateFormatter stringFromDate:date]);

//  if ([self hasValidObjectValue])
//		 NSLog(@"formatted date: %@", [dateFormatter stringFromDate:[self  
objectValue]]);

}

@end

In my awakeFromNib: method where the table is created, I set the cell  
thusly:


DMSquishableDateCell *dateCell = [[[DMSquishableDateCell alloc] init]  
autorelease];
NSTableColumn *creationDateColumn = [table  
tableColumnWithIdentifier:@"creation_date"];

[creationDateColumn setDataCell:dateCell];

However, the column is completely blank. If I remove the three lines  
above, the dates are properly displayed. The lines that I've commented  
above verify that the formatter itself is working properly. The cell  
objects come straight from CoreData, and seem to be objects of class  
"__NSCFDate".


What am I doing wrong?!?

Thanks!

Demitri

___

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 [EMAIL PROTECTED]