Does file-mapping a memory allocation work around RAM limits?

2017-05-03 Thread Rick Mann
Our iOS app works with very large data buffers (hundreds of MB). As you can 
imagine, we run into issues at times.

I saw some sample code that used this technique, and it got me wondering if 
this actually works around the 600 MB limitation of some iOS devices (which 
begs another question: doss the large iPad Pro with 3GB of RAM also limit apps 
to 600 MB?).

-- 
Rick Mann
rm...@latencyzero.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: NSDocument autosavesInPlace and additional menu items

2017-05-03 Thread Quincey Morris
On May 3, 2017, at 08:03 , Eyal Redler  wrote:
> 
> my menu nib contains "Save" and "Save As...” items

What is the IB action associated with your Save As item? It’s not clear how 
Cocoa recognizes the menu item, but the action seems like the likely mechanism. 
Or it could be by standardized name, so your old menu might (e.g.) have three 
periods where an ellipsis is expected.

> A test app I created from a template also has "Save" and "Save as..." but the 
> "Save as..." is replaced by duplicate when running.

According to the 10.7 release notes, Duplicate is added, and Save As is 
“hidden”. You’re getting the addition, just not getting the hiding.

If you can’t figure it out, there may be some IB magic in the File menu that 
your XIB doesn’t have because it’s too old. You could try putting a fresh File 
menu in your menu bar, and modify it to match any other customized items in 
your old one.
___

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: NSSplitView Problems

2017-05-03 Thread Quincey Morris
On May 3, 2017, at 09:27 , Richard Charles  wrote:
> 
> So it appears that simply allowing the the size of a subview to go negative 
> when autoresizing fixes an issue that has been around since the days of 
> NeXTSTEP. So what am I missing?

I dunno, but I think you need to be a bit cautious with your solution.

I have a vague recollection from years ago of running into trouble trying to 
use a NSSize structure with negative values. The details are lost, but IIRC 
there were situations where the negative value was replaced by its absolute 
value.

Looking at the documentation for NSSize, I see this:

> Normally, the values of width and height are non-negative. The functions that 
> create an NSSize structure do not prevent you from setting a negative value 
> for these attributes. If the value of width or height is negative, however, 
> the behavior of some methods may be undefined.

Looking at the documentation for CGSize, I see this:

> A CGSize structure is sometimes used to represent a distance vector, rather 
> than a physical size. As a vector, its values can be negative.


