NSTimer retain and release questions

2008-09-10 Thread Kyle

The documentation for this autoreleased method:

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds  
target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo  
repeats:(BOOL)repeats


states: "If repeats is NO, the timer will be invalidated after it  
fires."


If I call this autoreleased method, and set repeats to YES, does that  
imply I do not need to retain the object if I want to invalidate it  
later?  In other words, is this autoreleased method autoreleased only  
when repeats is NO, otherwise it is not autoreleased?


Just want to make sure I understand it correctly.  Thanks in advance!

___

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]


Converting non-English date string to NSDate

2009-03-31 Thread Kyle
My app imports tab-delimited data, and to convert a string date value  
to a NSDate value, it uses this method:


NSDate *theDate = [NSDate dateWithNaturalLanguageString:theStr
	locale:[[NSUserDefaults standardUserDefaults]  
dictionaryRepresentation]];


This works fine for English date strings, but not when the date string  
is non-English.  For example, a German date string usually (but not  
always) returns a nil value.  This is true even when the OS is the  
German OS.


Is there better way to convert string date values to NSDate values,  
especially non-English string date values?


Thanks in advance.
-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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Implications of disabling ATS?

2015-10-02 Thread Kyle Sluder
On Wed, Sep 30, 2015, at 03:45 PM, Mike Abdullah wrote:
> 
> > On 30 Sep 2015, at 17:17, Jens Alfke  wrote:
> > 
> > 
> >> On Sep 30, 2015, at 7:06 AM, Alex Hall  wrote:
> >> 
> >> However, before I go doing that, does anyone know of a better way? Are 
> >> there security implications I'm overlooking? I don't know what users will 
> >> do with this web view, and yes, some may log into sites or give other 
> >> sensitive data. The primary use case is to look at articles, videos, etc 
> >> that are tweeted, though, and to do that I can't have ATS blocking 
> >> everything. I'm not sure what the best course is here. Thanks.
> > 
> > You might want to use WKWebView instead, then, if all you need is a basic 
> > display of some Web content. Since it’s actually running in a separate 
> > process, your app won’t be the origin of the insecure HTTP loads, so you 
> > shouldn’t run into any issues with ATS.
> 
> In my testing so far, WKWebView is subject to the same limits still of
> ATS.

But SFSafariViewController is not. And it's more powerful.

--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: Implications of disabling ATS?

2015-10-02 Thread Kyle Sluder
On Oct 2, 2015, at 2:30 PM, Alex Hall  wrote:
> 
> 
>> On Oct 2, 2015, at 16:01, Kyle Sluder  wrote:
>> 
>> On Wed, Sep 30, 2015, at 03:45 PM, Mike Abdullah wrote:
>>> 
>>>> On 30 Sep 2015, at 17:17, Jens Alfke  wrote:
>>>> 
>>>> 
>>>>> On Sep 30, 2015, at 7:06 AM, Alex Hall  wrote:
>>>>> 
>>>>> However, before I go doing that, does anyone know of a better way? Are 
>>>>> there security implications I'm overlooking? I don't know what users will 
>>>>> do with this web view, and yes, some may log into sites or give other 
>>>>> sensitive data. The primary use case is to look at articles, videos, etc 
>>>>> that are tweeted, though, and to do that I can't have ATS blocking 
>>>>> everything. I'm not sure what the best course is here. Thanks.
>>>> 
>>>> You might want to use WKWebView instead, then, if all you need is a basic 
>>>> display of some Web content. Since it’s actually running in a separate 
>>>> process, your app won’t be the origin of the insecure HTTP loads, so you 
>>>> shouldn’t run into any issues with ATS.
>>> 
>>> In my testing so far, WKWebView is subject to the same limits still of
>>> ATS.
>> 
>> But SFSafariViewController is not. And it's more powerful.
> 
> It looks that way, but I can't find anything about using it on OS X. Is this 
> an iOS-only feature?

Ah, yes it is. My apologies.

--Kyle Sluder

> I've had to temporarily remove Xcode to install an update (64-GB MacBooks are 
> terrible for primary machines), so I can't look at the actual class just now. 
> Everything I'm reading, though, suggests this is exclusive to iOS9 and above.
>> 
>> --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/mehgcap%40icloud.com
>> 
>> This email sent to mehg...@icloud.com
> 
> 
> --
> Have a great day,
> Alex Hall
> mehg...@icloud.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: titleForHeaderInSection wrong section count.

2015-10-19 Thread Kyle Sluder
On Mon, Oct 19, 2015, at 01:26 PM, James Cicenia wrote:
> I have a fetch
> 
> let aFetchedResultsController = NSFetchedResultsController(fetchRequest:
> fetchRequest, managedObjectContext: getManagedObjectContext(),
> sectionNameKeyPath:"product.sectionKey", cacheName:nil)
> 
> In the following function:
>
>  func tableView(tableView: UITableView, titleForHeaderInSection section:
>  Int) -> String? {
>   print(section)
> print (searchFetchedResultsController.sectionIndexTitles)
> 
> I see:
> 
> 30
> ["1", "2", "4", "8", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
> "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X",
> "Y", "Z"]
> 
> Yes there are 30 elements but the array is zero based.
> 
> What is happening here?

Can you reproduce this in a sample app and attach it to a Radar?

--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: Hide UINavigationBar and keep UIPageController content static

2015-10-24 Thread Kyle Sluder
On Tue, Oct 20, 2015, at 11:21 AM, Stevo Brock wrote:
> The trick is, if in the storyboard, on the UIPageController, I set the
> “Under Top Bars” to yes, my custom view draws full screen.  But when I
> toggle the navigationBarHidden, the custom view and its superview scroll
> up and down the size of the navigation bar.

This sounds like it might be a bug in automatic content inset
adjustment. Please file a Radar with a sample project.

In the meantime, you can try turning off
automaticallyAdjustsScrollViewInsets on your view controller and
managing layout manually (relative to the view controller's
topLayoutGuide) in an override of -viewDidLayoutSubviews.

> 
> 
> Alternatively, if in the storyboard, on the UIPageController, I set the
> “Under Top Bars” to no, my custom view draws in the screen space under
> the navigation bar.  When I toggle the navigationBarHidden, the view
> stretches to fill the full height of the screen, but I never get a redraw
> call, so the drawing is stretched.

This is expected. Views that need to redraw when they change size should
override -setBounds: to call [self setNeedsDisplay].

--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: Hide UINavigationBar and keep UIPageController content static

2015-10-27 Thread Kyle Sluder
On Tue, Oct 27, 2015, at 11:49 AM, Stevo Brock wrote:
> Hi David and Kyle,
> 
> Thanks so much for the insight and pointers.
> 
> I was manually calling setNeedsDisplay() when toggling the navigation bar
> hidden, and now I can remove that and just set the contentMode to
> .Redraw.  That’s great.
> 
> And setting the automaticallyAdjustsScrollViewInsets to false helps, and
> I can now go back to drawing the content under the top bars and the
> content stays put while the bar animates up and down.
> 
> Thanks again guys for your expert insight.

You're welcome. You can pay me back by filing a bug about this issue
with an attached sample project. :P

--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: Best Control for Catching a Mouse Click?

2015-12-07 Thread Kyle Sluder
On Mon, Dec 7, 2015, at 10:32 AM, Dave wrote:
> Hi All,
> 
> I have a view that is made up for a Text View and a Small Icon like so:
> 
> NSView
>   NSImageView
>   NSTextField
> 
> If the User Clicks anywhere inside the base NSView, I’d like a Perform
> Click IBAction to be sent to the connected class (The View Controller in
> this case). In the past, on iOS i’ve done this by using a transparent
> UIButton that has the same Frame Rect as the base NSView.

This probably made your app inaccessible with VoiceOver. Please do not
use invisible controls for this sort of thing.

> When I tried to
> do with the same with an NSButton, I find that I can’t change the height
> in IB? 
> 
> On the Mac what is the best control to use to do this?

Use a different approach that will work on both platforms. Override
-hitTest: in a containing view. This will also work well with
accessibility.

--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: How to create an empty stack view in code

2015-12-07 Thread Kyle Sluder
On Sun, Dec 6, 2015, at 10:10 AM, Dave wrote:
> Hi,
> 
> I’m not sure what to use for the Frame though?

It doesn't matter. Auto Layout will change the frame on the first layout
pass anyway.

--Kyle Sluder

> The way this is setup is
> that I have a Stack View an empty Stack View in a NIB, as so:
> 
> @property (nonatomic,strong)IBOutlet NSStackView*  
> pLabelMainRowStackView; //Vertical
> 
> There is a then a Row Array which contains Column Arrays and each item in
> a Column Array is a Dictionary that contains the data for the
> Corresponding View.
> 
> So in code, I create a Column (Horizontal) Stack View, Create a New View
> for the Dictionary Item and add it to the newly created Stack View. When
> all Columns in the Array have been added, add the Column Stack view to
> the pLabelMainRowStackView Stack view.
> 
> All the Best
> Dave
> 
> > On 6 Dec 2015, at 15:48, Jonathan Hull  wrote:
> > 
> > You can just do [[NSStackView alloc] initwithFrame:]
> > 
> > 
> >> On Dec 6, 2015, at 6:23 AM, Dave  wrote:
> >> 
> >> Hi All,
> >> 
> >> How do I create an Empty Stack View in code? The only method I can find 
> >> that that creates a Stack View is stackViewWithViews and you can’t pass 
> >> nil to this. Do I have to pass an empty array or can I just do 
> >> [[NSStackView alloc] init]; ?
> >> 
> >> All the Best
> >> 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

Re: NSViewController -identifier unrecognized selecto problem

2015-12-09 Thread Kyle Sluder
On Wed, Dec 9, 2015, at 11:20 AM, Jonathan Mitchell wrote:
> NSViewController conforms to NSUserInterfaceItemIdentification so should
> implement 
> @property (nullable, copy) NSString *identifier;
> 
> I build my app on 10.11 with a deployment target of 10.9
> 
> Om 10.10 and 10.11 no issues.
> On 10.9 I get
> 
> 'NSInvalidArgumentException', reason: '-[TSToolbarGroup identifier]:
> unrecognized selector sent to instance 0x6018ee10’
> TSToolbarGroup is an NSViewController subclass of mine

As per the AppKit release notes, NSViewController only started
conforming to NSUserInterfaceItemIdentification in 10.10. Sadly, the are
no availability macros for conformances.

You might consider filing a bug report about this, but in the meantime
you'll need to stop sending -identifier to your view controllers when
running on 10.9.

--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: Another CFTypeRef question

2016-01-14 Thread Kyle Sluder
On Thu, Jan 14, 2016, at 08:54 AM, Clark Cox wrote:
> No. It does not change. A CF object has a single address for its
> lifetime.
> 
> > On Jan 14, 2016, at 06:42, Dave  wrote:
> > 
> > Hi,
> > 
> > Does the pointer value of a CFTypeRef change during it’s lifetime? Can I 
> > safely uses the string value of the pointer %p as a key to a dictionary?

That said, this is a very strange question. It sounds like you're trying
to implement a hash table by working around the requirement that an
NSDictionary key's must be copiable. Are you sure NSMapTable is not
better for your needs?

--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: Problem Archiving/Un-archiving Custom Objects

2016-01-22 Thread Kyle Sluder
On Fri, Jan 22, 2016, at 08:14 AM, Dave wrote:
> 
> > On 21 Jan 2016, at 23:40, Quincey Morris 
> >  wrote:
> > 
> > On Jan 21, 2016, at 15:22 , Dave  > <mailto:d...@looktowindward.com>> wrote:
> >> 
> >> I’m relying of the copy attribute for the NSString’s, do I need to change 
> >> these to do a [xxx copy] too
> > 
> > If you’re writing the setter yourself, you must do the copy yourself. If 
> > you’re using the synthesized setter, it’s done for you.
> > 
> > In your own code, you may as well be liberal with ‘copy’. It’s basically 
> > free (in run-time cost) in situations where you don’t need it. You don’t 
> > save anything by leaving it out.
> > 
> 
> I’ve always been confused over what *actually* happens when you do
> something like this:
> 
> @property (copy)NSString*   pString;
> 
> 
> self.pString = [anotherString copy];
> 
> Do two new NSString objects get created? (I mean using the synthesized
> setter)

No. -copy is equivalent to -retain for immutable strings, so in the best
case this code causes zero copies (when anotherString is immutable), and
in the worst case it causes one (when anotherString is mutable).

--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: Trying to understand a permissions failure when writing to ~/Desktop

2016-01-27 Thread Kyle Sluder
On Wed, Jan 27, 2016, at 09:57 PM, Graham Cox wrote:
> Well, the OS definitely believes the app is sandboxed. The full URL I get
> for ~/Documents/ is in fact ~/Library/Containers//…. blah blah
> 
> I did a clean build and changed the bundle ID as well as discarding the
> container, but no, it just makes a new container with the new bundle ID.
> This is exasperating, I can’t see where it could be getting such a notion
> from.
> 
> Sandboxing is OFF in Xcode’s ‘Capabilities’ section, and AFAICS no
> .entitlements file is added to the build. Th eonly ‘funny’ I have in my
> info.plist is an entry for NSUbiquitousContainers, since I wanted to
> allow access to the user’s iCloud documents. I thought that setting
> allowed this without sandboxing, not that it snuck sandboxing in by the
> back door. I will check and see whether that’s a red herring.

Any app on OS X can open documents from iCloud Drive—the user just has
to navigate to iCloud Drive in Finder.

--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: Very basic need, very difficult to achieve.

2016-05-03 Thread Kyle Sluder
On Tue, May 3, 2016, at 06:28 PM, Graham Cox wrote:
> My main dev machine runs the latest OS - 10.11.4
> 
> I need to install a 10.9 image on a disk partition for development
> testing.
> 
> How?
> 
> Apple’s dev site is getting worse all the time - wasting its time selling
> you something you already have - OS X - but hiding away basic resources,
> like an OS 9 installer that I can download. I’ve just spent 20 minutes
> fruitlessly searching the dev site. It’s utterly baffling, taking you
> round and round in circles.
> 
> How can I do this? Surely it’s actually possible, somehow?
> 
> Note that I do have an old Mavericks Installer, but it refuses to run on
> 10.11, saying that the app is too old ro run on this version of the OS. I
> also have not been able to set the partition I intend to use (that
> contains the installer) as a startup disk. I seem to recall that there
> was a thread about this not long ago, I even seem to remember pitching in
> something, but now I come to need it myself, I can’t get it to work.

Downgrading the OS (even on a second partition) isn’t actually that
simple of a request. If your computer was released after OS X Mavericks,
it definitely cannot support running OS X Mavericks. It’s also possible
that a firmware fix or disk format change may have shipped in a newer
OS, and older OSes are not qualified against that configuration.

Virtualization of recent versions of OS X is permitted on Apple-branded
hardware. That’s probably your best bet.

--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

Re: UIImagePickerController in popover broken on iOS 9

2016-05-11 Thread Kyle Sluder
On Wed, May 4, 2016, at 01:34 PM, Matt Reagan wrote:
> Hi all,
> 
> I've encountered a bug when UIImagePickerController is presented in a
> popover on iOS 9, and have been unable to find a workaround / fix.

Please file a bug report at https://bugreport.apple.com.

--Kyle

> 
> It is easily reproducible in a brand new Xcode template (repro steps +
> sample project linked below), but I haven't been able to find much
> information online. I've been able to find partial fixes that depend on
> the orientation + multitasking settings of the app, but when the
> UIImagePickerController is the child of any other view controller
> (UITabBarController etc.) and the device or sim is in Landscape, it
> always breaks. I'm attempting to find a reliable fix or workaround, was
> hoping someone here may have seen this before?
> 
> Bug:
>   * UIImagePickerController presented in a popover of any kind has a 
> broken 'pop' / back navigation animation
>   * Animated gif:   http://i.imgur.com/na2lprb.gif
>   
> Factors:
>   * The bug itself is impacted by several things:
>   - Orientation of the device/sim (only reproducible in Landscape)
>   - Multitasking availability (only Multitasking-capable 
> devices/sims AFAICT)
>   - Multitasking opt-in (whether 'Requires full screen' is 
> checked)
>   - Whether the UIImagePickerController is a child of any other 
> controller
>   * The bug is NOT impacted by the following:
>   - Whether UIPopoverController or presentViewController: + 
> UIModalPresentationPopover style is used
>   
> Repro steps (sample project linked below):
>   - Create a new iOS Xcode project ('Single view application' template)
>   - Add a button and wire it up to an action method in ViewController.m
>   - Add code to present a standard UIImagePickerController in a 
> UITabBarController (ex. snippet below)
>   - Run the app on a 9.3 iPad Air 2 Device (or simulator)
>   - Make sure device/sim is rotated to Landscape
>   - Tap button (see 'Result' below)
>   
> Result:
>   * The popover is presented in the UITabBarController + popover 
> normally, but if the user pushes back within the UIImagePickerController's 
> navigation flow, the animation is broken
>   * Gif: http://i.imgur.com/na2lprb.gif
>   
> Example code:
> 
>   // Bug also reproducible via presentViewController: + 
> UIModalPresentationPopover style
> 
>   - (IBAction)buttonWasTapped:(UIButton *)sender
>   {
>   UIImagePickerController *cameraRollController = 
> [UIImagePickerController new];
> 
>   cameraRollController.sourceType = 
> UIImagePickerControllerSourceTypePhotoLibrary;
>   cameraRollController.allowsEditing = NO;
> 
>   UITabBarController *tabController = [UITabBarController new];
>   tabController.viewControllers = @[cameraRollController];
> 
>   UIPopoverController *popoverController = [[UIPopoverController 
> alloc] initWithContentViewController:tabController];
>   [popoverController presentPopoverFromRect:sender.bounds
>  inView:sender
>
> permittedArrowDirections:UIPopoverArrowDirectionDown
>animated:YES];
>   }
>   
> Example project:
>   * http://sound-of-silence.com/sos/private/ImagePickerBug.zip
>   
> So far I've tried just about everything I can think of to fix the
> problem. As noted above, there are partial "fixes" that work (disabling
> Multitasking, or limiting orientations), but this is true only when the
> UIImagePickerController is presented _directly_ in the popover. When the
> picker is a child of any other view controller (embedded in a tab
> controller, or added as a child of an arbitrary UIViewController) I've
> been unable to find a fix.
> 
> Has anyone seen this before? Any advice/suggestions would be greatly
> appreciated.
> 
> Thank you~
___

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: Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior

2016-05-11 Thread Kyle Sluder
On Thu, Apr 28, 2016, at 05:03 PM, Rick Mann wrote:
> I'm getting the following message in the console:
> 
>   Attempting to load the view of a view controller while it is 
> deallocating is not allowed and may result in undefined behavior 
> ()
> 
> Thing is, I get it when handling a universal link (a link tapped outside
> my app, but which is sent to my app for handling). This message is logged
> before application(_:continueUserActivity:restorationHandler:) gets
> called.
> 
> At the time, I have my app's regular UI showing, and no
> UIAlertViewControllers have been instantiated.
> 
> Any idea why I'm seeing this? Thanks!

Can you set a breakpoint on -[UIViewController loadView] with a
condition of `[(id)$x0 isKindOfClass:[UIAlertController class]]` (on
device) or `[(id)$rdi isKindOfClass:[UIAlertController class]]` (in the
Simulator) while your app is in the background, then reproduce? That’ll
at least tell you what’s triggering the message. If further
investigation indicates that the alert is being created by the
framework, please file a bug report.

--Kyle Sluder

> 
> -- 
> 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: presentationControllerForPresentedViewController(…) is called multiple times

2016-05-11 Thread Kyle Sluder
On Tue, May 10, 2016, at 06:02 PM, Rick Mann wrote:
> Currently, my code instantiates a new UIPresentationController subclass
> each time presentationControllerForPresentedViewController(…) is called.
> Unfortunately, when I present a VC,
> presentationControllerForPresentedViewController(…) is called three
> times! This seems wasteful, at best, and possibly broken, since state is
> not tracked across calls.
> 
> I could try to keep a reference around for it, but then I'm holding on to
> a reference that won't be updated properly the next time.
> presentationControllerForPresentedViewController() passes in a couple of
> parameters required by UIPresentationController's constructor.
> 
> Is this a bug, or is this just how it is?

Regardless of whether this is expected, I agree it’s inefficient. Please
file a bug report at https://bugreport.apple.com.

--Kyle Sluder

> 
> 
> -- 
> 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: Application Activation Problem

2016-05-13 Thread Kyle Sluder
On Fri, May 13, 2016, at 04:46 AM, Dave wrote:
> Hi All,
> 
> I’m using:
> 
> [myRunningApp activateWithOptions:(NSApplicationActivateAllWindows |
> NSApplicationActivateIgnoringOtherApps)];
> 
> To activate an Application. Is there any way to tell when the Application
> is actually active? I have the need to cycle through an Array of App
> Bundle IDs and make each Application Active, one after the other, leaving
> the last one in the list as the Active App.
> 
> If I do this in a tight loop then it seems to just activate the last on
> in the Array without activating the preceding apps. I tried adding a
> delay between each Activation call, and although this sort of works, it
> still out an App once in a while. I was thinking if there was something I
> could monitor to make sure the App has activated and is stable before
> sending the next Activate.
> 
> Any ideas or suggestions greatly appreciated.

Activation is an inherently asynchronous and failable action. After all,
what if two apps send -activateWithOptions: simultaneously?

You might consider subscribing to
NSWorkspaceDidActivateApplicationNotification and cycling to the next
app in the list upon receipt, but the best you can do is best-effort.

--Kyle

> 
> All the Best
> 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

Re: objc [66375] class Foo is implemented in both BundleA and BundleB

2016-05-13 Thread Kyle Sluder
On Fri, May 13, 2016, at 03:23 AM, Jeff Szuhay wrote:
> 
> > On May 11, 2016, at 5:11 PM, Jeff Szuhay  wrote:
> >> On May 11, 2016, at 12:08 AM, Jens Alfke  wrote:
> >>> On May 10, 2016, at 11:05 PM, Jeff Szuhay  >>> <mailto:j...@szuhay.org>> wrote:
> >>> 
> >>> Class Foo is a base class. It is subclassed in BundleA,  BundleB, … 
> >>> BundleZ.
> >> 
> >> Where is Foo itself implemented? If there are copies of the Foo class in 
> >> each bundle then yeah, you’ll get that warning.
> >> 
> >>> Is there a better way to do it? I can’t currently how to have a singleton 
> >>> base class
> >>> implementation that is shared among two or more bundles.
> >> 
> >> Put the base class (and any other shared code) in a framework that each of 
> >> your bundles links against.
> >> 
> >> —Jens
> > 
> > Foo is common to all plug-ins of the app but not needed in the app itself 
> > nor by anything else in the system.
> > 
> > That was definitely the “right way:” make a framework of the base classes 
> > and store it in the app bundle.
> > Each plug-in links against the framework.
> > 
> > But, sheesh, that was painful to figure out.
> > 
> > Thanks, Jens.
> 
> 
> What was particularly painful was how to  configure each Xcode
> sub-project to see the framework. I had to 
> fiddle around with this for an inordinate amount of time. I feel the
> framework approach and some basic steps
> should, at the very least, be included in the READ.ME file for Apple’s
> sample BundleLoader project. 
> 
> But, just to be clear, the BundeLoader project is awesome (among many
> others). Thank you, Apple.
> 
> I’m still trying to figure out the difference between private framework
> headers and project framework headers.
> 
> So far, I’ve learned that
> 1) Project headers are only available within the framework and not to any
> other “consumer” of the framework.
> Which is to say, my bundles, which “consume" the framework, cannot
> see project headers.
> 2) Private heads are available to consumers of the framework but only at
> compile/link time. They are not anywhere
> in the app bundle — which is exactly what I want. 
> One downside to this is that if I change a framework header I have to
> rebuild the framework to get the changes
> in the right place for the bundles to see the changes. Minor
> inconvenience.
> 3) Public headers become available for everyone who looks in the app
> bundle. They are moved there for all to see.
> (not what I want).
> 
> Did I learn correctly?

