Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo

2016-04-27 Thread Martin Wierschin
This code is never going to work:

> [[myTextView textStorage] addAttribute:NSParagraphStyleAttributeName 
> value:[NSNumber numberWithInt:NSLineBreakByTruncatingTail] range:myRange];
> 
> But this results in nothing being displayed in the ScrollView/TextView.

In fact, using that code probably threw at least one exception, which is why 
you're not seeing anything in your text view.

The NSParagraphStyleAttributeName attribute expects a NSParagraphStyle object 
as its value, not an NSNumber. The value you're trying to set (the line 
breaking mode) is a property of the paragraph style. You want code that 
resembles:

NSMutableParagraphStyle* paraStyle = [[NSMutableParagraphStyle alloc] 
init];
[paraStyle setLineBreakMode:NSLineBreakByTruncatingTail];
[textStorage addAttribute:NSParagraphStyleAttributeName value:paraStyle 
range:myRange];

That's typed into Mail and may have errors, but you get the idea.

~Martin Wierschin

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How to Truncate lines in NSScrollView/NSClipView/NSTextView Combo

2016-04-27 Thread Dave

> On 27 Apr 2016, at 09:01, Martin Wierschin  wrote:
> 
> This code is never going to work:
> 
>> [[myTextView textStorage] addAttribute:NSParagraphStyleAttributeName 
>> value:[NSNumber numberWithInt:NSLineBreakByTruncatingTail] range:myRange];
>> 
>> But this results in nothing being displayed in the ScrollView/TextView.
> 
> In fact, using that code probably threw at least one exception, which is why 
> you're not seeing anything in your text view.
> 
> The NSParagraphStyleAttributeName attribute expects a NSParagraphStyle object 
> as its value, not an NSNumber. The value you're trying to set (the line 
> breaking mode) is a property of the paragraph style. You want code that 
> resembles:
> 
>   NSMutableParagraphStyle* paraStyle = [[NSMutableParagraphStyle alloc] 
> init];
>   [paraStyle setLineBreakMode:NSLineBreakByTruncatingTail];
>   [textStorage addAttribute:NSParagraphStyleAttributeName value:paraStyle 
> range:myRange];
> 
> That's typed into Mail and may have errors, but you get the idea.
> 
> ~Martin Wierschin
> 


Yes, it was throwing but I didn’t notice it because of problem I’ve got with 
the Debugger catching exception breakpoints.

Cheers
Dave

___

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

Can't code-signing validate an App's main executable, without its whole bundle.

2016-04-27 Thread Motti Shneor
The following simple code will validate the code-signing of any Mac executable 
file, or App-bundle, or any code-bundle etc.

However, if handed a path to an executable which happens to be the main 
executable of an App bundle (example 
`/Applications/Mail.app/Contents/MacOS/Mail`) The SecStaticCodeRef will 
automatically encompass the whole wrapping bundle. Such bundle could be huge 
and the verification process can be both CPU and memory intensive. 

The documentation of SecStaticCodeCreateWithPath, (see 
https://developer.apple.com/library/mac/documentation/Security/Reference/CodeSigningRef/#//apple_ref/c/func/SecStaticCodeCreateWithPath
 
)
  states that  "If you pass a URL to the main executable of a bundle, the 
bundle as a whole is generally recognized."

My Question: How to 'persuade' either the `SecStaticCodeCreateWithPath` or the 
`SecStaticCodeCheckValidityWithErrors` to NOT do that - i.e. represent only 
that main-executable alone, without its bundle. I could not find any flags or 
attributes to do that, but I’m pretty novice with the Security Framework, and I 
can’t yet fully grasp the “SecStaticCode” object’s role and use.

Ideas anyone?

void checkFileValidity(CFIndex idx, const char *filePath) {
OSStatus result = noErr;
printf ("Validating %ld: ", idx);

CFURLRef fileRef = CFURLCreateAbsoluteURLWithBytes(kCFAllocatorDefault, 
(UInt8 *)filePath, strlen(filePath), kCFStringEncodingUTF8, NULL , false);
if (fileRef == NULL)
return;
   
SecStaticCodeRef staticCode;
result = SecStaticCodeCreateWithPath(fileRef, kSecCSDefaultFlags, 
&staticCode);
CFRelease(fileRef);
if (result != noErr)
return;

SecCSFlags staticVerifyOptions = kSecCSDefaultFlags; // 
kSecCSCheckAllArchitectures | kSecCSStrictValidate;
CFErrorRef error = NULL;
result = SecStaticCodeCheckValidityWithErrors(staticCode, 
staticVerifyOptions, NULL, &error); // Following call leaks memory.

CFRelease(staticCode);
switch (result) {
case errSecSuccess:
printf ("Good. ");
break;

default:
printf ("Failed with code:%d for %s\n", result, filePath);
CFShow(error);
CFRelease(error);
break;
}
}

Motti Shneor
---
Ceterum censeo Microsoftinem delendam esse


___

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: nsopenpanel no title bar

2016-04-27 Thread Martin Wierschin
> Since 10.11 it seems the title bar no longer appears even when using 
> setTitle: does anyone know what happened and how to get the old behavior back?

I don’t know anything about that, but you can always use -[NSOpenPanel 
setMessage:] to display relevant information to the user.

~Martin Wierschin


___

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: Radio buttons as table views

2016-04-27 Thread lorenzo

This ended up off-list. I’m reposting in case this might be of use to anyone.

> On Apr 25, 2016, at 6:26 PM, Quincey Morris 
>  wrote:
> 
> (we’re off-list, as of your last message — not sure if this was accidental, 
> but feel free to repost to list if you wish)
> 
> On Apr 25, 2016, at 12:33 , Lorenzo Thurman  wrote:
>> 
>> I'll have to manually manage the select/unselect. 
> 
> Not necessarily. It’s possible to bind the value of the checkboxes to a Bool 
> property of your ‘objectValue’ object. 
> 
> All you need is for this to be a “derived” property — one whose value is 
> dependent on the value of a property in a different object (e.g. in your view 
> controller, or your data source or delegate), and is made KVO compliant by 
> the ‘keyPathsForValuesAffecting’ mechanism, or something equivalent.
> 
> 


___

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