Currently (that is for any macOS code that *isn’t* legacy 32-bit or doesn’t use 
the "build 32 bit like 64 bit” letting) NSSize and CGSize are literally the 
same thing, so I have to assume the discrepancy in the documentation reflects a 
difference that existed in the bad old days when NSSize and CGSize were 
different structs.

Putting all that together, I would tentatively conclude that setting the 
subview size negative probably wouldn’t have worked for legacy 32-bit code, 
probably does work for current architectures, except that there may still be 
some edge cases where it still won’t behave exactly as you intend. You may be 
living a little dangerously, and how little that is, I don’t know.

___

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: strange behaviour of hasPrefix

2017-05-03 Thread Ben Kennedy

> On 03 May 2017, at 8:25 am, Gerriet M. Denkmann  wrote:
> 
> NSString *test2 = [ @"/some/path" stringByAppendingPathComponent: pintu 
> ].lastPathComponent;  
> [ self printTestString: test2 ];  
> //  prints:   length 2 0x2d 0xe3a “-ฺ” BAD: has no prefix "-" NSPathStore2 ← 
> NSString

> Why has test2 no prefix?

If I'm reading your code right, I would imagine this is because test2 obviously 
begins with a slash ("/some/path/...") and not "-".

-[NSString hasPrefix:] :

> Returns a Boolean value that indicates whether a given string matches the 
> beginning characters of the receiver.

-ben

___

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

NSSplitView Problems

2017-05-03 Thread Richard Charles
I have a vertical split view that does not use auto layout or constraints. The 
split view contains a custom subview that has the autoresizing mask set to 
NSViewWidthSizable.

During normal operation the user moves the split view divider which results in 
a collapsed subview. When the split view divider is repositioned to expose the 
subview, the size of the subview has been corrupted.

Apparently this is a well known historical problem caused when a superview 
collapses a subview. This issue has been extensively addressed by BWSplitView 
but RBSplitView but these projects are very old and have not been kept up to 
date.

After thinking about it and doing a little investigation it appears that the 
root cause of the problem is that the size of a view is never allowed to go 
negative when autoresizing. My guess is that if the size of a subview is 
allowed to go negative it would simply fix the issue.

In my subview custom class I implemented the following method override.

- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
{
NSRect frame = self.frame;
NSRect superFrame = self.superview.frame;
NSAutoresizingMaskOptions mask = self.autoresizingMask;

if (mask == NSViewWidthSizable) {
CGFloat delta = superFrame.size.width - oldSize.width;
CGFloat x = frame.origin.x;
CGFloat y = frame.origin.y;
CGFloat w = frame.size.width + delta;
CGFloat h = frame.size.height;
self.frame = NSMakeRect(x, y, w, h);
}
else {
[super resizeWithOldSuperviewSize:oldSize];
}
}

This extremely simple solution seems to work perfectly. The subview collapses 
to zero and then the size goes negative. When the subview is uncovered, its 
size has not been corrupted and autoresizing works as expected.

So it appears that simply allowing the the size of a subview to go negative 
when autoresizing fixes an issue that has been around since the days of 
NeXTSTEP. So what am I missing?

--Richard Charles

___

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


Reconnecting to a NetService after a stream error

2017-05-03 Thread Jeff Kelley
Hi all,

I’m writing an app that begins a NetService on tvOS and connects to it from
iOS. I’m creating the service with a port number of 0 to get an automatic
port and publishing with the .listenForConnections option. On the client
(iOS) side, once I resolve an address for the service I use its
getInputStream(_:outputStream:) method to get input and output streams set
up. I create a background thread to handle callbacks on and schedule the
streams on its RunLoop.

What I’m noticing is that I get a lot of stream errors with this setup. I’m
using JSONSerialization to write JSON objects to the stream and for the
most part it works, but when I get these errors I’d like to reconnect. It
seems like I can’t just call getInputStream(_:outputStream:) again on the
resolved service, as doing so gives me all kinds of errors about a socket
not being available. My next thing to try will be to rediscover the
service, using its TXT data to make sure it’s the same one, re-resolve the
address, and try again.

I’m pretty new to Bonjour and there aren’t a whole lot of resources out
there for how to handle stream errors. Am I on the right track? What kind
of gotchas should I be aware of here (for instance, is there a hard number
of clients that could conceivably connect to a NetService on an Apple TV)?

Thanks in advance for any pointers!


Jeff Kelley

slauncha...@gmail.com | @SlaunchaMan  |
jeffkelley.org
___

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

strange behaviour of hasPrefix

2017-05-03 Thread Gerriet M. Denkmann
//  strange behaviour for probably all combining marks (macOS 12.4):
NSString *pintu = @"-ฺ";//  HYPHEN-MINUS + THAI CHARACTER PHINTHU

//  ok
NSString *test1 = pintu;
[ self printTestString: test1 ]; 
// prints:  length 2 0x2d 0xe3a “-ฺ” ok: has prefix “-“ 
__NSCFConstantString ← __NSCFString

//  BAD
NSString *test2 = [ @"/some/path" stringByAppendingPathComponent: pintu 
].lastPathComponent;
[ self printTestString: test2 ];
//  prints: length 2 0x2d 0xe3a “-ฺ” BAD: has no prefix "-" NSPathStore2 ← 
NSString


- (void)printTestString: (NSString *)testWord
{
BOOL hasPre = [ testWord hasPrefix: @"-" ];
NSLog(@"%s length %tu %#x %#x \"%@\" %s prefix \"-\" %@ ← 
%@",__FUNCTION__, 
testWord.length, [testWord characterAtIndex: 0], [testWord 
characterAtIndex: 1], testWord,
hasPre ? "ok: has" : "BAD: has no",
[testWord class], [testWord superclass] );
}

Why has test2 no prefix?

What am I doing wrong?

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

NSDocument autosavesInPlace and additional menu items

2017-05-03 Thread Eyal Redler
Hi,

I'm working on a very old document based application. When autosave in place 
was introduced back in 10.7 I've added support for this and made it optional 
for my users. I know that the autosaving feature was tweaked a few times in 
subsequent releases but I'm really fuzzy about what these tweaks were and when 
they were added.

At any rate, my menu nib contains "Save" and "Save As..." items and when my app 
is running in autosave mode - that is - when I'm returning YES from 
+autosavesInPlace then the "Duplicate", "Rename" and "Move To..." items are 
added to the menu. This is all great but for some reason the "Save as" item is 
still kept so I have save, save as, duplicate etc.

A test app I created from a template also has "Save" and "Save as..." but the 
"Save as..." is replaced by duplicate when running.

I'm having a hard time finding the place where this feature is documented so I 
would be grateful if someone here could point me in that direction or possibly 
explain what's happening here.

TIA

Eyal Redler

"If Uri Geller bends spoons with divine powers, then he's doing it the hard 
way."
--James Randi
www.eyalredler.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: Mysterious write-only SMB behavior (Kirk)

2017-05-03 Thread Matthew Kozak
Microsoft updates the default negotiated version of SMB used in each release 
and in your situation it's a major bump from 2.x (Server 2008) to 3.x (as of 
Server 2012).  See section 4, here, for a matrix of versions:

https://blogs.technet.microsoft.com/josebda/2015/05/05/whats-new-in-smb-3-1-1-in-the-windows-server-2016-technical-preview-2/


That may be an angle worth investigating?


Matt


From: Cocoa-dev  
on behalf of Ken Thomases 
Sent: Tuesday, May 2, 2017 9:40 PM
To: kkere...@ststulsa.com
Cc: cocoadev cocoadev
Subject: Re: Mysterious write-only SMB behavior (Kirk)

You should have the Windows network admin examine the files for their 
attributes, ACLs, and other metadata.  Compare with files which show up 
properly to see if you can identify the problematic ones.

Regards,
Ken

On May 1, 2017, at 11:11 AM, Kirk Kerekes  wrote:
>
> More details.
>
> The write-only procedure was using -[NSString 
> writeToURL:atomically:encoding:error:], with atomically set to YES.
>
> I noticed that the app did file-move and rename operations on, to and between 
> SMB volumes without problems, so I changed the write process to create the 
> file locally on the Mac and use NSFileManager to [ 
> moveItemAtURL:toURL:error:]  the item to the remote SMB volume. This works 
> flawlessly.
>
> But this does not identify the actual source of the problem. -[NSString 
> writeToURL:atomically:encoding:error:] should work correctly. (Or perhaps I 
> need to wrap it in some additional housekeeping?)
> However I cannot easily assert that this is a Foundation problem even though 
> the code has worked correctly for years on older Windows Server shares.
>
> I am not any kind of expert on Windows networking, and have no insight as to 
> why creating a file on a Windows share should be different than copying a 
> file to the same share.
>
> I would still welcome any wisdom on this, at least to provide a reference for 
> befuddled future readers.
>
>> --
>>
>> Message: 1
>> Date: Fri, 28 Apr 2017 15:21:45 -0500
>> From: Kirk 
>> To: cocoa-dev@lists.apple.com
>> Subject: Mysterious write-only SMB behavior
>> Message-ID: <8be95449-f93e-4847-ae39-4f45f63c5...@gmail.com>
>> Content-Type: text/plain;charset=us-ascii
>>
>> I have Cocoa application that does a specialized task for my employer. It 
>> runs on a Mini running Sierra but all file I/O is from/to network SMB 
>> volumes shared by Windows Server over the company network.
>>
>> The Mini is a full admin domain member, both computer and user.
>>
>> This application has been working fine, until we recently upgraded the 
>> server from WS 2008 to 2016 and moved a lot of stuff around.
>>
>> Now, files that my app creates over SMB are invisible to Macs, but visible 
>> to Windows clients. And then if that were not odd enough, the files become 
>> visible to a Mac if they are found by a Finder file-name search on the SMB 
>> volume. Once the search is closed, the files resume being invisible.
>>
>> All of the files are text files, with various non-standard file extensions 
>> for housekeeping purposes.
>>
>> FIles that my app merely modifies (renames) and relocates remain visible, 
>> and directories that it creates are visible.
>>
>> If this rings a bell with anyone, I would appreciate a clue, which would be 
>> one more than I have now.
>>
>> Kirk Kerekes
>> (iPhone)
>>
>
> ___
>
> 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://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.apple.com%2Fmailman%2Foptions%2Fcocoa-dev%2Fken%2540codeweavers.com=02%7C01%7Cmkozak%40oit.rutgers.edu%7Cca09dd9b5a5345ff88e408d491c5581f%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C636293724156810942=%2B8BfY7sEzdEI9qZI3Ss9uvpItZNEbGh7MUHyjox7Cao%3D=0
>
> This email sent to k...@codeweavers.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://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.apple.com%2Fmailman%2Foptions%2Fcocoa-dev%2Fmkozak%2540camden.rutgers.edu=02%7C01%7Cmkozak%40oit.rutgers.edu%7Cca09dd9b5a5345ff88e408d491c5581f%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C636293724156810942=%2Ffnjn8RjX%2BRvJOs6SckyepLAqTBLEdS%2BlxqrKzmcd98%3D=0

This email sent to mko...@camden.rutgers.edu
___

Cocoa-dev mailing list