Not quite. Private headers get copied into the Framework bundle, but in
a PrivateHeaders subfolder instead of the regular Headers folder. This
way your clients can use your private API, and then when everything is
built you can go through and strip all PrivateHeaders folders from your
app bundle. This sounds like exactly what you want.

Note: I haven’t actually done this in the face of codesigning. Not sure
if PrivateHeaders is considered part of the framework’s seal.

--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

Re: unwind segue on navigation pop

2016-05-13 Thread Kyle Sluder
On Thu, May 12, 2016, at 09:48 PM, Roland King wrote:
> I’m making more use of unwind segues to try and get to the point I have
> ‘go forward’ and ‘go backward’ code in one place in the same class. So
> during prepareForSegue I set some stuff up, during my unwind segue method
> I tear it down again. Don’t use it for everything, but for some complex
> presentations it’s been quite useful. 
> 
> I’ve just changed a piece of navigation to use a standard nav controller,
> it used to be a modal presentation but a push makes more sense. So now
> there’s no custom dismiss button like there used to be, you go back with
> the normal back button on the nav controller. I can’t find a good way to
> get that back action to trigger my unwind segue. Can’t seem to do it in
> IB, I don’t want a custom back button because you lose the chevron (or
> have to fake it) and all the normal uinav behaviour. 

The Back button is not customizable in this fashion. Please file an
enhancement request at https://bugreport.apple.com.

--Kyle Sluder

> 
> Best I’ve found so far is to give the segue a custom identifier (ie make
> it a viewcontroller segue) and performSegue it from ‘viewWillDisappear’,
> however that has a pretty bad smell about it because that’s not really an
> unwind, it’s already doing the dismissal by then. Feels like something
> which is going to break one day. 
> 
> There’s other ways I can do this obviously - change it to a
> protocol/delegate method called directly from the VC as it goes away, but
> I was trying to stick with unwind segues if possible. 

___

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: Application Activation Problem

2016-05-13 Thread Kyle Sluder
On Fri, May 13, 2016, at 10:21 AM, Dave wrote:
> Hi,
> 
> > You might consider subscribing to
> > NSWorkspaceDidActivateApplicationNotification and cycling to the next
> > app in the list upon receipt, but the best you can do is best-effort.
> > 
> > --Kyle
> > 
> 
> That’s actually what I am doing. I monitor
> NSWorkspaceApplicationWllLaunchNotification,
> NSWorkspaceApplicatioDidLaunchNotification  and
> NSWorkspaceDidActivateApplicationNotification (as well as others). For
> each notification I get I add the BundleID of the App to an Array. Then
> at some later point, I want to cycle through the Activates and re-send
> them in the same order they were activated originally.
> 
> I realise that this is not 100% perfect (because of outside influences,
> (other apps etc)), but I’d like to get it as close as possible as long as
> no other Apps are getting in the way.
> 
> I suppose I could set a flag somewhere and then check it in the Activate
> notification handler.

Yeah, that’s what I’m suggesting. Your Activate handler will basically
operate in two modes: “passive” (where it adds apps to the array) and
“active” (where it dequeues an app from the array and asks NSWorkspace
to activate it).

--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: Scrolling table view when the keyboard appears

2016-05-24 Thread Kyle Sluder
On Tue, May 24, 2016, at 12:33 PM, Doug Hill wrote:
> OK, this might have been more obvious to people, but it finally came to
> me how to handle the keyboard display.
> 
> Instead of changing the view size, I move the center of the view up, then
> apply a content inset to the table to adjust for the part of the table
> offscreen. Animations seem to work much better now.

Did you really mean “move the center of the view”? Or did you mean
scrolling the center of the viewport?

Either way, contentInset is definitely the way to handle this.

--Kyle Sluder

> 
> Doug Hill
> 
> > On May 20, 2016, at 5:21 PM, Doug Hill  wrote:
> > 
> > I’m implementing a chat message view with a table view and a text field 
> > underneath it. I want the most recent messages at the bottom, and the 
> > scroll position always to stay at the last row in the table.
> > 
> > There are some tricks to making sure the table scrolls to the bottom when 
> > it’s first drawn and when adding new rows. I seem to be able to make this 
> > work but I’m running into a problem keeping the table scrolled to the 
> > bottom when the keyboard is shown. I listen for the 'keyboard shown’ 
> > notification and adjust the height of my entire view by the height of 
> > keyboard. This works but the scroll position ends up wrong, as it doesn’t 
> > keep the same scroll position at the last row when the view is moved up. 
> > OK, so I set the contentOffset to compensate for this.
> > 
> > Here is the code I use in the Keyboard Will show notification:
> > 
> > [UIView animateWithDuration:keyboardAnimDuration
> > animations:
> > ^{
> >self.view.frame = newViewFrame;
> > }
> > completion:^(BOOL finished)
> > {
> >[self.myTableView setContentOffset:newContentOffset animated:NO];
> > }];
> > 
> > So far, things work pretty well and things end up in the right place with. 
> > However, the animation is weird.
> > 
> > • Even though the view frame is changed inside the animation block, it 
> > moves into place immediately with no animation. No matter what duration I 
> > set it seems to be ignored.
> > • Then the keyboard scrolls into place. Because my view has already been 
> > moved up, you see a blank space where the keyboard moves up and over. This 
> > looks pretty bad.
> > • The table scrolls with an animation even though contentOffset is changed 
> > in the completion block and I set the animated param to NO.
> > • The time for the table scroll to animate is fixed.
> > 
> > Here is an example of this animation:
> > 
> > https://youtu.be/SBSts2UOJXw
> > 
> > (Try on slow speed to see it better)
> > 
> > I know this can be done correctly because I see other iOS chat apps that 
> > make the list view move up with the keyboard in a coordinated, smooth 
> > animation. Any ideas?
> > 
> > Doug
> > 
> > ___
> > 
> > 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/cocoadev%40breaqz.com
> > 
> > This email sent to cocoa...@breaqz.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/kyle%40ksluder.com
> 
> This email sent to k...@ksluder.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: Scrolling table view when the keyboard appears

2016-05-24 Thread Kyle Sluder
On Tue, May 24, 2016, at 05:37 PM, Alex Zavatone wrote:
> 
> On May 24, 2016, at 4:02 PM, Kyle Sluder wrote:
> 
> > On Tue, May 24, 2016, at 12:33 PM, Doug Hill wrote:
> >> OK, this might have been more obvious to people, but it finally came to
> >> me how to handle the keyboard display.
> >> 
> >> Instead of changing the view size, I move the center of the view up, then
> >> apply a content inset to the table to adjust for the part of the table
> >> offscreen. Animations seem to work much better now.
> > 
> > Did you really mean “move the center of the view”? Or did you mean
> > scrolling the center of the viewport?
> > 
> > Either way, contentInset is definitely the way to handle this.
> 
> Just checking.  You meant to use contentInset and not contentOffset? 

Yes, I meant contentInset. contentOffset is just another name for
self.bounds.origin.

--Kyle Sluder

> 
> I'm going to need to handle this exact issue soon too.
> 
> Thanks, Kyle.
> 
> Alex Zavatone
> 
> > --Kyle Sluder
> > 
> >> 
> >> Doug Hill
> >> 
> >>> On May 20, 2016, at 5:21 PM, Doug Hill  wrote:
> >>> 
> >>> I’m implementing a chat message view with a table view and a text field 
> >>> underneath it. I want the most recent messages at the bottom, and the 
> >>> scroll position always to stay at the last row in the table.
> >>> 
> >>> There are some tricks to making sure the table scrolls to the bottom when 
> >>> it’s first drawn and when adding new rows. I seem to be able to make this 
> >>> work but I’m running into a problem keeping the table scrolled to the 
> >>> bottom when the keyboard is shown. I listen for the 'keyboard shown’ 
> >>> notification and adjust the height of my entire view by the height of 
> >>> keyboard. This works but the scroll position ends up wrong, as it doesn’t 
> >>> keep the same scroll position at the last row when the view is moved up. 
> >>> OK, so I set the contentOffset to compensate for this.
> >>> 
> >>> Here is the code I use in the Keyboard Will show notification:
> >>> 
> >>> [UIView animateWithDuration:keyboardAnimDuration
> >>> animations:
> >>> ^{
> >>>   self.view.frame = newViewFrame;
> >>> }
> >>> completion:^(BOOL finished)
> >>> {
> >>>   [self.myTableView setContentOffset:newContentOffset animated:NO];
> >>> }];
> >>> 
> >>> So far, things work pretty well and things end up in the right place 
> >>> with. However, the animation is weird.
> >>> 
> >>> • Even though the view frame is changed inside the animation block, it 
> >>> moves into place immediately with no animation. No matter what duration I 
> >>> set it seems to be ignored.
> >>> • Then the keyboard scrolls into place. Because my view has already been 
> >>> moved up, you see a blank space where the keyboard moves up and over. 
> >>> This looks pretty bad.
> >>> • The table scrolls with an animation even though contentOffset is 
> >>> changed in the completion block and I set the animated param to NO.
> >>> • The time for the table scroll to animate is fixed.
> >>> 
> >>> Here is an example of this animation:
> >>> 
> >>> https://youtu.be/SBSts2UOJXw
> >>> 
> >>> (Try on slow speed to see it better)
> >>> 
> >>> I know this can be done correctly because I see other iOS chat apps that 
> >>> make the list view move up with the keyboard in a coordinated, smooth 
> >>> animation. Any ideas?
> >>> 
> >>> Doug

___

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: Scrolling table view when the keyboard appears

2016-05-24 Thread Kyle Sluder
On Tue, May 24, 2016, at 05:46 PM, Kyle Sluder wrote:
> On Tue, May 24, 2016, at 05:37 PM, Alex Zavatone wrote:
> > 
> > On May 24, 2016, at 4:02 PM, Kyle Sluder wrote:
> > 
> > > On Tue, May 24, 2016, at 12:33 PM, Doug Hill wrote:
> > >> OK, this might have been more obvious to people, but it finally came to
> > >> me how to handle the keyboard display.
> > >> 
> > >> Instead of changing the view size, I move the center of the view up, then
> > >> apply a content inset to the table to adjust for the part of the table
> > >> offscreen. Animations seem to work much better now.
> > > 
> > > Did you really mean “move the center of the view”? Or did you mean
> > > scrolling the center of the viewport?
> > > 
> > > Either way, contentInset is definitely the way to handle this.
> > 
> > Just checking.  You meant to use contentInset and not contentOffset? 
> 
> Yes, I meant contentInset. contentOffset is just another name for
> self.bounds.origin.

To clarify: you might want to change both the contentInset (to avoid the
keyboard) *and* the contentOffset (to move content that has been
obscured by the keyboard back into the visible part of the scrollview.)

--Kyle Sluder

> 
> --Kyle Sluder
> 
> > 
> > I'm going to need to handle this exact issue soon too.
> > 
> > Thanks, Kyle.
> > 
> > Alex Zavatone
> > 
> > > --Kyle Sluder
> > > 
> > >> 
> > >> Doug Hill
> > >> 
> > >>> On May 20, 2016, at 5:21 PM, Doug Hill  wrote:
> > >>> 
> > >>> I’m implementing a chat message view with a table view and a text field 
> > >>> underneath it. I want the most recent messages at the bottom, and the 
> > >>> scroll position always to stay at the last row in the table.
> > >>> 
> > >>> There are some tricks to making sure the table scrolls to the bottom 
> > >>> when it’s first drawn and when adding new rows. I seem to be able to 
> > >>> make this work but I’m running into a problem keeping the table 
> > >>> scrolled to the bottom when the keyboard is shown. I listen for the 
> > >>> 'keyboard shown’ notification and adjust the height of my entire view 
> > >>> by the height of keyboard. This works but the scroll position ends up 
> > >>> wrong, as it doesn’t keep the same scroll position at the last row when 
> > >>> the view is moved up. OK, so I set the contentOffset to compensate for 
> > >>> this.
> > >>> 
> > >>> Here is the code I use in the Keyboard Will show notification:
> > >>> 
> > >>> [UIView animateWithDuration:keyboardAnimDuration
> > >>> animations:
> > >>> ^{
> > >>>   self.view.frame = newViewFrame;
> > >>> }
> > >>> completion:^(BOOL finished)
> > >>> {
> > >>>   [self.myTableView setContentOffset:newContentOffset animated:NO];
> > >>> }];
> > >>> 
> > >>> So far, things work pretty well and things end up in the right place 
> > >>> with. However, the animation is weird.
> > >>> 
> > >>> • Even though the view frame is changed inside the animation block, it 
> > >>> moves into place immediately with no animation. No matter what duration 
> > >>> I set it seems to be ignored.
> > >>> • Then the keyboard scrolls into place. Because my view has already 
> > >>> been moved up, you see a blank space where the keyboard moves up and 
> > >>> over. This looks pretty bad.
> > >>> • The table scrolls with an animation even though contentOffset is 
> > >>> changed in the completion block and I set the animated param to NO.
> > >>> • The time for the table scroll to animate is fixed.
> > >>> 
> > >>> Here is an example of this animation:
> > >>> 
> > >>> https://youtu.be/SBSts2UOJXw
> > >>> 
> > >>> (Try on slow speed to see it better)
> > >>> 
> > >>> I know this can be done correctly because I see other iOS chat apps 
> > >>> that make the list view move up with the keyboard in a coordinated, 
> > >>> smooth animation. Any ideas?
> > >>> 
> > >>> Doug

___

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: NSFileWrapper

2016-06-05 Thread Kyle Sluder
On Sun, Jun 5, 2016, at 01:14 AM, Chris Ridd wrote:
> 
> > On 4 Jun 2016, at 23:02, Daryle Walker  wrote:
> > 
> >> On Jun 4, 2016, at 12:18 PM, Peter Hudson  wrote:
> >> 
> >> Hi Mike
> >> 
> >> You're right - I want the behaviour of a package. Do you happen to know 
> >> how I can achieve it?   I had presumed it might be some mix of flag 
> >> setting at system level. If for example i set the extension on an 
> >> NSFileWrapper to   .bundle i get some of what I need - but I cant find out 
> >> how to ‎get an icon of my choosing associated with it.
> > 
> > You’ll have to work at it; it won’t be completely transparent to your users 
> > to experience nor you to program.
> > 
> > The “.bundle” extension is already in use for system plug-ins.  You have to 
> > come up with a new extension.  For instance, if you’re already using “.xyz” 
> > for you single-file format, you could use “.xyz-pkg” for your package 
> > format.
> 
> Are you sure that’s true? Apps like OmniGraffle have a flat file format
> *and* a bundle format, both using the .graffle extension. In OmniGraffle
> Pro's document inspector you can switch between formats.

At one point OmniGraffle dropped the flat file/package inspector
precisely because using the same extension for both confused Launch
Services. But there was so much wrong with OmniGraffle’s UTI
declarations at the time; fixing them might have resolved the issue and
led to the return of the format switch.

If you’re going to try to share the same filename extension for packages
and flat files, it is doubly important that you have *two* UTIs, and
that teach UTI declare conformance to exactly *one or the other* of the
“physical” hierarchies. That means your document package UTI *must not*
conform to your flat-file UTI, because then it would conform to both the
package and flat-file physical hierarchies, and LS will get confused
about which UTI should be used for flat files.

--Kyle Sluder

> 
> If you have the app or a demo you can investigate its Info.plist.
> 
> Chris

___

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: Doc icon shows up in QuickLook but not Finder

2016-06-07 Thread Kyle Sluder
On Tue, Jun 7, 2016, at 04:26 PM, Rick Mann wrote:
> Some have reported this before, but none of the solutions (namely,
> rebuilding the launch services DB) seem to work.
> 
> I have a document package with extension .mpproj. I get a generic
> document icon in the Finder, but if I quicklook the document, it shows
> the right icon.
> 
> Any suggestions? The app icon took immediately. I tried relaunching the
> Finder. I have not tried restarting.

Does your corresponding UTI declaration correctly conform to
`com.apple.package` and NOT to `public.data`?

--Kyle Sluder

> 
> -- 
> 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: Open-file progress dialog with cancel button

2016-06-10 Thread Kyle Sluder
On Fri, Jun 10, 2016, at 11:03 AM, Daryle Walker wrote:
> I don't need this (yet), but it popped up in my head. Usually,
> readFromData: ofType: processes the data in place.  But what if the
> process take a while, or you otherwise want to provide a progress window
> (maybe with a cancel button)? I guess you could handle the parsing in an
> NSOperation, but how do you establish the window and make sure
> readFromData for that instance doesn't deadlock the rest of the program?

Check out +[NSDocument canConcurrentlyReadDocumentsOfType:].

--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: quicklook audio sample rates

2016-06-10 Thread Kyle Sluder
On Thu, Jun 9, 2016, at 08:03 PM, George Toledo wrote:
> I'm having a hard time finding documentation that covers this question...
> 
> Does Quicklook play audio of a previewed file at the sample rate it was
> encoded at, or is it somehow doing a samplerate conversion on the fly?
> 
> Hopefully this isn't considered off topic. Though it doesn't directly
> concern Obj-C/Cocoa code, I was looking for an answer in the Quicklook
> Programming guide, and couldn't find one.

This is a highly specific question and is unlikely to be documented. I’m
curious why you’re interested.

At the end of the day, the audio hardware operates at some particular
bitrate, so unless your source exactly matches the hardware sample rate
there’s likely to be a SRC in the audio pipleline *somewhere*.

--Kyle Sluder

> 
> Thanks,
> George Toledo
> ___
> 
> 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/kyle%40ksluder.com
> 
> This email sent to k...@ksluder.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: NSService (aka. Bonjour) outside local network

2016-06-24 Thread Kyle Sluder
On Fri, Jun 24, 2016, at 02:11 AM, Gerriet M. Denkmann wrote:
> Is it possible to create an NSService (OS X 10.11.45) which is
> discoverable (via NSServiceBrowser) outside of the local WiFi network?

Only if your machine is configured for Wide-area Bonjour. Regular
Bonjour is restricted to the local subnet.

> What should be used for domain in this case?

Whatever WAB domain(s) are configured on the machine.

The macnetworkprog list might be a better resource.

--Kyle Sluder

> If not: what is the use of domain ≠ “local.” , e.g. domain = “” ?
> 
> Also: I noticed that includesPeerToPeer = YES makes the kernel_task,
> which usually takes about 1% of my Cpu, go up to 11%. Back to 1% one
> minute after the app with NSService quits.
> 
> Is this normal and to be expected?
> 
> 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

Re: Why can't Swift instance methods call class methods without qualification?

2016-06-30 Thread Kyle Sluder
On Thu, Jun 30, 2016, at 07:20 PM, Rick Mann wrote:
> Why can my instance methods not call class methods without the class
> specifier?
> 
> class MyClass
> {
> func
> foo()
> {
> classMethod()
> }
> 
> class
> func
> classMethod()
> {
> }
> }
> 
> Why do I have to call MyClass.classMethod()? Just a choice made by the
> language designers to distinguish the call at the call site? I like C++'s
> way of treating all static methods as directly available to the instance.

The official swift-users list might be a better place to ask this
question:

https://lists.swift.org/mailman/listinfo/swift-users

--Kyle Sluder

> 
> -- 
> 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: awakeFromFetch behaviour change in 10.12?

2016-07-25 Thread Kyle Sluder
On Mon, Jul 25, 2016, at 09:14 AM, Sean McBride wrote:
> Hi all,
> 
> I'm observing that in 10.12 my awakeFromFetch methods are being called
> more than in 10.11 and earlier.  Specifically, it's called more than once
> for an object that's already been fetched previously.
> 
> Perhaps I have misunderstood the method's semantics all these years, but
> I expected that awakeFromFetch would only be called once, when an object
> is first awaken from the persistent store.
> 
> Now I'm seeing that if I execute a fetch request where
> returnsObjectsAsFaults=YES awakeFromFetch will be invoked on all the
> resulting objects, even if it'd been invoked before.
> 
> Does that seem correct to you?

This does not sound like expected behavior. Could you please file a bug
report at https://bugreport.apple.com and attach a sample project if at
all possible?

Thanks,
--Kyle Sluder

> 
> Thanks,
> 
> -- 
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com 
> Mac Software Developer  Montréal, Québec, Canada
> 
> 
> 
> ___
> 
> 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/kyle%40ksluder.com
> 
> This email sent to k...@ksluder.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: NSImage drawInRect deadlock

2016-08-08 Thread Kyle Sluder
On Mon, Aug 8, 2016, at 05:11 PM, Jens Alfke wrote:
> 
> > On Aug 8, 2016, at 2:54 PM, Aaron Tuller  wrote:
> > 
> > "The following classes and functions are generally not thread-safe. In most 
> > cases, you can use these classes from any thread as long as you use them 
> > from only one thread at a time."
> 
> The images are only being used on one thread at a time. The problem seems
> to be that the NSImage _cache_ is shared and (apparently) not
> thread-safe.

I wouldn’t jump immediately to thread-unsafety. It’s possible that
Andrew is simply exhausting the thread pool.

Andrew, are you doing anything to limit the amount of decode operations
you’re putting on the global queue?

--Kyle

> 
> —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

Re: NSImage drawInRect deadlock

2016-08-09 Thread Kyle Sluder
On Tue, Aug 9, 2016, at 07:38 AM, Andrew Keller wrote:
> Am 08.08.2016 um 8:12 nachm. schrieb Kyle Sluder :
> > 
> > On Mon, Aug 8, 2016, at 05:11 PM, Jens Alfke wrote:
> >> 
> >>> On Aug 8, 2016, at 2:54 PM, Aaron Tuller  wrote:
> >>> 
> >>> "The following classes and functions are generally not thread-safe. In 
> >>> most cases, you can use these classes from any thread as long as you use 
> >>> them from only one thread at a time."
> >> 
> >> The images are only being used on one thread at a time. The problem seems
> >> to be that the NSImage _cache_ is shared and (apparently) not
> >> thread-safe.
> > 
> > I wouldn’t jump immediately to thread-unsafety. It’s possible that
> > Andrew is simply exhausting the thread pool.
> > 
> > Andrew, are you doing anything to limit the amount of decode operations
> > you’re putting on the global queue?
> 
> Not presently.  Under normal usage, it hovers around 10-40 threads, but
> I’ve seen it as high as 200.  Honestly, I was hoping to limit it to 3 or
> 6 — just experimentally, one thread by itself can saturate roughly 20-30%
> of my i7 processor.  If 3-6 simultaneous operations will saturate the
> whole processor, I don’t see much value in letting it go much higher than
> that.
> 
> What is the preferred way to limit the number of parallel operations in
> the global queue?  I was under the impression from the docs that macOS
> handles the thread pool “automatically”.

Mike Ash did a good job explaining why this isn’t as “automatic” as one
might think:
https://www.mikeash.com/pyblog/friday-qa-2009-09-25-gcd-practicum.html

--Kyle Sluder

> 
> Thanks,
>  - Andrew
> 

___

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: array = [NSArray new] or array = [NSArray array]?

2016-08-19 Thread Kyle Sluder


On Fri, Aug 19, 2016, at 06:08 PM, Charles Srstka wrote:
> > On Aug 19, 2016, at 3:46 PM, Quincey Morris 
> >  wrote:
> > 
> > On Aug 19, 2016, at 10:53 , Charles Srstka  > <mailto:cocoa...@charlessoft.com>> wrote:
> >> 
> >> [NSArray array] is a synonym for [[[NSArray alloc] init] autorelease].
> > 
> > (along with other similar comments in other responses)
> > 
> > To be pedantic, it’s *implemented* as [[[NSArray alloc] init] autorelease], 
> > but the lack of an API contract to that effect means that “synonym” isn’t 
> > quite accurate.
> > 
> > My point is that Apple might revisit the implementation of NSArray at any 
> > time (in these Swiftian days, stranger things have happened), and choose to 
> > write it with full ARC compatibility, which means there might not be any 
> > autorelease when invoked from ARC client code, since ARC can optimize the 
> > code when it handles both ends of the invocation.
> 
> Swift typically just calls the initializer if it’s there, so the
> convenience initializers like +[NSArray array] are really only relevant
> to Objective-C code. For that reason, I doubt they’d change unless Apple
> did something crazy like rewrite the entire frameworks in Swift, in which
> case they’d probably go away.

There is an official reimplementation of Foundation/CoreFoundation in
Swift. The implementation of NSObject lacks a `static func new`:
<https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSObject.swift>
Likewise, Swift explicitly does not bridge `+new` from ObjC, so this is
a moot point in Swift code.

> So for the foreseeable future, the
> difference is that +array returns an autoreleased object, meaning that in
> ARC code, +new is the better choice.

I would not make that assumption. Who says +[NSArray array] constructs
anything at all? Try comparing the return values of two calls to
[NSArray array] sometime. ;-)

I happen think +new is more readable, but it’s really just a matter of
preference.

--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: runModalForWindow() doesn't re-activate former window upon return

2016-08-25 Thread Kyle Sluder


On Thu, Aug 25, 2016, at 01:51 PM, Andreas Falkenhahn wrote:
> On 25.08.2016 at 19:47 Keary Suska wrote:
> 
> >> On Aug 25, 2016, at 9:45 AM, Andreas Falkenhahn  
> >> wrote:
> 
> >> Tested it, the window is clearly main and key, this is the debug output:
> 
> >> CHECK: 0x10040b4d0 0x10040b4d0 0x10040b4d0
> 
> >> i.e. [NSApp mainWindow], [NSApp keyWindow] and my NSWindow pointer are
> >> exactly the same before runModalForWindow() is called.
> 
> > What are they *after* the modal loop has ended?
> 
> They are both set to a window pointer that doesn't belong to my
> application.

-mainWindow and -keyWindow don’t return pointers to windows outside of
your application. (How could they? Other applications have their own
address spaces.) They either return pointers to windows in your app
(which might be windows owned by the framework), or they return nil.

--Kyle Sluder

> I've logged both pointers directly after runModalForWindow() returns.
> 
> > What happens if you add -orderOut: to the button action method?
> 
> Ok, this solves the problem. But still, shouldn't this be handled
> automatically
> by runModalForWindow()? Why does it activate a window that doesn't belong
> to
> my application when it returns? That doesn't look reasonable to me at
> all...
> 
> -- 
> Best regards,
>  Andreas Falkenhahn   
>  mailto:andr...@falkenhahn.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 crash with NSTableView

2016-08-26 Thread Kyle Sluder
On Fri, Aug 26, 2016, at 12:25 PM, Gary L. Wade wrote:
> I'm talking about exchanging release for autorelease on your list
> delegate, which happens after runModal finishes. Since you now do an
> orderOut, your table view should not need its data source/delegate, so it
> should be safe keeping them set and using an autorelease, but clearing
> them is the safest.

Neither autorelease nor release on its own is sufficient here; Andreas
should clear out his delegates. This is true either in ARC or non-ARC,
whether the delegate property is declared `unsafe_unretained` (née
`assign`) or `weak`.

You don’t know when an object will be deallocated. While it would be
unexpected (and arguably an error) for NSTableView to hand off its
delegate to something that will take a long-lived strong +1 reference to
it, it is perfectly legal for the delegate to wind up in the autorelease
pool for an indefinite period of time. Delegates are most likely not
written to handle being called in that limbo state where they’re still
alive and assigned to the delegate property, but the object that created
them has disavowed them by releasing its last strong reference to them.

`weak` prevents retain cycles. It does not ensure program correctness.

> 
> This kind of exercise in understanding the MRC rules is precisely why ARC
> was created. If you need to use MRC, you probably should do what lots of
> others did and draw lots of pictures in timeframes with tally counts on
> objects to understand what happens when. If you go with ARC, this
> clearing should happen for you—I'm pretty sure the data source and
> delegate are weak, but I don't have the headers in front of me right now.

Automatic clearing of zeroing weak references is dependent on the
*implementor* being compiled with ARC. Non-ARC clients will still see
another object’s zeroing weak ref go to nil when the last strong ref to
the referent is released.

Here’s some sample code:

/* WeakRefHolder.h
 * This file is transcluded twice: once with ARC enabled, once with ARC
 disabled.
 */
#import 

@interface WeakRefHolder : NSObject

@property(weak) id weakRef;

@end
/* WeakRefHolder.m
 * clang -c -o WeakRefHolder.o -fobjc-arc WeakRefHolder.m
 */

#if !__has_feature(objc_arc)
#error WeakRefHolder implementation must be compiled with ARC
#endif

#import "WeakRefHolder.h"

@implementation WeakRefHolder
// Automatically synthesize implementation of .weakRef property
@end

/* main.m
 * Compile: clang -o main -framework Foundation -fno-objc-arc main.m
 WeakRefHolder.o
 */

#if __has_feature(objc_arc)
#error Main file should not be compiled with ARC
#endif

#import "WeakRefHolder.h"
#import 

@interface SquealOnDealloc : NSObject
@end

@implementation SquealOnDealloc
- (void)dealloc {
printf("<%p> deallocating!\n", self);
[super dealloc];
}
@end

int main(int argc, char **argv)
{
WeakRefHolder *holder = [[WeakRefHolder alloc] init];
id referent;
@autoreleasepool {
printf(">> Pushing autorelease pool\n");
referent = [[SquealOnDealloc alloc] init];
printf("Assigning <%p> to .weakRef property\n",
referent);
holder.weakRef = [referent autorelease];
printf("<< Popping autorelease pool\n");
}

printf(".weakRef = %p\n", holder.weakRef);
return 0;
}

--Kyle Sluder

> --
> Gary L. Wade (Sent from my iPhone)
> http://www.garywade.com/
> 
> > On Aug 26, 2016, at 9:38 AM, Andreas Falkenhahn  
> > wrote:
> > 
> >> On 26.08.2016 at 17:52 Gary L. Wade wrote:
> >> 
> >> You would not see this if you hid or removed the table view first
> >> since it would not need its data source or delegate then. Try going
> >> with ARC or at least use autorelease on your delegate/data source.
> > 
> > I'm not using autorelease on the delegate/data source on purpose because
> > AFAIU autoreleased objects are (potentially) killed whenever the application
> > is in an event loop and this is the case with runModalForWindow(). AFAIU
> > if I used autorelease on the delegate/data source then both would be
> > killed in the run loop started by runModalForWindow() because both 
> > setDelegate()
> > and setDatasource() don't retain. So using autorelease doesn't make sense
> > to me here. Is this right or did I get anything wrong here?
> > 
> > -- 
> > Best regards,
> > Andreas Falkenhahnmailto:andr...@falkenhahn.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 crash with NSTableView

2016-08-28 Thread Kyle Sluder
On Sat, Aug 27, 2016, at 03:55 PM, Andreas Falkenhahn wrote:
> On 27.08.2016 at 18:10 Alex Zavatone wrote:
> 
> > Buuut, to the mind of the person learning this or trying to fit all
> > the complexity of learning this in their head, it might be wise in
> > the docs to remind the programmer that they need to do this and why
> > with a, "just in case you are assuming that your code is ready to
> > function now, please remember that the objects that end up making a
> > working tableView require that the tableView's  dataSource object
> > and delegate object need to be assigned, generally to the hosting
> > view controller's instance of self. If this causes you to raise an
> > eyebrow in confusion, the reasons why you must do this are xxx and
> > .  Likewise upon deallocation of the tableView (if it gets
> > called), these objects will need to be set to nil after  but
> > before the tableView object is able to dispose of itself."
> 
> Huh? "Remember that you have to set this property to nil before you
> release the object" would already be sufficient...
> 
> By the way, I still don't know whether setting the delegate to nil
> before release is a general rule or does it only apply to NSTableView?
> Should I also set my button delegates to nil before the buttons are
> released?

Buttons don’t have delegates; they have targets.

Generally applications work fine without nilling out the targets of
their controls. This only works because controls almost exclusively
message their targets synchronously on the main in response to user
actions. There’s no opportunity for one of the target’s dependencies to
be deallocated in between the user triggering the target-action message
and the target receiving the action message.

Delegates are different because they are often messaged in response to
various exogenous events. Some of these events might happen transiently
during window teardown, which is usually a time of massive fluctuation
in an app’s object graph. This is why -windowDidClose: is a good time to
nil out delegate properties that point back and the window controller
which ultimately owns the control.

That said, it is totally possible for a control to delay-perform sending
an event, and even if it takes pains to make sure it doesn’t message the
_target_ if it’s been deallocated, one of the target’s _dependencies_
might have been deallocated. These cases are usually found after much
swearing and trial-by-fire. Such is the difference between theory and
practice.

--Kyle Sluder

> 
> -- 
> Best regards,
>  Andreas Falkenhahn   
>  mailto:andr...@falkenhahn.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 crash with NSTableView

2016-08-29 Thread Kyle Sluder
> On Aug 29, 2016, at 6:39 AM, Andreas Falkenhahn  
> wrote:

> 
>> On 29.08.2016 at 02:10 Kyle Sluder wrote:
>> 
>> Delegates are different because they are often messaged in response to
>> various exogenous events. Some of these events might happen transiently
>> during window teardown, which is usually a time of massive fluctuation
>> in an app’s object graph. This is why -windowDidClose: is a good time to
>> nil out delegate properties that point back and the window controller
>> which ultimately owns the control.
> 
> So does this mean that this is potentially dangerous?
> 
>[NSApp runModalForWindow:win];
>[tableView setDelegate:nil];
>[tableView setDataSource:nil];
>[win release];
> 
> Should I move the "set to nil" calls to -windowDidClose instead?

Since you hold a strong reference to the window until after you clear out the 
delegate/dataSource backpointers, you know that the window cannot be 
reallocated until at least that point (but could be delayed to any arbitrary 
point in the future). So this approach is safe from window teardown causing the 
table view to message a zombie delegate.

--Kyle Sluder

> 
> -- 
> Best regards,
> Andreas Falkenhahnmailto:andr...@falkenhahn.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: How to set up my NSViews?

2016-09-06 Thread Kyle Sluder
On Tue, Sep 6, 2016, at 01:38 PM, Andreas Falkenhahn wrote:
> On 06.09.2016 at 18:51 Ken Thomases wrote:
> 
> > On Sep 6, 2016, at 11:41 AM, Andreas Falkenhahn  
> > wrote:
> 
> >> My NSWindow contains an NSView which I use to draw custom graphics to. It 
> >> doesn't
> >> contain any widgets like buttons at all, just custom graphics drawn in 
> >> drawRect().
> 
> >> Now I'd like to have an AVPlayerView NSView on top of this view. Thus, I 
> >> tried to
> >> add this AVPlayerView on top of the NSView by doing the following:
> 
> >>[view addSubview:playerview];
> 
> >> However, this didn't work and generated lots of debug output to stderr.
> 
> > What, specifically, does "this didn't work" mean?  What debug output was 
> > logged?
> 
> Well, this list has a limit of 25kb per mail, so here is just the first
> 20% of what
> was logged:
> 
> (
> " '|':MyAVPlayerView:0x1004f5b70 )>",
> 
> [:snip:]
> 
> 
> Let me know if you need more :)
> 

It looks like the constraints that AVPlayerView uses to manage its own
internal layout are in conflict with its frame. Did you give the
AVPlayerView a non-zero frame before inserting it as a subview? If
you’re trying to position it using Auto Layout, did you remember to turn
.translatesAutoresizingMaskIntoConstraints off?

--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: Strange toolbar item error

2016-09-14 Thread Kyle Sluder
On Wed, Sep 14, 2016, at 07:50 PM, Shane Stanley wrote:
> Under 10.12 GM, I'm seeing entries like this in Console:
> 
> NSToolbarItem () had to adjust the size of
>  from {38, 25} to the expected size of {40,
> 27}. Make sure that this toolbar item view has a valid frame/min/max
> size. This is an app bug, please do not file a bug against AppKit or
> NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint
> 
> I'm seeing it in a couple of apps -- one using a standard nib approach,
> and one generating the toolbar fully in code. 
> 
> In the nib one, the toolbar has buttons on the toolbar items, and IB
> won't even allow any size other than 25px deep. I've tried fiddling with
> the toolbar item sizes, to no avail. I added the suggested breakpoint,
> but I don't see it break. If the message weren't so adamant, I'd be
> inclined to question it.
> 
> Anyone else seen it, or have suggestions?

What’s your app’s deployment target? What’s the deployment target of
your nib (listed in the file inspector while the nib is open for
editing)?

--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

Re: Strange toolbar item error

2016-09-17 Thread Kyle Sluder


On Fri, Sep 16, 2016, at 11:11 PM, Shane Stanley wrote:
> On 15 Sep 2016, at 2:54 PM, Kyle Sluder  wrote:
> > 
> > On Wed, Sep 14, 2016, at 07:50 PM, Shane Stanley wrote:
> >> Under 10.12 GM, I'm seeing entries like this in Console:
> >> 
> >> NSToolbarItem () had to adjust the size of
> >>  from {38, 25} to the expected size of {40,
> >> 27}. Make sure that this toolbar item view has a valid frame/min/max
> >> size. This is an app bug, please do not file a bug against AppKit or
> >> NSToolbar! Break on _NSToolbarAdjustedBorderedControlSizeBreakpoint
> >> 
> >> I'm seeing it in a couple of apps -- one using a standard nib approach,
> >> and one generating the toolbar fully in code. 
> >> 
> >> In the nib one, the toolbar has buttons on the toolbar items, and IB
> >> won't even allow any size other than 25px deep. I've tried fiddling with
> >> the toolbar item sizes, to no avail. I added the suggested breakpoint,
> >> but I don't see it break. If the message weren't so adamant, I'd be
> >> inclined to question it.
> >> 
> >> Anyone else seen it, or have suggestions?
> > 
> > What’s your app’s deployment target? What’s the deployment target of
> > your nib (listed in the file inspector while the nib is open for
> > editing)?
> 
> I checked under the latest(?) GM, and it's still showing "Deployment
> Target(10.9)".
> 
> For anyone seeing the same thing, the solution seems to be to change the
> max size of the toolbar items to the unexpected "expected" size.

Yes, the intent of the warning message is to get you to do that. But
since you’re linking against and deploying to Mavericks, I fear you’ll
wind up with too-big buttons on older OSes. Could you please file a bug
report with a sample project attached, and send me the bug number?

> I
> thought I'd already tried this without success, until I realized what was
> happening: I had edited the values, then closed the toolbar editor in IB.
> I've now realised that the changes were not being saved; when I reopened
> the toolbar editor, the old values were still showing. Running once with
> the toolbar editor open seems to have made the changes 'take". (And yes,
> I tried cleaning at various stages.)

This sounds worthy of investigation. Could you please file a bug report
detailing the _exact_ steps that resulted in your changes being
forgotten? Send me that bug number too please.

> 
> Along the way I discovered another problem in Xcode 8: setting a button
> to image-only in IB still shows any title if there is one.

I think we have a bug report on this already. In the meantime, if you
clear out the Title property, please make sure to populate the relevant
Accessibility properties.

--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: Strange toolbar item error

2016-09-18 Thread Kyle Sluder
On Sat, Sep 17, 2016, at 09:24 PM, Shane Stanley wrote:
> On 18 Sep 2016, at 3:12 AM, Kyle Sluder  wrote:
> > 
> >> For anyone seeing the same thing, the solution seems to be to change the
> >> max size of the toolbar items to the unexpected "expected" size.
> > 
> > Yes, the intent of the warning message is to get you to do that. But
> > since you’re linking against and deploying to Mavericks, I fear you’ll
> > wind up with too-big buttons on older OSes. Could you please file a bug
> > report with a sample project attached, and send me the bug number?
> 
> Will do. So if I understand you correctly, my options are:
> 
> * Change the max size as above, and have toolbar items potentially appear
> the wrong size pre-Sierra;
> 
> * Ignore the warning and have everything appear as it should in each
> version;
> 
> * Perhaps set the max size in code, based on the running OS version.

Your understanding matches mine. (I don’t work on the team that manages
NSToolbar, so I will let them have the final say in the response to your
bug report.) In the meantime, I would go with option #2.

--Kyle Sluder

> 
> FWIW, I'm also seeing it on another project, which is more complex: the
> toolbar items are all moderately subclassed, it doesn't use autolayout,
> and it's all done in code rather than a nib. I've tried a few things, but
> I can't see any way to make the warning go away. 
> 
> I think I understand the point of the message, but the adamant tone is
> going to put developers in an invidious position if users start logging
> bugs with them over it.
> 
> >> I
> >> thought I'd already tried this without success, until I realized what was
> >> happening: I had edited the values, then closed the toolbar editor in IB.
> >> I've now realised that the changes were not being saved; when I reopened
> >> the toolbar editor, the old values were still showing. Running once with
> >> the toolbar editor open seems to have made the changes 'take". (And yes,
> >> I tried cleaning at various stages.)
> > 
> > This sounds worthy of investigation. Could you please file a bug report
> > detailing the _exact_ steps that resulted in your changes being
> > forgotten? Send me that bug number too please.
> 
> It's #28348587.
> 
> >> Along the way I discovered another problem in Xcode 8: setting a button
> >> to image-only in IB still shows any title if there is one.
> > 
> > I think we have a bug report on this already.
> 
> I've already filed #28348535, which includes a simple example.
> 
> -- 
> Shane Stanley 
> , 
> 
> 

___

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: NSMenuItem’s userKeyEquivalent lost if changing title

2016-09-20 Thread Kyle Sluder
On Tue, Sep 20, 2016, at 02:56 AM, Allan Odgaard wrote:
> Minor improvement on the code below, when title is equal to plainTitle 
> we can set attributedTitle to nil.
> 
> This restores proper rendering of disabled items.
> 
> Finder should be able to do the same, as when its dynamic menu items are 
> disabled, they would normally not contain the dynamic part (info about 
> selected items).

Sounds like a great UI bug report to file, Allan. :)

--Kyle Sluder

> 
> 
> On 20 Sep 2016, at 9:37, Allan Odgaard wrote:
> 
> > Thanks, I’ll switch to using this category method for setting 
> > dynamic titles:
> >
> > - (void)setDynamicTitle:(NSString*)plainTitle
> > {
> > if(self.userKeyEquivalent && ![self.userKeyEquivalent 
> > isEqualToString:@""])
> > {
> > NSString* title = plainTitle;
> > plainTitle = self.title;
> >
> > NSFont* font = self.menu.font ?: [NSFont menuFontOfSize:0];
> > self.attributedTitle = [[NSAttributedString alloc] 
> > initWithString:title attributes:@{ NSFontAttributeName : font }];
> > }
> > self.title = plainTitle;
> > }
> ___
> 
> 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/kyle%40ksluder.com
> 
> This email sent to k...@ksluder.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: Re: Passing param by reference then using within block throws exception

2016-09-22 Thread Kyle Sluder
On Wed, Sep 21, 2016, at 09:22 AM, Steve Mills wrote:
> On Sep 21, 2016, at 08:53 AM, Alex Zavatone  wrote:
> 
> Stab in the dark here, but I'm stabbing blank. Is there an Instruments
> tool or debugging option to detect this? 
> 
> Thanks for getting stabby. Fourvel appreciates it (only relevant if
> you're a CBB fan). It doesn't appear that anything will detect this. When
> zombies is on, it says an address is attempting to be retained but was
> previously released. That's a bit of a red herring, since the only 2
> variables being uses have just been declared and initialized right before
> the call to the method. If anything, the process of converting to ARC or
> the static analyzer should've flagged this as a problem.

Are you able to reproduce this in a sample app? I tried the following
but got no crash:

#include 
#import 

static void foo(NSString **fillMeIn) {
[@[@"a"] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx,
BOOL *stop) {
*fillMeIn = obj;
*stop = YES;
}];
}

int main(int argc, char **argv) {
@autoreleasepool {
NSString *out;
foo(&out);
    printf("%s", out.UTF8String);
}
return 0;
}


--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

Re: Triggering a segue from code

2016-09-22 Thread Kyle Sluder
On Mon, Sep 19, 2016, at 10:07 PM, Quincey Morris wrote:
> On Sep 19, 2016, at 18:10 , mail...@ericgorr.net
> <mailto:mail...@ericgorr.net> wrote:
> > 
> > The strange behavior I am now seeing is that when I show & hide the panel 
> > using the buttons are what appears to be two (not three, not four, etc.) 
> > different instances of the inspector panel. The autosave information only 
> > appears to apply to one but not the other.
> 
> A couple of things:
> 
> 1. You’re keeping the panel window instance reference in
> InspectorWindowController.sharedInstance, but not keeping a reference to
> its window controller. That causes its window controller to be
> deallocated early, although that likely has nothing to with the rest of
> the problem, since the panel doesn’t have any custom behavior yet. You
> should keep a reference to the window controller instead, and that will
> keep the panel alive too.
> 
> 2. You’re doing a “performClose” to hide the panel. If you do an orderOut
> instead, you get the behavior you want.
> 
> Note that you are getting a new instance of the panel because the window
> segue mechanism decides the first one has disappeared. Again because it’s
> not documented how window segues work, there’s no way of knowing what the
> “correct” behavior is supposed to be. (Your panel window is correctly set
> to “Single” mode in the storyboard, which is what’s supposed to prevent
> multiple instances from appearing.)
> 
> Also undocumented — forever AFAIK although others on this list may know
> more about this — is what a window “close” (or “performClose”) does,
> other than ordering out the window and (if it’s set to release on close)
> to release it.

-performClose: is documented to highlight the Close button, so that it
is highlighted if any “unsaved changes” confirmation sheets are
displayed. That helps the user understand what will happen to the
document window if they confirm the Save panel.

-close asks the window’s delegate (via -windowShouldClose:) if it should
close. If the window is owned by a window controller that’s associated
with a document, the document will also get a chance to weigh in via
-shouldCloseWindowController:…. It will also send
NSWindowWillCloseNotification.

-orderOut: just hides the window (removes it from the window list). You
can always order it back in again later.

--Kyle Sluder

> Whatever a “close” actually does, it’s making the
> storyboard mechanism unable to find the panel instance, so it creates a
> new one. (Your panel is *not* set to release on close, and I was able to
> verify that it’s not being released regardless, so this is not anything
> you appear to be doing wrong.)
> 
> ___
> 
> 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/kyle%40ksluder.com
> 
> This email sent to k...@ksluder.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: Triggering a segue from code

2016-09-22 Thread Kyle Sluder
On Thu, Sep 22, 2016, at 02:47 PM, Quincey Morris wrote:
> On Sep 22, 2016, at 12:34 , Kyle Sluder  wrote:
> > 
> > -close asks the window’s delegate (via -windowShouldClose:) if it should
> > close. If the window is owned by a window controller that’s associated
> > with a document, the document will also get a chance to weigh in via
> > -shouldCloseWindowController:…. It will also send
> > NSWindowWillCloseNotification.
> > 
> > -orderOut: just hides the window (removes it from the window list). You
> > can always order it back in again later.
> 
> Yes, but ignore for a moment the “shouldClose…” interaction, and assume
> the window is NOT set to release on close. What *else* does “close” do
> vs. “orderOut”?

This question sounds vaguely similar to “What have the Romans done for
us?” from Life of Brian. ;-)

> 
> The example app mentioned in this thread demonstrates that “close” has
> some other effect beyond what “orderOut” does. In particular, a
> “single”-mode storyboard segue re-uses an ordered-out window, but not a
> closed one.

I must first admit, especially for the benefit of anyone who read the
documentation after I replied to you, that I was mistaken.
-shouldCloseWindowController: and -windowShouldClose: are only sent from
-performClose:, not from -close. Which makes sense: -close is the
unconditional way for an app (that might have even implemented its own
confirmation flow) to close a window.

Having made my apologies, -orderOut: and -close live at two levels of
abstraction. -orderOut deals with the window’s order and membership in
the window list. -close deals with higher-level semantics like window
controllers, documents, and notifications. As part of these higher-level
semantics, -close calls -orderOut:. For document-based apps, it also
dissociates the window from the document (and the window controller the
document made for it). And as Eric has discovered, it instructs the
Storyboard runtime to create a new instance of the window controller
rather than unhiding the existing one.

(-close used to render windows more thoroughly dead in the era of
releaseWhenClosed and one-shot backing stores. But those days are in the
past.)

--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: Triggering a segue from code

2016-09-22 Thread Kyle Sluder
On Sep 22, 2016, at 10:13 PM, Shane Stanley  wrote:
> 
>> On 23 Sep. 2016, at 1:17 pm, Kyle Sluder  wrote:
>> 
>> -close used to render windows more thoroughly dead
> 
> So can we assume that the close button generally calls -close?

No. You can assume it is morally similar to -performClose, but that is all the 
documentation promises.

> 
> On a tangent here...
> 
> In Safari, it used to be that if a script asked for the app's windows, 
> -orderedWindows would return a list of open windows. Under Sierra, however, 
> the list returned can include windows that have been closed via the close box 
> -- you might have closed them half-an-hour ago. They show with a visible 
> property of false, but by setting it to true they reappear -- no Web 
> contents, but the URL, title, etc all intact. And the only way to close them 
> is again via script -- their close buttons do nothing.
> 
> It's probably just a bug, although DTS don't seem to think so, but these 
> windows seem surprisingly resistant to death.

Did you file a Radar or merely contact DTS? Note that starting in Sierra you 
can use Cmd-Z to unclose more than just the most-recently-closed tab.

--Kyle Sluder

> 
> -- 
> Shane Stanley 
> , 
> 
> 


___

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: PDFKit on 10.12

2016-10-05 Thread Kyle Sluder
On Wed, Oct 5, 2016, at 04:08 AM, Jonathan Mitchell wrote:
> 
> > On 5 Oct 2016, at 07:52, Antonio Nunes  wrote:
> > 
> > On 04 Oct 2016, at 14:26, Jonathan Mitchell  wrote:
> >> 
> >> PDFKit seems a bit disturbed on Sierra.
> >> The 10.12 beta 3 seems to improve things but there are still some 
> >> rendering stutters etc.
> > 
> > 1. Why are you referring to a beta, when 10.12 has been out for weeks now?
> 
> Oops. that should have been 10.12.1 Beta (16B2338c)..
> 
> > Whatever is going on with PDFKit, it’s not good.
> 
> 
> I agree with that.
> 
> PDFKit is long in the tooth and the documentation is a bit patchy.
> However there is no way I can just write it off.
> 
> My solution involves assembling multipage PDFs from templates that
> incorporate a static base PDF over which I write text derived from my
> object model.
> The composed PDF is then viewed, printed or exported.
> On 10.9 to 10.11 peace reigns.
> 
> The 10.12 issues are rather unpredictable.
> Some documents render fine others don’t.
> Obviously this makes tracking down the source of the issues tough.
> It also makes it difficult to come up with meaningfully directed bug
> reports to send back in to bugreporter.apple.com.
> 
> It would be helpful if someone from the PDFKit development team would
> chip in with insight into how the kit has changed in 10.12.
> 
> If not I might need to go down the route of a TSI.

The first thing DTS will ask you is, “what are your bug numbers?” So
work on filing those first. A minimally-useful bug report is better than
no bug report at all.

--Kyle Sluder

> 
> 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

Re: How to count Atoms

2016-10-07 Thread Kyle Sluder


On Fri, Oct 7, 2016, at 11:24 AM, Jens Alfke wrote:
> 
> > On Oct 7, 2016, at 1:14 AM, Quincey Morris 
> >  wrote:
> > 
> > One straightforward way is to use dispatch_semaphore. IIRC it’s lightweight 
> > unless it blocks (that is, unless its count is zero when you wait), so it’s 
> > good for this situation where actual contention is rare (assuming actual 
> > contention is rare).
> 
> IMO dispatch_semaphore is overkill for this; it’s not just an atomic
> counter, it’s also got blocking behaviors for use in e.g. managing a pool
> of resources. I’ll bet that most Mac/iOS programmers don’t know about it,
> let alone people coming from other platforms.
> 
> The simplest solution is just to use an atomic operation. Even if there
> isn’t a standard atomic API in C (as there is in C++), anyone reading the
> code is probably going to understand what OSAtomicIncrement32() does just
> from its name.

OSAtomic.h (except for OSAtomicQueue) is deprecated. Don’t use
OSAtomicIncrement32 in new code.

--Kyle Sluder

> 
> —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

Re: Substituting instance of cell subclass for instance of superclass

2016-11-11 Thread Kyle Sluder
On Fri, Nov 11, 2016, at 07:34 PM, James Walker wrote:
> I want to replace (for example) an instance of NSButtonCell with an 
> instance of my own subclass of NSButtonCell on the fly.  Now, I know 
> that's not a common thing to want to do; normally, you'd edit the nib to 
> use whatever cell class you want.  But I'd like to be able to do it to 
> an NSAlert, for which I don't have a nib.

You also have no idea if the NSAlert is already using a custom
NSButtonCell subclass—or whether it uses NSControl at all.

Your only option here is to reimplement the alert.

--Kyle Sluder

> 
> So, my thought was to first make an instance of my cell class that 
> copies all the state of the NSButtonCell instance, and then use 
> -[NSControl setCell:].  The documentation on setCell: does say:
> "Use this method with great care as it can irrevocably damage the 
> affected control; specifically, you should only use this method in 
> initializers for subclasses of NSControl."
> Anyone know what kind of damage we're talking about?
> 
> Anyway, as far as copying the cell state, I tried this:
> 
> - (id) initCopyingBaseCell: (NSButtonCell*) oldCell
> {
>   NSData* archive = [NSKeyedArchiver
>   archivedDataWithRootObject: oldCell];
>   NSKeyedUnarchiver* coder = [[[NSKeyedUnarchiver alloc]
>   initForReadingWithData: archive] autorelease];
>   
>   self = [super initWithCoder: coder];
>   if (self != nil)
>   {
>   
>   }
>   return self;
> }
> 
> However, the new cell has failed to copy much of the state of the old 
> one.  Things like title, font, target, action, bezelStyle...  I can 
> manually copy anything that I notice is missing, but I'm just wondering 
> why the keyed archiver approach here doesn't work.

___

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: AVFoundation and the main thread

2016-12-20 Thread Kyle Sluder
On Tue, Dec 20, 2016, at 08:59 AM, Andreas Falkenhahn wrote:
> So everybody knows that all things relating to UIKit have to be done
> on the main thread.
> 
> But what about AVFoundation functions which bear some resemblance to
> UIKit APIs? Do these have to be called on the main thread too or can
> they also be called from a worker thread?
> 
> For example, when adding an AVPlayerLayer to a view using addSubview()
> I have to do this on the main thread of course.
> 
> But what about changing the frame size of an AVPlayerLayer using
> setFrame()? AVPlayerLayer inherits from CALayer which is part of the
> QuartzCore framework, not UIKit. But of course CALayer methods like
> setFrame() bear a strong resemblance to their UIKit counterparts so
> I'm wondering whether it is really allowed to call setFrame() from
> a worker thread?

Since AVPlayerLayer is a layer, not a view, it cannot be added with
addSubview. It can either be added as a sublayer to your view’s layer,
or it can be wrapped in a view and *that view* added as a subview.

The distinction is important in many ways, but in this case the answer
is the same for both: don’t do this from a background thread.

(Caveat: it is technically possible to do CALayer-level work on a
background thread, but you have to manage many aspects of the
CATransaction yourself. It’s not easy to do correctly, and it gets
_very_ complex when manipulating a layer tree from multiple threads
simultaneously. And as soon as one of these layers belongs to a view,
you must only touch it from the main thread.)

--Kyle Sluder

> 
> Also, what about AVPlayerLayer methods like removeFromSuperlayer()?
> Is this main thread only as well?

___

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: Connecting NSTextStorage to a string

2016-12-28 Thread Kyle Sluder
> On Fri, Dec 23, 2016, at 09:16 PM, Daryle Walker wrote:
> The text controls on macOS use a NSTextStorage object to retain their
> text. That object is a extension of an attributed string. Let's say you
> use a NSString (or similar) in your document model. How should I get
> changes on one string to get mirrored on the other?

It depends on what you’re trying to do. The Cocoa text system is set up for two 
modes: editing rich text, and editing non-rich text.

In the rich-text case, the NSTextStorage object is intended to *be* the model 
object. It’s a long-lived object with its own optimized mutation scheme 
(-beginEditing/-endEditing and the mutators it inherits from 
NSMutableAttributedString), which is married to one particular NSTextView 
instance in the window. This of course means it’s not a great fit for 
frameworks like Core Data or Cocoa Bindings which expect model object 
properties to be simple value types. You can bridge this gap with various 
techniques, such as registering an object as the NSTextStorage’s delegate that 
posts your own notifications or triggers change notifications for a synthesized 
Core Data property.

The non-rich-text mode is more straightforward. In this mode, the NSTextStorage 
is permanently married to the window’s field editor, and as focus moves around 
the window its contents are batch-replaced with the underlying control’s 
stringValue as focus moves around the window. The controller is expected to 
listen to NSControl text editing notifications (possibly by acting as the 
control’s delegate) to know when to push values to the model. It is expected to 
use some other means, such as KVO, to push values from the model to the 
control. Cocoa Bindings intends to do this two-way marshaling on your behalf.

--Kyle Sluder

> 
> I think there are begin/end-editing flag methods on text controls, but
> how would I go the other way?
> 
> Sent from my 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://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Enabling UISearchBar cancel button?

2017-01-23 Thread Kyle Sluder
On Wed, Jan 11, 2017, at 10:17 PM, Rick Mann wrote:
> I'm creating and displaying a UISearchBar without using
> UISearchController (it gets in the way).
> 
> My UISearchBar is installed in the storyboard via IB. I animate it into
> position in my UI when the user taps a button. However, the Cancel button
> is disabled. I pre-load the search bar with the text of the last search,
> so the button should be enabled.
> 
> Before, when I was using UISearchController, it was enabled. Now it's
> not, until the user taps on it!
> 
> Any idea how to enable it? Thanks!

Sorry, Rick. There is no supported way to enable a UISearchBar’s Cancel
button while it isn’t active.

--Kyle Sluder

> 
> -- 
> 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: Sometimes all my menus are disabled

2017-02-12 Thread Kyle Sluder


On Sun, Feb 12, 2017, at 11:01 AM, Andreas Falkenhahn wrote:
> I'm experiencing a strange issue with my app. Sometimes, maybe in 1 out
> of 10
> programs starts, all menus of my app are grayed out, including standard
> menus
> like "Services", "Hide XXX", "Hide Others", "Show All", "Minimize",
> "Zoom",
> "Bring All To Front", really everything is grayed out right after my app
> has
> launched!
> 
> I don't really know what to do about this because I don't have any actual
> code
> in my app that relates to menus. The menu is created in Interface Builder
> and
> the individual items are connected to "AppDelegate menuClick:" in the 
> "Sent Actions" part of Xcode. That's pretty much all I have.

You’ve wired up every single menu item to a single action in your app
delegate? That’s certainly non-standard.

By default, menus automatically enable/disable their items based on
whether the target can perform the action. Perhaps your app delegate is
being deallocated, and thus the menu is walking the responder chain and
failing to find a responder that responds to -menuClick:?

--Kyle Sluder

> 
> What could be the problem here? How can I find out what's going awry
> here?
> 
> As I said, in 9 of 10 attempts everything works fine, but in maybe 1 of
> 10
> attempts all menus are grayed out right after my app has launched, making
> it
> impossible to use my app :-(
> 
> -- 
> Best regards,
>  Andreas Falkenhahn 
>  mailto:andr...@falkenhahn.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: Sometimes all my menus are disabled

2017-02-12 Thread Kyle Sluder

>> On Feb 12, 2017, at 12:36 PM, Andreas Falkenhahn  
>> wrote:
> 
> 
>> On 12.02.2017 at 21:29 Kyle Sluder wrote:
>> 
>> You’ve wired up every single menu item to a single action in your app
>> delegate? That’s certainly non-standard.
> 
> It's really old code. It's an Xcode project I originally created on a
> PowerPC Mac some 10 years ago, so I don't really remember how I used
> Interface Builder back then. All I see is that every single menu item
> has an entry under "Sent Actions" that links to "AppDelegate: menuClick".
> The menu events are then processed in the "menuClick" method of my
> app delegate.
> 
>> By default, menus automatically enable/disable their items based on
>> whether the target can perform the action. Perhaps your app delegate is
>> being deallocated, and thus the menu is walking the responder chain and
>> failing to find a responder that responds to -menuClick:?
> 
> But how can that possibly happen? I'm certainly not deallocating the
> app delegate myself...

There are plenty of ways to write refcounting bugs. But the refcounting bug is 
just a theory. All we know for sure is that something is disabling the menu 
items. I assume you have not turned off the default autoenablesItems property 
on the menu, so that leaves a few possibilities:

1. The target of your menu items is being replaced with an object that does not 
respond to -menuClick:.
2. The target of your menu items is being deallocated, and a new object is 
being allocated in its place that does not respond to -menuClick:.
3. The target of your menu items is being deallocated, and NSMenuItem’s weak 
target pointer is being nilled out (special case of #1).
4. The menu has a delegate, and it implements of one of the menu update 
callbacks to disable the menu items.
5. Some arbitrary object in your app is grabbing a reference to the menu items 
and disabling them.

--Kyle Sluder

> 
> -- 
> Best regards,
> Andreas Falkenhahnmailto:andr...@falkenhahn.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: -glyphWithName:

2014-08-22 Thread Kyle Sluder
On Fri, Aug 22, 2014, at 10:57 PM, Raglan T. Tiger wrote:
> 
> 
> NSFont *font = [NSFont systemFontOfSize:288];
> NSGlyph glyph = [font glyphWithName:glyphName];
> 
> 
> if glyphName is @“A” for example I get A
> 
> if the glyphName is @“&” I get nothing
> 
> if the glyphName is @“ampersand” I get &
> 
> I cannot find a list that tells me the names of these non-alphabet
> characters.
> 
> Where should I look for this list and will the names be the same
> regardless of font?

You should probably ask this question on the coretext-dev to get an
answer from an authoritative source. But I would wager that the valid
glyph names come from this table:
<https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6post.html>

Obviously 258 names can't cover modern fonts that can span the dozens of
thousands of Unicode codepoints. The documentation on the 'Zapf` table
implies that font designers can name their glyphs whatever the hell they
want:
<https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6Zapf.html>
(see section "The GlyphIdentifier Structure").

So the question I have is: what are you actually trying to do?

--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: -glyphWithName:

2014-08-23 Thread Kyle Sluder
On Sat, Aug 23, 2014, at 11:26 AM, Raglan T. Tiger wrote:
> 
> > So the question I have is: what are you actually trying to do?
> 
> Generally speaking, display the NSFontPanel with an accessory view
> containing a NSTextField, OK and Cancel buttons.
> 
> The user picks a font, types a phrase and clicks OK.
> 
> I now take the phrase and get the glyphs for each character in the
> phrase.

So the user types "abcdef" into your field and hits OK; you dismiss the
font panel and try to get the glyphs for "a", "b", "c", "d", "e", and
"f"?

> 
> Glyhs are gotten by name.

If my above understanding is correct, this is almost certainly the wrong
way to go about it. The Cocoa text system can go directly from Unicode
strings to glyphs; there's no need to convert the string to some sort of
intermediary form.

But I'm also concerned that you might not be aware of some of the more
complicated areas of Unicode-aware text rendering that make your desired
goal somewhat dubious.

There is not a 1-to-1 mapping of "characters" (what Unicode refers to as
"graphemes") and glyphs. See Apple's documentation about grapheme
clusters:
<https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Strings/Articles/stringsClusters.html>

"""In many writing systems, a single character may be composed of a base
letter plus an accent or other decoration. […] However, even if a string
is fully precomposed, there are still many combinations that must be
represented using a base character and combining marks. For most text
processing, substring ranges should be arranged so that their boundaries
do not separate a base character from its associated combining marks."""

So what to the user might look like a single character (ö, for example),
might actually be generated from two separate glyphs. The header
comments for -[NSLayoutManager
characterRangeForGlyphRange:actualGlyphRange:] reinforces this:

"""For example, if the text storage contains the character (o-umlaut)
and the glyph store contains the two atomic glyphs "o" and (umlaut), and
if the glyph range given encloses only the first or second glyph, then
actualGlyphRange will be set to enclose both glyphs."""

What glyphs get generated for any given character sequence (composed or
not) depend on the font and the glyph generator.

--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: -glyphWithName:

2014-08-23 Thread Kyle Sluder
On Aug 23, 2014, at 4:30 PM, "Raglan T. Tiger"  wrote:
> 
> 
> -rags
> 
> 
> 
>> On Aug 23, 2014, at 3:30 PM, Kyle Sluder  wrote:
>> 
>> So the user types "abcdef" into 
> 
> no, more like “Zoe’s First Birthday"

So what if Zöe’s name has an umlaut? As the documentation describes, that can 
result in two separate glyphs.

--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: -glyphWithName:

2014-08-23 Thread Kyle Sluder
On Aug 23, 2014, at 5:49 PM, Raglan T. Tiger  wrote:
> 
> 
>> On Aug 23, 2014, at 5:43 PM, Kyle Sluder  wrote:
>> 
>> So what if Zöe’s name has an umlaut? As the documentation describes, that 
>> can result in two separate glyphs.
> 
> apparently -glyphWithName: returns all the paths required to make the unicode 
> character
> 
> at this link you will see Zöe  interpreted from the NSBezierPaths returned by 
> -glyphWithName:  and put into bezier our model
> 
> http://crusaderrabbit.net/zoe.png

For *that specific font,* ö is one glyph. What about other fonts?

Also, have you tried with Hangul? What about overlays like COMBINING ENCLOSING 
CIRCLE?

> 
> this is what we want but again to the original question how to get glyphs 
> unicode so we don’t have to know the names

As I said before, I don’t think any reasonable way of achieving your goal 
actually requires this knowledge.

--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: Auto Layout with purple

2014-08-27 Thread Kyle Sluder
Ah, the *icons* are purple, not the constraints themselves.

Those definitely look like Xcode 4-era automatically-generated constraints. You 
might want to rebuild your constraints.

--Kyle Sluder

> On Aug 26, 2014, at 11:52 PM, "Gerriet M. Denkmann"  
> wrote:
> 
> 
>> On 27 Aug 2014, at 13:36, xcode-users-requ...@lists.apple.com wrote:
>> 
>>  
>>> On Wed, Aug 27, 2014, at 01:22 AM, Gerriet M. Denkmann wrote:
>>> I have two TextFields in a row. Their width is ≥ 11. Their y-centres are
>>> aligned.
>>> The first one has its leading edge fixed to some other thing. Trailing
>>> edge to second TextField = default.
>>> The second TextField has its trailing edge ≥ default to some other thing.
>>> 
>>> The problem: both TextFields also have a fixed width in purple, which
>>> seems to mean: cannot be deleted.
>>> But that is exactly what I am trying to do.
>>> 
>>> How can I convince Xcode (beta 6) that these widths are not needed?
>> 
>> I have never seen a purple constraint. Can you provide a screenshot?
> 
> Here is a picture with 3 purple constraints and 1 blue one in the Size 
> Inspector:
> 
> 
> 
> 
> Kind regards,
> 
> 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

Re: Prompting user (NSAlert) during document reading

2014-08-27 Thread Kyle Sluder
> On Aug 27, 2014, at 8:43 AM, edward taffel  wrote:
> 
> 
>> On Aug 27, 2014, at 11:30 AM, Matthew LeRoy  wrote:
>> This seems to work in initial testing — the alert displays — but I get a 
>> message in the console telling me that “NSAlert is being used from a 
>> background thread, which is not safe. This is probably going to crash 
>> sometimes. …” Presumably this is because I have overridden 
>> +canConcurrentlyReadDocumentsOfType: to return YES for my documents, 
>> resulting in document reading happening on a background thread. Changing 
>> +canConcurrentlyReadDocumentsOfType: to return NO makes the warning message 
>> go away.
> 
> i had this problem too: you can show the alert on the main thread via e.g. 
> performSelectorOnMainThread. (as was kindly pointed out to me by, if i 
> remember correctly,  graham cox).

I would not advise this. The main thread may itself be blocked due to waiting 
on your document via -performSychronousFileAccesdUsingBlock:.

Matthew, could you perhaps perform automatic conversion, mark the document as 
untitled, and display a notice about automatic conversion once the document has 
been asked to -showWindows? This is the strategy I’ve suggested implementing in 
our own apps in the future.

Something like:

- initWithContentsOfURL:… {
  self = [super initWithContentsOfURL:…];
  if (_autoConverted)
[self setDraft:YES];
  return self;
}

- showWindows {
  [super showWindows];
  if (_autoConverted) {
NSAlert *autoConversionAlert = …;
NSWindow *docWindow = self.windowControllers[0].window;
[alert beginSheetModalForWindow:window completionHandler:…];
}

--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: CALayer disappears on view resize...

2014-08-27 Thread Kyle Sluder
On Wed, Aug 27, 2014, at 08:17 PM, Peters, Brandon wrote:
> Devs,
> 
> I have a NSScrollview with and NSImageView as its document view. I have a
> sublayer for the scrollview that serves my selection rect. When I load an
> image I can pressed down and draw the selection rect, but as soon as I
> resize the window, the rect disappears but the image remains. As the
> window resizes, the code changes the location of the image in the window
> and should also be updating the location of the selection rect such that
> the selection rect “stays in place” with respect to the image as its
> location is updated due to the window resize. Here is what I have in
> drawRect():

Stop. -drawRect: is for drawing, not for resizing things.

Start by reviewing the View Programming Guide:
https://developer.apple.com/library/mac/documentation/cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40002978

--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: Best practice for creating a temporary file

2014-09-02 Thread Kyle Sluder
On Tue, Sep 2, 2014, at 11:47 AM, Jens Alfke wrote:
> 
> It looks as though there _is_ a per-volume temporary-items directory,
> because on my non-boot partition I see a top-level invisible directory
> called ".TemporaryItems" with a subfolder for each user-ID. But how do I
> find it programmatically?

.TemporaryItems doesn't get cleaned up automatically AFAIK, so I don't
think you'll gain anything by trying to use it.

If you want to hide the folder, I'd try setting its hidden flag via
chflags(2).

--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: Best practice for creating a temporary file

2014-09-02 Thread Kyle Sluder
On Tue, Sep 2, 2014, at 06:10 PM, Jens Alfke wrote:
> 
> > On Sep 2, 2014, at 4:05 PM, Quincey Morris 
> >  wrote:
> > 
> > I get a URL to a new folder in the private (secure) temporary directory, 
> > and *not* in the parent of ‘importURL’. I don’t know why you’re seeing 
> > something different.
> 
> This is on iOS. (On Mac OS I do see the file appear in the temporary
> directory of the appropriate volume.)
> 
> I suppose I could conditionalize my code and use NSTemporaryDirectory()
> on iOS, since there won't be multiple volumes there.

Eh… I'd consider using ItemReplacementDirectory anyway. They've already
changed the way containers are organized at least once (splitting the
Documents directory from the app bundle), so I'd rather insulate myself
from any potential changes in the relationship between the Documents
directory and Library.

Who knows, maybe next week we'll get support for removable SD cards.
(*laugh*)

--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: Resizing issue with NSSplitView

2014-09-02 Thread Kyle Sluder
On Tue, Sep 2, 2014, at 11:39 PM, Peter Hudson wrote:
> Hi All
> 
> I have recently migrated a project to xCode 5.1.1 and OSX  10.9.4
> 
> In one of the windows of the app I have an NSSplitView.  
> Previously, I could adjust the relative size of the splits in Interface
> Builder - and when I ran the app, the splits would appear as I set them.
> 
> Mysteriously, Interface builder has resized the relative sizes of one of
> my splits - and I can no longer adjust them in Interface Builder.
> When I have selected the correct object on the screen, I get the  up /
> down  arrow that implies I can move the divider  - but when I try to drag
> the divider to a new position, the cursor moves but the  divider stays
> put.
> 
> Other split views, in the same window, can be resized without any
> trouble.
> 
> Any suggestions gratefully received !

If you have enabled Auto Layout in the nib, you need to use constraints
to specify the widths of your splits. The exception is if the delegate
of the split view implements one of the verboten methods that kicks the
split view back into legacy mode. You can read more in the AppKit
release notes:
https://developer.apple.com/library/mac/releasenotes/AppKit/RN-AppKitOlderNotes/

--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: Responder Chain Confusion

2014-09-07 Thread Kyle Sluder
On Sep 7, 2014, at 9:24 AM, dangerwillrobinsondan...@gmail.com wrote:
> 
> Hi all
> 
> I just spent a bit of time poking around the responder chain and nil targeted 
> actions. 
> I built a view controller and a view hierarchy with controls that should be 
> configurable. 
> When instantiating the view controller the interface allows configuring the 
> action SEL of the controls. Reuse is the goal of course. 
> I know 10.10 changes things greatly for view controllers. But on 10.9 that's 
> not there. 
> 
> Anyway, I need to insert the view controller into the responder chain between 
> its top level view and that view's superview. 
> That wasn't too bad. Implement the missing reference to the vc in a view 
> subclass and give the vc a callback when the view is in place. 
> 
> But what I found while tinkering is that for non-document based apps from a 
> vanilla project template there was no next responder for the window or the 
> NSApplication instance. 
> I had a method in the app delegate that I was trying to reach via nil 
> targeted action. It couldn't get there. 
> So I set the window nextResponder to the app and the app to the app delegate. 
> I also made the app delegate an NSResponder subclass. 
> 
> It feels like overkill. 
> Am I missing something simple?

IIRC, the window is not supposed to have a nextResponder. Conceptually, the 
next responder of a window is its delegate, and the next responder of an 
application is *its* delegate, but there is no requirement that these objects 
are instances of subclasses of NSResponder. Therefore the responder chain 
mechanism manually jumps from the window to its delegate, then to the 
application, and finally to the app’s delegate. (It also inserts window 
controllers as well as the shared NSDocumentController instance if one has been 
created.)

If the message never reached your app delegate, I suspect you failed to patch 
the view controller’s nextResponder in correctly.

--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: How to copy Color Panel behaviour?

2014-09-09 Thread Kyle Sluder
On Tue, Sep 9, 2014, at 06:42 PM, Graham Cox wrote:
> 
> On 10 Sep 2014, at 7:13 am, Luc Van Bogaert 
> wrote:
> 
> > This opens the panel without making it key, which is OK, but it still makes 
> > the panel key when I click any of the responder objects in the panel, such 
> > as a collectionview...
> 
> 'becomesKeyOnlyIfNeeded' does what it says, but how does it define
> 'needed'. It does that by allowing the panel to become key if any of its
> views or controls accept first responder. So to prevent that, these also
> need to refuse FR by overriding -acceptsFirstResponder to return NO.

There's also the corresponding method, -needsPanelToBecomeKey, which is
used by things like text fields to ensure they actually work when
clicked on.

--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: NSUserDefaults not sticking

2014-09-10 Thread Kyle Sluder
On Wed, Sep 10, 2014, at 11:15 AM, Todd Heberlein wrote:
> > in the past few years when it's happened it's been an early symptom of 
> > filesystem corruption. Sometimes there have been a bunch of leftover 
> > temporary lock(?) files in the Preferences directory.
> > 
> > If you're getting reports of this from users of your app, it might be worth 
> > asking them to run Disk First Aid.
> 
> I’ve run into this problem during software development (can’t recall for
> shipping apps). Since it is just during development, I trash the
> preferences file for the app and the problem usually goes away.

Part of the problem might be that you should avoid touching or viewing
the plist files in ~/Library/Preferences. cfprefsd has gotten more and
more aggressive about in-memory caching over the past few years, and the
preferences files might be out of date.

If you want to nuke an app's preferences, use `defaults delete
your.bundle.identifier`. However, in the past that has sometimes not
found the correct container. In that case you might still need to delete
the appropriate plist, but you may need to log out and back in both
before and after doing so to ensure that the changes are picked up by
cfprefsd.

--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: NSUserDefaults not sticking

2014-09-10 Thread Kyle Sluder
On Wed, Sep 10, 2014, at 07:32 PM, Rick C. wrote:
> And about not relying on the .plist if we don’t rely upon it how do we
> write our prefs?  I understand I should not manipulate it directly, but I
> am calling everything via NSUserDefaults…

Continue using NSUserDefaults for all interaction with the preferences
system. That's what the `defaults` command uses too.

--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: NSUserDefaults not sticking

2014-09-10 Thread Kyle Sluder
On Sep 10, 2014, at 7:04 PM, Scott Ribe  wrote:
> 
> The real point: plenty of sites on the web state that the .plist no longer 
> represents the current state, but that the defaults command will read the 
> current state so you can use it for debugging. They are wrong. Apparently 
> there's something about the caching such that defaults, and I expect any 
> other process outside the one making the changes, DOES NOT return the latest 
> values you synched. It is absolutely the case that your app can use 
> NSUserDefaults to update defaults, can synch them, can then read back the new 
> values and confirm that NSUserDefaults is returning the latest values you 
> gave it, and the defaults command line will at that point still be returning 
> stale values from before your update.

It’s my understanding that this shouldn’t happen. If you can reproduce it, you 
should file a Radar.

Also, you should almost never need to call -synchronize yourself. The framework 
does it at appropriate times.

--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: Reset dispatch_once_t if the initialization failed?

2014-09-13 Thread Kyle Sluder
On Sep 13, 2014, at 9:14 PM, Daryle Walker  wrote:
> 
> I’ve seen bog-standard code to initialize a shared instance like:
> 
>> + (SomeSingleton *) sharedInstance
>> {
>>static SomeSingleton *sharedInstance = nil;
>>static dispatch_once_t onceToken;
>>static dispatch_once_t onceToken;
>>dispatch_once(&onceToken, ^{
>>sharedInstance = [[SomeSingleton alloc] init];
>>});
>>return sharedInstance;
>> }
> 
> What happens if that initialization fails? Shouldn’t there be a test for NIL 
> and a reset of the “onceToken” somewhere?… (Or is the chance of failure too 
> unlikely?)

Plenty of ObjC code assumes that initialization can’t fail. Sometimes, but not 
always, the fallibility of the initializer is documented. Thankfully Swift puts 
pressure on you to make that assumption explicit.

Besides all that, you can’t reset a dispatch_once. The contract requires that 
you pass it a pointer to a dispatch_once_t that you guarantee has been 
initialized zero for the entire life of the program. Otherwise you’ve just 
moved the race condition from initializing your singleton to initializing the 
dispatch_once.

Technically this means you can’t have a dispatch_once instance variable, as the 
memory at that address may have been nonzero before the object was allocated. 
In practice, I don’t think it’s an issue (nobody should be able to send 
messages to your object until initialization finishes anyway), but I invite 
someone from the runtime team (*cough* Greg Parker *cough*) to explain why I’m 
wrong. :)

--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: Want NSTableView NSOutlineView to load lazy like iOS?

2014-09-15 Thread Kyle Sluder
On Mon, Sep 15, 2014, at 01:52 PM, Jerry Krinock wrote:
> 
> It would be nice!  Is that correct?  If so, how might my outline view be
> abnormal?  My data source is backed by Core Data, but I don’t think that
> matters to this issue.  Below is a call stack of how my data source gets
> a typical one of those 13,000 messages.

Are you using a view-based outline view?

Does your outline view have constant row heights, or are you
implementing -tableView:heightOfRow:?

--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: Want NSTableView NSOutlineView to load lazy like iOS?

2014-09-15 Thread Kyle Sluder

On Sep 15, 2014, at 12:31 PM, Jerry Krinock  wrote:
> 
> 
>> On 2014 Sep 15, at 11:56, Kyle Sluder  wrote:
>> 
>> Are you using a view-based outline view?
> 
> No.  It is cell-based.  App currently runs in Mac OS X 10.6.

Can’t very well keep “only the onscreen views” if the table isn’t view-based…

--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: NSOutlineView not lazy when expanding items :(

2014-09-16 Thread Kyle Sluder
On Tue, Sep 16, 2014, at 05:04 PM, Jerry Krinock wrote:
> 
> > On 2014 Sep 16, at 10:29, Jens Alfke  wrote:
> > 
> > Maybe it's the animation that ends up dereferencing all the rows? I forget 
> > whether there's a way to disable the animations on an NSOutlineView …
> 
> I can’t find any such control, Jens.

I'd try wrapping things in an NSAnimationContext with
allowsImplicitAnimation=NO. Though I'm not sure where you would have the
opportunity to wrap the built-in expand behavior.

--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: Heavy flickering on Retina Macs with Yosemite & NSVisualEffectView & overlay windows

2014-09-17 Thread Kyle Sluder
Your video won’t play on my phone. But honestly, if you’re not doing anything 
particularly advanced (as in the OpenGL or CGDirectDisplay level), then the 
symptoms you describe should not appear and you ought to file a bug.

You might consider simply attaching your current project (along with 
screenshots and/or a version of your movie you know to work) before bothering 
to make a demo app. Be sure to include your system configuration—this is one 
case where it really matters, and you don’t want to burn time waiting for a bug 
screener’s “please attach a system configuration” reply.

--Kyle Sluder

> On Sep 17, 2014, at 5:19 AM, Markus Spoettl  wrote:
> 
> Hello,
> 
>> On 16/09/14 16:28, Markus Spoettl wrote:
>>   using Yosemite DP8 (first tested and observed with DP7), we get very heavy
>> flickering when animating a popup overlay window over a window whose content
>> consists of  views sitting on NSVisualEffectViews
>> (NSVisualEffectBlendingModeWithinWindow) and with a transparent window title 
>> bar
>> and toolbar.
>> 
>> What happens is that the area behind the popup window that is being animated
>> into view (animating window frame and alpha) briefly blacks out with a opaque
>> completely black fill. Sometimes it resembles the shape of the popup window,
>> sometimes it doesn't, sometimes areas not covered by the popup window 
>> flicker.
> 
> I made a short demo video illustrating the problem:
> 
> http://www.shiftoption.com/images/flickering.mov
> 
> Anyone any idea what might cause this? Maybe a overwhelmed graphics unit? A 
> driver bug? It also sometimes happens when the window becomes active or 
> inactive, for example when tabbing through apps. Then larger areas of the 
> window briefly get blacked out. It only happens on the Retina MacBook (Mid 
> 2012), I don't have any other retina display hardware here to try other 
> machines.
> 
> Any pointers would be highly appreciated!
> 
> Thanks
> Markus
> -- 
> __
> Markus Spoettl
> ___

___

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: Doc links broken

2014-09-17 Thread Kyle Sluder
On Wed, Sep 17, 2014, at 06:46 PM, Rick Mann wrote:
> It seems that Apple broke all the existing documentation links. Dunno if
> that was deliberate or not. Bad form, either way.
> 
> Filing a bug…

Happens every single OS release.

--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: Document Packages

2014-09-17 Thread Kyle Sluder
On Sep 17, 2014, at 7:18 PM, Charles Jenkins  wrote:
> 
> I know this is a stupid question that’s probably been asked many times 
> before, but I don’t find a way to search the cocoa-dev list to look for it.  
> 
> For several evenings I’ve been struggling to learn how to write my document’s 
> data out as an NSFileWrapper directory containing a group of RTF files.
> 
> Everything finally worked today (yay!), but the resulting output appeared as 
> an ordinary directory of files (boo!).  
> 
> The Bundle Programming Guide offers this tantalizing bit of information:
> 
>> To register a document as a package, you must modify the document type 
>> information in your application’s information property list (Info.plist) 
>> file. The CFBundleDocumentTypes key stores information about the document 
>> types your application supports. For each document package type, include the 
>> LSTypeIsPackage key with an appropriate value. The presence of this key 
>> tells the Finder and Launch Services to treat directories with the given 
>> file extension as a package. For more information about Info.plist keys, see 
>> Information Property List Key Reference.
> 
> The Information Property List Key Reference does mention the LSTypeIsPackage 
> key, but it’s not clear where that key should appear in the Info.plist’s 
> structure.
> 
> I used DuckDuckGo to search for LSTypeIsPackage and found that you set it by 
> checking the “Document is distributed as a bundle” box in the document type’s 
> section of the target’s Info property page. So I did that, but the files I 
> save still appear as directories.
> 
> What configuration am I missing to get a document package which appears as a 
> single file?   

The documentation is woefully out of date, or at least fails to adequately 
cover all topics.

Your document type’s UTI must conform to com.apple.package. That’s a “physical” 
UTI, so you’ll probably want to conform too public.composite-content as well.

Not that UTIs are semantically useful to any greater extent than file 
extensions, but there you have it.

--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: Heavy flickering on Retina Macs with Yosemite & NSVisualEffectView & overlay windows

2014-09-18 Thread Kyle Sluder
When an OS gets towards release, I notice a sharp increase in the likelihood of 
my bug report getting intercepted and returned by bug screeners. This is a 
function of a management, not engineering, and I gather their job is to swat 
bugs away from the engineers so they can focus on getting the release out the 
door.

Unfortunately I fear the screeners are in a similar position as customer 
“service” agents—that is, under constant pressure to resolve bugs quickly, and 
either explicitly or implicitly encouraged to close bugs for the sake of 
meeting some kind of performance metric.

Part of the role of Evangelists is to sidestep this process: they are 
technically skilled and politically empowered to put important bugs under the 
engineering managers’ noses. Likewise for Relationship Managers, if you have 
one.

This sounds like a big enough issue that you might want to flag Jake Behrens, 
the UI and App Frameworks Evangelist:  If this doesn’t fall 
under his purview, he’ll at least be able to forward you to the right person. 

--Kyle Sluder

> On Sep 18, 2014, at 10:29 AM, Markus Spoettl  wrote:
> 
>> On 17/09/14 17:32, Kyle Sluder wrote:
>> Your video won’t play on my phone. But honestly, if you’re not doing anything
>> particularly advanced (as in the OpenGL or CGDirectDisplay level), then the
>> symptoms you describe should not appear and you ought to file a bug.
>> 
>> You might consider simply attaching your current project (along with
>> screenshots and/or a version of your movie you know to work) before bothering
>> to make a demo app. Be sure to include your system configuration—this is one
>> case where it really matters, and you don’t want to burn time waiting for a
>> bug screener’s “please attach a system configuration” reply.
> 
> I filed a bug, lets hope they can recreate using the app, video, test data and
> system configuration I supplied.
> 
> The last two times I did this in the last couple of weeks, I got a response 
> that
> indicated they didn't even read the first line of the steps (which says "unzip
> the attached app and start it") by requesting an app to reproduce the issue. I
> find the whole experience extremely unrewarding, rude and very deterring.
> 
> Regards
> Markus
> -- 
> __
> Markus Spoettl

___

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: Heavy flickering on Retina Macs with Yosemite & NSVisualEffectView & overlay windows

2014-09-19 Thread Kyle Sluder
On Sep 19, 2014, at 9:39 AM, Jens Alfke  wrote:
> 
> FWIW, I've seen standard UI controls (esp. progress bars) in Apple apps go 
> into this kind of super-flickery state in Yosemite on my Retina MBP. I've 
> been assuming it's a WindowServer or graphics driver bug.
> 
> (No, I didn't file a Radar. It was sufficiently common and glaring that I 
> assumed it was something everyone saw & knew about.)

Never assume. Apple engineers have told me stories about glaring bugs that I 
assumed were obvious but had a grand total of one report ever filed against 
them, years after the bug had been introduced.

That said, I don’t file every bug I encounter with the OS (particularly things 
that have seen obvious changes over time, like the WindowServer in Yosemite), 
but I do file a lot of framework bugs.

--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: return string that is the difference between two other strings

2014-09-20 Thread Kyle Sluder
On Sep 20, 2014, at 11:54 AM, 2551 <2551p...@gmail.com> wrote:
> 
> I'll pass if people start asking me what I mean by a 'word', though I'm well 
> aware that that is a genuine question at certain levels and across different 
> localisations. Take it that for the purpose of the inquiry I mean any 
> combination of letters in the standard English alphabet that is space 
> delimited. Punctuation and diacriticals can be ignored for my current 
> purposes.

Well luckily for you, there is a general-purpose word splitter in Core 
Foundation that works for many non-Latin languages as well: CFStringTokenizer.

--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: return string that is the difference between two other strings

2014-09-20 Thread Kyle Sluder
On Sep 20, 2014, at 9:08 PM, 2551 <2551p...@gmail.com> wrote:
> 
> As I've been saying all along, this is such a common operation, I'd have 
> thought there must be a common cocoa method or API for doing it. So the 
> question is, can anyone tell me what that is?

No, it is nowhere near a common operation to perform on strings. It’s common 
for *programmers* to perform on their source code.

--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: Custom layout and constraints

2014-09-21 Thread Kyle Sluder
On Sep 21, 2014, at 7:10 AM, Allan Odgaard  wrote:
> 
> 
> That is, if the view has hugging and/or intrinsic content size then the size 
> from the derived constraints will be used, otherwise `NSZeroSize`. Likewise 
> the origin will be `NSZeroPoint` unless constrains are added to affect the 
> position.
> 
> So how can I ensure the position I set for a subview’s frame in my `layout` 
> override is not (implicitly) changed later?

You need to turn on translatesAutoresizingMaskIntoConstraints for the subviews 
you position manually. That way Auto Layout knows how to position them.

I really view this as a bug. If a view has no constraints applied to it, the 
view should not be touched by Auto Layout at all. That was the implicit promise 
made to us by saying we could still perform manual layout in -layout. Breaking 
that promise has led to bugs where existing code that used -setFrame: would 
fail because it was handed a view that had translatesAutoresizingMask turned 
off at some point. It also means that any -setFrame:-based code triggers a 
recursive pass through the entire view hierarchy, which is exactly what you 
don’t want in any animation code that’s using -setFrame:.

You’re the third person on this mailing list in the past month to be bitten by 
this surprising behavior. I would suggest you file a Radar.

--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: Changes to Core Data in iOS 8

2014-09-23 Thread Kyle Sluder
On Sep 23, 2014, at 4:24 PM, Rick Mann  wrote:
> 
> In iOS 7, my app works fine. In iOS 8, deleting an entity eventually works, 
> but whereas in iOS 7 my UI would update and show the change, the change 
> doesn't seem to have "taken hold" by this time in iOS 8.
> 
> Basically, when the user deletes an entity, I delete it from the MOC (main 
> thread), then mark my custom view as needing display. Its -drawRect: is 
> called, but when it asks the owning entity for the set of related entities it 
> draws, that set comes back with the deleted items still present (although 
> they return true for -isDeleted).
> 
> When a later event causes the custom view to refresh again, the entity 
> representations finally go away.
> 
> Has something changed in delete propagation between iOS 7 and 8?

Have you checked the value of your MOC’s propagatesDeletesAtEndOfEvent property 
on iOS 7 and iOS 8?

But more fundamentally, why aren’t you listening for 
NSManagedObjectContextObjectsDidChangeNotification to trigger your UI updates?

--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: What is NSAnimationSlowMotionOnShift?

2014-09-25 Thread Kyle Sluder
On Sep 25, 2014, at 5:15 AM, Bill Cheeseman  wrote:
> 
> But I can't find NSAnimationSlowMotionOnShift anywhere. Is this remark in the 
> release notes an inside joke? Google turns up no references to 
> NSAnimationSlowMotionOnShift other than these Release Notes, and searching 
> the Yosemite headers turns up nothing.

From the release notes:

“Most animations on the system can be slowed down by setting the default 
NSAnimationSlowMotionOnShift to YES”

Notice it says “the default”. This is a noun, used in the same sense as the 
defaults(1) command. Therefore you set it either with `defaults write` or by 
passing it as an argument on the command line.

Slow animations are a debugging aid; testing for the shift key often results in 
legitimate key combinations taking forever to animate.

--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: What is NSAnimationSlowMotionOnShift?

2014-09-25 Thread Kyle Sluder
On Sep 25, 2014, at 8:31 AM, Bill Cheeseman  wrote:
> 
> 
>> On Sep 25, 2014, at 10:33 AM, Kyle Sluder  wrote:
>> 
>> Notice it says “the default”. This is a noun, used in the same sense as the 
>> defaults(1) command. Therefore you set it either with `defaults write` or by 
>> passing it as an argument on the command line.
> 
> Duh. I'm feeling particularly stupid today. Thanks for straightening me out.
> 
>> Slow animations are a debugging aid; testing for the shift key often results 
>> in legitimate key combinations taking forever to animate.
> 
> I'm careful to avoid side effects. As far as I can tell.

That’s the rub. Modifier keys compose.

What if the only way to hit the key combo for your feature’s menu item is with 
the aid of the Shift key?

I find slow animations quite useful to suss out how the framework animates, or 
when I have a crapton of windows open. But in general, I think 
Shift-to-slowly-animate is a misfeature.

--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: What is NSAnimationSlowMotionOnShift?

2014-09-25 Thread Kyle Sluder
On Thu, Sep 25, 2014, at 11:52 AM, Bill Cheeseman wrote:
> Apple's Minimize button slow-motion effect works even if you hold down
> other modifier keys along with the Shift key. I just tried it with
> Shift-Cmd-Y (it requires some contortion if you only have two hands).
> Sure enough, you're right, it causes the window to minimize to the Dock
> in slow motion and only then does the new sticky note appear. But how
> often is anybody going to do that?

To a rough approximation, everyone uses every feature all the time. And
in particular, people get really defensive about keyboard shortcuts.

And it's a rather poor design to explicitly implement a feature like a
shortcut key and then punish its users by not thinking about its
interactions with other parts of the system.

--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: Showing Application Credits

2014-09-26 Thread Kyle Sluder
On Fri, Sep 26, 2014, at 03:59 PM, SevenBits wrote:
> So, what can I realistically do? Because of the formatting, I need to use
> RTF format to display the documents.
> 
> Any suggestions from the Cocoa crusaders? ;)

Just use a panel with a standard NSTextView. You can create an
NSAttributedString from RTF rather easily.

--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: Dragging to Rearrange Outline View

2014-09-27 Thread Kyle Sluder
On Sep 27, 2014, at 6:54 AM, Charles Jenkins  wrote:
> 
> I have a question that may be truly obvious and stupid, but here goes anyway. 
>  
> 
> In my application, I’ll display an outline view, and I want the user to be 
> able to drag nodes around to rearrange the tree however he likes.
> 
> The table objects’ drag-related functions I’ve found seem to rely on the 
> pasteboard, as if we were dragging information in from the Finder or another 
> application.
> 
> Are those the functions I should be looking at for rearranging the outline, 
> or am I barking up the wrong tree?  

The pasteboard is indeed the way to go. After all, for any arbitrary outline 
view, the user could drag from your that outline view to another app.

If in your case it only makes sense to drop within the outline view, you can 
use a custom pasteboard type that contains no data.

(This is actually how Safari tabs work.)

--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: -[NSTabView mouseDown:] blows stack in Yosemite SDK

2014-09-28 Thread Kyle Sluder
On Sep 28, 2014, at 9:48 PM, Jerry Krinock  wrote:
> 
> …
> #1309580x7fff96f9ad70 in forwardMethod ()
> #1309590x7fff96f9ad70 in forwardMethod ()
> #1309600x7fff974074ea in -[NSTabView mouseDown:] ()


Do you have a cycle in your nextResponder chain? Remember than NSViewController 
now inserts itself into the responder chain on 10.10.

--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: Validate NSDocument on Quit

2014-10-05 Thread Kyle Sluder
On Oct 5, 2014, at 7:36 AM, Keary Suska  wrote:
> 
> I am trying to prevent a quit in a document-based app when data in a document 
> is invalid. AFAICT when auto save is turned on none of the normal document 
> closing methods are called, and when the app delegate is called, 
> NSDocumentController shows no existing documents. It might also have to do 
> with the "Ask to keep changes" preference. Has anyone figured out how to trap 
> closing to prevent saving possibly invalid data?

This sounds at odds with the fundamental concept of auto-saving, which is that 
your data is more or less always up to date on disk.

Why can’t you write the “invalid” data? It’s the user’s work-in-progress.

--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: Responsive scrolling: prepareContentInRect: not called

2014-10-08 Thread Kyle Sluder
On Oct 8, 2014, at 2:53 AM, Antonio Nunes  wrote:
> 
> Turns out the problem is a different, and of course, almost embarrassingly 
> silly one. I misspelled the method name: prepareContentInrect rather than 
> prepareContentInRect. Now that I’ve caught that and corrected it, the method 
> is called. Thanks for you effort anyway.

Hmm, this sounds like it would make a great compiler warning. File a Radar, 
maybe?

--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: PushKit dyld errors on 64bit

2014-10-09 Thread Kyle Sluder
On Thu, Oct 9, 2014, at 03:25 PM, Iain Holmes wrote:
> Hi,
> 
> I have an iOS8 app that uses the native iOS WebRTC libraries and
> therefore must be armv7 or armv7s (as they haven’t got an arm64 build).
> I’m using PushKit for VoIP notifications and while this works great on 32
> bit devices, when we move to test it out on a 64bit device it crashes
> with this error from dyld
> 
> Dyld Error Message:
>  Library not loaded: @rpath/PushKit.framework/PushKit
>  Referenced from:
>  
> /private/var/mobile/Containers/Bundle/Application/7E61943D-4DA2-47FD-A668-260668DD2E19/Dupl.app/Dupl
>  Reason: no suitable image found.  Did find:
>  /System/Library/Frameworks/PushKit.framework/PushKit: mach-o, but wrong
>  architecture
>  Dyld Version: 353.5
> 
> Does anyone know what might be wrong with it and possible fixes?

The error seems pretty plain to me. The dylib doesn't contain a slice
for your target hardware architecture. Are you building for only  the
active architecture (the ONLY_ACTIVE_ARCH build setting)? This is the
default for debug builds.

--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: PushKit dyld errors on 64bit

2014-10-09 Thread Kyle Sluder
On Thu, Oct 9, 2014, at 03:42 PM, Kyle Sluder wrote:
> The error seems pretty plain to me. The dylib doesn't contain a slice
> for your target hardware architecture. Are you building for only  the
> active architecture (the ONLY_ACTIVE_ARCH build setting)? This is the
> default for debug builds.

Bah, PushKit is part of the system frameworks. I wrongly assumed it was
a third-party thing.

If a system framework was only delivered as a 32-bit binary, that seems
like a problem.

--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: Concurrent tasks are getting hung up

2014-10-10 Thread Kyle Sluder
> On Oct 10, 2014, at 6:42 AM, Steve Mills  wrote:
> 
> I've only created one NSOperationQueue and added many NSInvocationOperation 
> to it.

NSOperationQueue works by dispatching your blocks to the global async GCD 
queue. If you send a thousand blocks to be async processed at once, GCD will 
keep spinning up threads to try to service them until it exhausts the thread 
limit and your process deadlocks.

It sucks, but you have to be judicious in the number of blocks you submit to 
the global queue. Set a max operation count on your NSOperationQueue.

> On Oct 10, 2014, at 6:55 AM, Steve Mills  wrote:
> 
> I'll hold off on reporting a bug until I can figure out if it's my fault or 
> not. I asked before how I can find out which things are not thread-safe, but 
> didn't get a reply on that. I don't see anything about thread safety in any 
> of the headers for these:

https://developer.apple.com/library/mac/qa/qa1238/_index.html

--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: Kerning Pairs

2014-10-11 Thread Kyle Sluder
On Oct 11, 2014, at 8:20 AM, Raglan T. Tiger  wrote:
> 
> The Windows CDC class has a function:
> 
> DWORD GetKerningPairs( DWORD nNumPairs, LPKERNINGPAIR lpkrnpair );
> 
> 
> What would be the equivalent in a Cocoa class?  I cannot find any methods 
> that have kerning in their name.

Kerning can be much more complicated than can be represented by a simple 
pairing table. See Apple’s documentation for the Kerx table, specifically 
Format 1, which encodes a state machine: 
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kerx.html

So the question, as usual, becomes: what are you actually trying to do? I bet 
you could get it done via the NSTypesetter API.

--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: Kerning Pairs

2014-10-12 Thread Kyle Sluder
On Sun, Oct 12, 2014, at 08:36 AM, Raglan T. Tiger wrote:
> My task is to make the Mac view and controller to capture the selected
> font. The rendering of the font is all good. So now I just need kerning
> data that I can put into a KERNINGPAIR structure and my task is complete. 

That's a means, not an end. The purpose of your program isn't to extract
kerning information. The question now thrice posed to you: what does
your program *do* that involves kerning information?

> 
> I have read the reference from Kyle that describes the 'kerx' extended
> kerning table which is supported on OS X 10.7 and iOS 7 onward. Our
> deployment is 10.5 and greater.
> 
> I suspect that the 'kern' table will give what I need. 
> 
> How does one get a pointer to a 'kern' table for a specified font?


Not all fonts have a 'kern' table, so this is not the way forward.

It sounds like you're trying rrrealllly hard to avoid admitting to
yourself that your model code needs to be rewritten.

--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: Code signing problem using shared framework in Yosemite

2014-10-12 Thread Kyle Sluder
On Oct 12, 2014, at 9:24 AM, Bill Cheeseman  wrote:
> 
> I'm updating my UI Browser application and my related PFAssistive framework 
> <http://pfiddlesoft.com> for Yosemite, and I've run into a specific problem 
> related to code signing. I'm wondering if anyone can shed light on this.
> 
> Specifically, UI Browser calls my framework's Objective-C wrapper methods for 
> accessibility functions like AXIsProcessTrustedWithOptions(). These calls 
> have begun to fail in recent GM releases of Yosemite. Console.app reports 
> things like this:
> 
> 2014-10-12 11:04:01.213 AM tccd[223]: Unable to verify code signing identity 
> of com.pfiddlesoft.uibrowser:  the code on disk does not match what is running

Curious: have you tried scouring your machine for all copies of the app and 
deleting them? Since it’s generally not possible to associate a running 
executable with a file on disk, the OS might be trying to look up your app via 
bundle identifier and finding an old, stale copy whose code really doesn’t 
match what’s running.

> 
> Is code signing now making it impossible to use shared frameworks at all, 
> going forward? That would be a huge change to spring on the developer 
> community without advance warning.

What do you mean “shared frameworks”? As in, frameworks that live outside of 
your app wrapper? Because frameworks in and of themselves are certainly still 
usable.

--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: Problem getting import UTI recognised

2014-10-15 Thread Kyle Sluder
On Oct 15, 2014, at 8:14 PM, Graham Cox  wrote:
> 
> Hi all,
> 
> My app declares 3 UTIs for import, which are basically the same as the 
> document types it supports.
> 
> It imports two of the types fine, but the other (which is actually the 
> default native format) it refuses to accept - I get a message to say that my 
> app cannot open documents of such-and-such format, and my document's 
> -readFromData:ofType:... isn't even called. It writes files of this type OK, 
> but in the Finder they have the generic icon and the 'Kind' is just 
> "Document" instead of the correct description.
> 
> My native UTI is declared in the usual way, in reverse dot.com form, and this 
> conforms to public.content, unpackaged. The export UTIs are the same.
> 
> I must be missing something pretty obvious, but I'm at a loss.

Is there another app on your system declaring that file extension for its own 
UTI? You can dump the database with lsregister(1).

--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: Problem getting import UTI recognised

2014-10-16 Thread Kyle Sluder


On Oct 16, 2014, at 4:07 AM, Graham Cox  wrote:
> 
> 
>  "http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
> 
> 

I’m assuming this is a snippet extracted from your actual Info.plist.

>
>UTTypeConformsTo
>
>public.content
>

You’re not conforming to any physical types. You probably want to conform to 
public.data as well as public.content.

Also, can you provide your CFBundleDocumentTypes array? Most of those keys have 
been supplanted by the UTI declaration, but you still need that to connect the 
UTI to an NSDocument subclass.

--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: Set UICollectionView UIScrollViewDelegate delegate

2014-10-18 Thread Kyle Sluder
On Oct 18, 2014, at 2:22 PM, Mazzaroth M.  wrote:
> 
> Hi, I have a parent view controller that has two UICollectionViewController
> subclasses as children in its view controller hierarchy. I'd like to set
> the parentViewController as the Subclass1CollectionViewController and
> Subclass2CollectionViewControllers' .colllectionView UIScrollView delegate.
> However when I set the delegate, the compiler assumes I'm trying to assign
> it as the UICollectionViewDelegate. UICollectionView is a subclass of
> UIScrollView.. how do refer to its scrollview delegate pointer?

There is only one delegate property. UICollectionView redeclares the property 
it inherits from UIScrollView and retypes it as UICollectionViewDelegate, which 
extends UIScrollViewDelegate. Any object you assign as the collection view’s 
delegate *must* conform to UICollectionViewDelegate.

The good news is that every member of UICollectionViewDelegate is optional, so 
this is a trivial change.

--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

  1   2   3   4   5   6   7   8   9   10   >