Re: Master - Detail: How to get back?

2015-04-15 Thread Roland King

> 
> 5. Run 
> 
> iPhone- tapping on "Do & Back" prints:
> 2015-04-16 12:16:52.799 Dummi[28069:20737983] -[MasterViewController 
> doSomethingAndBackToMaster:] did something with "2015-04-16 05:16:49 +", 
> will do: [ perform]
> 
> iPad  - tapping on "Do & Back" prints:
> nothing. 
> 


What did you expect it to do on the iPad? If the master column is already 
showing there’s nothing to do, if not you’re in portrait. Did you expect it to 
do the same thing the ‘Master’ button does and show the master column? That’s 
not really an unwind, it’s movement to a parallel state. 

It’s arguably a bug. The reason it doesn’t do anything at all is because the 
viewcontroller hierarchy is rather different between iPad and iPhone, in iPhone 
the master and detail are stacked in a UINavigationController, so the unwind 
segue finds the master as it goes up the tree. In the other they are siblings 
in the splitviewcontroller, so the unwind segue doesn’t get found. Even if you 
subclass the splitviewcontroller to return the master view controller you’ll 
find the segue still does nothing as, as I said, it’s not really an unwind. 



___

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: Master - Detail: How to get back?

2015-04-15 Thread Gerriet M. Denkmann

>> Can this be done? Or is there a better way to make my button work both
>> for iPhone and iPad?
> 
> Well, my first question is: can you just put your work in the
> implementation of the unwind selector?

That is the way the work is done.

> The unwind itself will be a no-op
> if the split view controller is not collapsed, but the runtime should
> still invoke your unwind selector. If it doesn't, that's a bug, and you
> should file a Radar and send me the number.
Bug 20566151 iPad cannot Unwind

If someone wants to check this bug, here is how I did it:


1. Create project

I created (in Xcode 6.3) a new iOS Application: Master-Detail Application; 
named it "Dummi" (left all the other things unchanged: i.e Objective-C, 
Universal, no CoreData).


2.  Rename Master Scenes

Looked at Main.storyboard. It has 2 Master Scenes. This I think confusing.

I clicked the yellow "Master" symbol in the first Master Scene, set Attributes 
Inspector → View Controller → Title to "Master iPad".

Same with other "Master" → "Master iPhone".


3.  Run

Run on iPhone:
Back Button is called "Master"

Run on iPad:
Back Button is called "Master iPad"

Strange, but not very important.


4.  Unwinding

Added in MasterViewController:

- (IBAction)doSomethingAndBackToMaster:(UIStoryboardSegue*)segue
{
DetailViewController *detailViewController = segue.sourceViewController;
NSLog(@"%s did something with \"%@\", will do: [%@ 
perform]",__FUNCTION__, 
detailViewController.detailItem, segue);
[ segue perform ];
}

Added in Detail Scene a UIBarButtonItem to the right of the Navigation Bar; 
Titel = "Do & Back".

Control-dragged from "Do & Back" to red Exit symbol in Master iPhone Scene; 
selected "doSomethingAndBackToMaster:".


5. Run 

iPhone  - tapping on "Do & Back" prints:
2015-04-16 12:16:52.799 Dummi[28069:20737983] -[MasterViewController 
doSomethingAndBackToMaster:] did something with "2015-04-16 05:16:49 +", 
will do: [ perform]

iPad- tapping on "Do & Back" prints:
nothing. 


> But while I'm here, I figure I should share some little-known knowledge:
> segues do not need to be attached to a control at all. A segue is
> actually defined by its source and destination view controllers, not by
> any controls that invoke it.
> 
> To create a "manual segue" (that is, one which must be invoked in code,
> rather than by any button action):
> 
> 1. In the Document Outline on the left side of the storyboard editor,
> expand the Master and Detail scenes
> 2. Control-drag from the Detail scene's view controller to the Master
> scene's Exit proxy.
> 3. Choose the unwind selector to create a manual unwind segue that isn't
> attached to any specific control.

No such choice.
I get offered:
Manual Segue
doSomethingAndBackToMaster:
Nothing else

> 4. On the Properties Inspector for that newly-created segue, give it an
> identifier.
> 5. Wire up your bar button item to a method that uses
> -performSegueWithIdentifier:sender to trigger the unwind.
> 
> —Kyle Sluder

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: Crash when move open document based app file to trash

2015-04-15 Thread Martin Wierschin
>> I’m not sure how careful that monitoring is, though, whether it happens 
>> continuously, or only at the moment the app or document regains focus.
> 
> Even if it’s continuous, it can’t be continuous enough, since the OS is 
> multithreaded. There’s always the possibility of a race condition where the 
> app tries to access the file after it’s been moved but before the 
> notification arrives. 

I believe an app can use -[NSDocument performSynchronousFileAccessUsingBlock:] 
to avoid such race conditions. At least, I assume so, since NSDocument adopts 
NSFilePresenter and should cope with access from multiple processes (eg: 
Jonathan's app and the Finder).

~Martin Wierschin


___

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

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

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

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

Re: User interface unresponsive in window

2015-04-15 Thread Quincey Morris
On Apr 15, 2015, at 14:54 , Jonathan Taylor  
wrote:
> 
> Am I right in thinking that when running under Xcode any drawing errors will 
> be logged to the Xcode console?

No, not unless they’re actually exceptions. Messages from other processes are 
only going to appear in the system log.

With puzzling, intermittent errors like this, I often find that reading your 
own code carefully may be more productive than going to heroic debugging 
extremes. The trick is not to prejudge *where* in your code you should look. 
(Don’t be the person looking underneath the street light for a dropped quarter 
because “that’s where the light is”.)



___

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: User interface unresponsive in window

2015-04-15 Thread Jonathan Taylor
Thanks for the suggestions. Am I right in thinking that when running under 
Xcode any drawing errors will be logged to the Xcode console? That's certainly 
what I've seen in the past (but not in relation to this problem - haven't seen 
anything in the Xcode console at all for this).

Any other ideas from anyone? Has anybody seen similar symptoms ever in the past 
(GUI not responding properly in one single window)?


On 15 Apr 2015, at 18:01, Quincey Morris  
wrote:

> On Apr 15, 2015, at 07:04 , Jonathan Taylor  
> wrote:
>> 
>> From dimly-remembered past experience I have a feeling it could be related 
>> to something somewhere resulting in GUI code being executed on a non-main 
>> thread.
> 
> You can at least start by trying the simple things, if you haven’t tried them 
> already:
> 
> — Make sure you have an Objc-C exception breakpoint set in Xcode at all times.
> 
> — Use the Console utility to look in the system log for errors about 
> incorrect drawing calls in your app.
> 
> There’s not much chance this will get you off easily, but it’s a quick start.
> 

___

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: layout method not getting called on Content View

2015-04-15 Thread David Duncan

> On Apr 15, 2015, at 2:06 PM, Dave  wrote:
> 
>> 
>> I recommend you switch to Auto Layout.
> 
> AFAICT, Auto-Layout won’t let me do what I want to do.
> 
> This is so simple. The NIB file is owned by the window controller. The window 
> is a large window and initially has two frames in it. Later on, I get 
> Notifications telling me a new position and size for the two Views.

The very minimal thing you could do in auto layout for this is as simple as 
specifying constraints for leading, trailing, width, and height – and you will 
get exactly what you want by setting the constraints as requested by your 
notification. This minimal change would do exactly what the frame setting you 
are trying to do would do.

> I just want set the frame on these two views so it reflects the data from the 
> Notification. I can’t see how auto-layout will help me to do this? The Window 
> can’t be resized and even it it were to be resized, I wouldn’t want anything 
> in the window to change position or size.
> 
> Thanks, 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/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

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: layout method not getting called on Content View

2015-04-15 Thread Dave
> 
> I recommend you switch to Auto Layout.

AFAICT, Auto-Layout won’t let me do what I want to do.

This is so simple. The NIB file is owned by the window controller. The window 
is a large window and initially has two frames in it. Later on, I get 
Notifications telling me a new position and size for the two Views. I just want 
set the frame on these two views so it reflects the data from the Notification. 
I can’t see how auto-layout will help me to do this? The Window can’t be 
resized and even it it were to be resized, I wouldn’t want anything in the 
window to change position or size.

Thanks, 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: First responder (?) problem, and orphaned highlight boxes

2015-04-15 Thread Quincey Morris
On Apr 15, 2015, at 13:30 , Aandi Inston  wrote:
> 
> 2. As a quick fix, is there a way to make sure this highlight box
> disappears with the
> control that it is (to my mind) attached to?

It’s probably being drawn around the field editor, and perhaps that’s not being 
dismissed properly when you hide the text view. You could try setting first 
responder to something else: ‘[window recalculateKeyViewLoop]’, or perhaps 
‘[window makeFirstResponder: nil]’ if you just want to get rid of it.

The blue highlight (it’s called a “focus ring” in Cocoa jargon) behavior does 
sound like a Yosemite bug. If no one else jumps in with a reason why it should 
linger like this, I’d suggest you also submit a bug report about it.



___

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

First responder (?) problem, and orphaned highlight boxes

2015-04-15 Thread Aandi Inston
I am trying to solve a problem which seems to involve the first responder
for an NSWindow.

The NSWindow contains a number of controls and views, including several
NSTextField controls.
It is necessary to show or hide groups of these. These are all created
dynamically, rather
than with Interface Builder.

When a field containing text (created as an NSTextField) is contains the
cursor, it has
a blue(?) highlight box drawn around it. (We do not implement this, it just
happens). But
when the field is hidden, we would like the highlight box to go away.

In our oldest test system, 10.6.8, this is what happens - the highlight box
is removed when
the text field is hidden. But in our newest available test system, 10.10.1,
the highlight box
is left in place, only moving if we click into one of the newly shown
NSTextFields.

So, it seems reasonable to check, when hiding a field, whether it is
highlighted. This is
where I'm stuck. I use [NSWindow currentFirstResponder], but the value
returned is never
the NSTextView that I am hiding. It seems to be an NSText object, which I
didn't make.
Perhaps it is the [NSTextField currentEditor]. But this is getting into
guesswork. So...

1. Is there a more appropriate way to identify if a particular control has
what I would
loosely call "the focus"?
2. As a quick fix, is there a way to make sure this highlight box
disappears with the
control that it is (to my mind) attached to?

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

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

Re: Help with Swift changes to optionals

2015-04-15 Thread Rick Mann

> On Apr 15, 2015, at 12:47 , Marco S Hyman  wrote:
> 
> 
>> On Apr 15, 2015, at 12:29 PM, Rick Mann  wrote:
>> 
>> I used to have this code prior to 1.2, which compiled and ran fine, but now 
>> I get an error on the last line:
>> 
>> '?' must be followed by a call, member lookup, or subscript
> 
> …
> 
>> 
>>   var query : String?;
> 
>> 
>>   log("query: '\(query?)'”);
> 
> Use
> 
>   log("query: '\(query)'”);
> 
> If query is nil the result will be “query: ‘nil’” because string interpolation
> works with optionals.

I stand corrected; that *does* work. I think I fell victim to Xcode showing me 
an error because although it worked in the current target, I had not yet 
rebuilt another target, so it was still showing the error (I REALLY hate 
Xcode's error reporting).

Thanks!

-- 
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: layout method not getting called on Content View

2015-04-15 Thread Dave

> On 15 Apr 2015, at 21:02, Kyle Sluder  wrote:
> 
> On Wed, Apr 15, 2015, at 02:41 PM, Dave wrote:
>> A bit more, I turned Auto Layout on and now the layout method gets
>> called, but it doesn’t set the Frame Rect correctly.
>> 
>> I’m looping through the subviews and setting the frames of a couple of
>> NSViews, but the Frame doesn’t change?
> 
> As documented, you shouldn't be setting frames with Auto Layout enabled.
> They'll get stomped on the next layout passed.

Yes, I realise that, I only turned on Auto-Layout to see what would happen, I 
want it off and I want to lay out the frame myself. When I turn it off, layout 
doesn’t get called. 



___

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: layout method not getting called on Content View

2015-04-15 Thread Kyle Sluder
On Wed, Apr 15, 2015, at 03:02 PM, Kyle Sluder wrote:
> 
> You might want to watch the introductory videos available at
> apple.com/wwdc.

Whoops, the video archive is actually located at
https://developer.apple.com/videos/wwdc.

You might start with the Cocoa Autolayout video from WWDC 2011:
https://developer.apple.com/videos/wwdc/2011/

--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: layout method not getting called on Content View

2015-04-15 Thread Kyle Sluder
On Wed, Apr 15, 2015, at 02:41 PM, Dave wrote:
> A bit more, I turned Auto Layout on and now the layout method gets
> called, but it doesn’t set the Frame Rect correctly.
> 
> I’m looping through the subviews and setting the frames of a couple of
> NSViews, but the Frame doesn’t change?

As documented, you shouldn't be setting frames with Auto Layout enabled.
They'll get stomped on the next layout passed.

You might want to watch the introductory videos available at
apple.com/wwdc.

--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: layout method not getting called on Content View

2015-04-15 Thread Kyle Sluder
On Wed, Apr 15, 2015, at 01:47 PM, Dave wrote:
> Hi,
> 
> I have a WindowController/Window Combo contained in a NIB.

Window controllers usually don't live in nibs. Instead, they act as the
nib's File's Owner.

> Auto Layout is
> turned off and I want to alter to positions and/or sizes of views inside
> the ContentView. I thought the obvious place to do this was layout, but
> it never seems to get called?

As documented, -layout is only called if Auto Layout is enabled or your
view is layer-backed.

> 
> How can I manually lay out the Content View?

I recommend you switch to Auto Layout.

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

layout method not getting called on Content View

2015-04-15 Thread Dave
A bit more, I turned Auto Layout on and now the layout method gets called, but 
it doesn’t set the Frame Rect correctly.

I’m looping through the subviews and setting the frames of a couple of NSViews, 
but the Frame doesn’t change?

The views are initially loaded from a NIB, but later I want to change the size 
and positions of these views in response to data received.

Any help on this greatly appreciated.

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

Help with Swift changes to optionals

2015-04-15 Thread Rick Mann
I used to have this code prior to 1.2, which compiled and ran fine, but now I 
get an error on the last line:

'?' must be followed by a call, member lookup, or subscript

func
httpResponseForMethod(inMethod: String!, URI inPath: String!)
-> NSObject!
{
...

var query : String?;
if let r = inPath.rangeOfString("?")
{
requestRoot = inPath.substringToIndex(r.startIndex);
query = inPath.substringFromIndex(r.endIndex);
}
else
{
requestRoot = inPath;
}

...

log("query: '\(query?)'");
^ < ERROR HERE
}

I tried removing the '?', but I get the same error. Do I have to wrap the whole 
thing in a "let" expression?

I really do prefer Objective-C's handling of messages passed to nil.

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

layout method not getting called on Content View

2015-04-15 Thread Dave
Hi,

I have a WindowController/Window Combo contained in a NIB. Auto Layout is 
turned off and I want to alter to positions and/or sizes of views inside the 
ContentView. I thought the obvious place to do this was layout, but it never 
seems to get called?

How can I manually lay out the Content View?

Thanks a lot
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: User interface unresponsive in window

2015-04-15 Thread Quincey Morris
On Apr 15, 2015, at 07:04 , Jonathan Taylor  
wrote:
> 
> From dimly-remembered past experience I have a feeling it could be related to 
> something somewhere resulting in GUI code being executed on a non-main thread.

You can at least start by trying the simple things, if you haven’t tried them 
already:

— Make sure you have an Objc-C exception breakpoint set in Xcode at all times.

— Use the Console utility to look in the system log for errors about incorrect 
drawing calls in your app.

There’s not much chance this will get you off easily, but it’s a quick start.



___

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: Master - Detail: How to get back?

2015-04-15 Thread Kyle Sluder
On Wed, Apr 15, 2015, at 07:18 AM, Gerriet M. Denkmann wrote:
> 
> While my iPhone can use the “DoSomethingAndGoBackToMasterView” button
> fine,
> the same button does nothing for iPad.
> 
> Of course iPad does not need an unwinding segue - both master and detail
> view are always visible (at least in landscape orientation). But the
> “DoSomething” part is still needed.
> 
> Currently the button has a Triggered Segue (used on iPhone) and a Sent
> Action - obviously ignored, because of the segue.
> 
> So the idea: if the app starts on iPad, I could just clear the Triggered
> Segue and the Sent Action would be used.
> But how? UIBarButtonItem has nothing about segues.

Correct; you can't manipulate segue definitions at runtime.

> 
> Can this be done? Or is there a better way to make my button work both
> for iPhone and iPad?

Well, my first question is: can you just put your work in the
implementation of the unwind selector? The unwind itself will be a no-op
if the split view controller is not collapsed, but the runtime should
still invoke your unwind selector. If it doesn't, that's a bug, and you
should file a Radar and send me the number.

But while I'm here, I figure I should share some little-known knowledge:
segues do not need to be attached to a control at all. A segue is
actually defined by its source and destination view controllers, not by
any controls that invoke it.

To create a "manual segue" (that is, one which must be invoked in code,
rather than by any button action):

1. In the Document Outline on the left side of the storyboard editor,
expand the Master and Detail scenes
2. Control-drag from the Detail scene's view controller to the Master
scene's Exit proxy.
3. Choose the unwind selector to create a manual unwind segue that isn't
attached to any specific control.
4. On the Properties Inspector for that newly-created segue, give it an
identifier.
5. Wire up your bar button item to a method that uses
-performSegueWithIdentifier:sender to trigger the unwind.

--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 remove iPad popover?

2015-04-15 Thread Kyle Sluder
On Wed, Apr 15, 2015, at 12:00 AM, Kyle Sluder wrote:
> Segues are transient objects that only exist

Er, I meant "that only exist long enough to perform their action". In
other words, if you perform a popover segue, that UIStoryboardSegue
object ceases to exist once the popover is onscreen.

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

Scaling images for Insertion into UITextView .attributedText

2015-04-15 Thread Michal L. Wright
Hi,

I have an iOS-based flat-file database app that shows records in a 
UIViewController, called RecordViewController.

I’ve added an “Insert Photo” menu item to the editing menu. This brings up a 
photo picker view that sends the selected image back to RecordViewController.

I’ve included code to scale the image to fit the screen width, which seems to 
work fine when it first displays. However, if I save the datafile or just 
display a different record, then return to the record with the embedded image, 
the image is no longer scaled, but has reverted to its original size.

I haven’t done much with images (and Quartz is just another mineral to me), so 
I don't know what else I might need to do to keep the scaling from reverting.

Here’s the RecordViewController routine that is called to embed the image in 
the UITextView.

- (void)insertPhoto:(UIImage *)image
{
// determine the scaling factor to fit the screen width
CGFloat oldWidth = image.size.width;
NSUInteger newWidth = (g_textView.frame.size.width - 10);
CGFloat scaleFactor;

if (oldWidth > newWidth)
scaleFactor = oldWidth / newWidth;
else
scaleFactor = 1;

// create scaled version of image
CGImageRef imageRef = image.CGImage;
UIImage *scaledImage = [UIImage imageWithCGImage:imageRef 
scale:scaleFactor orientation:UIImageOrientationUp];

// create a text attachment containing the scaled image
NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
textAttachment.image = scaledImage;

// create an attributed string containing the text attachment
NSAttributedString *attrStringWithImage = [NSAttributedString 
attributedStringWithAttachment:textAttachment];

// create a mutable attributed string, tempMutableAttributedText, from 
the text view's .attributedText
NSMutableAttributedString *tempMutableAttributedText = 
[[NSMutableAttributedString alloc] 
initWithAttributedString:g_textView.attributedText];

// insert the attributed string containing the image at the selection 
point in tempMutableAttributedText
NSRange insertionRange = g_textView.selectedRange;
[tempMutableAttributedText replaceCharactersInRange:insertionRange 
withAttributedString:attrStringWithImage];

// set the text view's .attributedText to tempMutableAttributedText
[g_textView setAttributedText:tempMutableAttributedText];

[[self currentRecord] setIsDirty:YES];
[self setDatafileDirty:YES];
}

So, what am I missing? 

And, since different devices need different scaling, is there a way to scale 
multiple embedded images on the fly? If not, I may add code to the photo picker 
to let the user specify the scaling factor. 

Thanks,
Mike Wright

___

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: NSTableView content height

2015-04-15 Thread Ken Thomases
On Apr 15, 2015, at 12:41 AM, Alex Kac  wrote:

> I’m failing to find the proper way to do this. Given an NSTableView, I’d
> like to size its parent view to the height of all the rows/content/headers
> of that table view so that there is no scrolling.
> 
> Someone suggested:
> 
> [_scrollView.documentView frame].size.height
> 
> 
> But that does not work for me. I’d love to get a better suggestion.

Well, what did you do with the above value that didn't work?  Did you feed that 
as input into +[NSScrollView 
frameSizeForContentSize:horizontalScrollerClass:verticalScrollerClass:borderType:controlSize:scrollerStyle:]
 to compute the frame size that the scroll view would have to be to accommodate 
it?

Regards,
Ken


___

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

User interface unresponsive in window

2015-04-15 Thread Jonathan Taylor
I've started encountering intermittent problems in one specific window in my 
application, where text input boxes become unresponsive, steppers remain 
highlighted after clicking, etc. I'm rather short of ideas on how to debug 
this, particular since I haven't worked out how to reproduce it reliably. Other 
windows seem to remain unaffected.

From dimly-remembered past experience I have a feeling it could be related to 
something somewhere resulting in GUI code being executed on a non-main thread. 
There is in principle a risk of that, since the window interacts with 
peripherals/drivers etc involving multithreaded code. I've tried to isolate the 
GUI code from the multithreaded code, but may perhaps have missed some obscure 
case. [ideally, I'd probably totally isolate anything multithreaded from ObjC 
code, but that would mean a proliferation of shadow classes, which is something 
I'd prefer to avoid being dragged into]

Even if my suspicion about the cause (multithreading+GUI) is correct, I'm still 
not sure how to pin down and debug the problem, since there are so many entry 
points into GUI-related code (e.g. property value changes), not all of which 
even involve my own code directly. It would be great if there was some way of 
enabling a global "exception if main-thread requirements are violated", but I 
certainly haven't heard of such a thing (and can imagine there could be very 
good reasons why it would be prohibitively hard to implement). Can anyone 
suggest ways to diagnose and debug my problem (or indeed suggest other possible 
causes I haven't thought of)?

Thanks in advance
Jonny
___

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 safely delete a WebView delegate object?

2015-04-15 Thread Juanjo Conti
Thanks you very much! That fixed it!

On Tue, Apr 14, 2015 at 9:44 PM, Quincey Morris <
quinceymor...@rivergatesoftware.com> wrote:

> On Apr 14, 2015, at 17:01 , Juanjo Conti  wrote:
> >
> > If I click the button too many times, fast enough, my app crash with a
> > EXEC_ error and if I enable zombie objects I get that it crash when one
> of
> > this two messages is been send:
> >
> > [MyDelegate respondsToSelector] or [MyDelegate retain]
> >
> > Does this smell? Any tip I should have in mind for situations like this?
>
> It smells of a memory management error. Delegates are, in most of the
> modern Cocoa classes, unretained objects, and your array (with its strong
> references to your delegates) is what’s keeping them alive. When you remove
> the array element, the strong reference disappears, and your delegate can
> get deallocated, leading to such crashes.
>
> You should make sure you’re setting the various delegate properties in the
> WebView to nil before removing the array element. (It’s too late to do it
> after, unless you’ve taken a local strong reference to the delegate before
> removing.)
>
> At least, this is what it sounds like.
>
>


-- 

Juanjo Conti http://goog_2023646312>@carouselapps.com
>

Software Engineer - Carousel Apps 

-- 
Carousel Apps Limited, registered in England & Wales with registered number 
7689440 and registered office Unit 2 Artbrand Studios, 7 Leathermarket 
Street, London SE1 3HN. Any communication sent by or on behalf of Carousel 
App Ltd or any of its subsidiary, holding or affiliated companies or 
entities (together "Watu") is confidential and may be privileged or 
otherwise protected. If you receive it in error please inform us and then 
delete it from your system. You should not copy it or disclose its contents 
to anyone. Messages sent to and from Watu may be monitored to ensure 
compliance with our internal policies and to protect our business. Emails 
are not secure and cannot be guaranteed to be error free. Anyone who 
communicates with us by email is taken to accept these risks.
___

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: Master - Detail: How to get back?

2015-04-15 Thread Gerriet M. Denkmann

While my iPhone can use the “DoSomethingAndGoBackToMasterView” button fine,
the same button does nothing for iPad.

Of course iPad does not need an unwinding segue - both master and detail view 
are always visible (at least in landscape orientation). But the “DoSomething” 
part is still needed.

Currently the button has a Triggered Segue (used on iPhone) and a Sent Action - 
obviously ignored, because of the segue.

So the idea: if the app starts on iPad, I could just clear the Triggered Segue 
and the Sent Action would be used.
But how? UIBarButtonItem has nothing about segues.

Can this be done? Or is there a better way to make my button work both for 
iPhone and iPad?

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: How to remove iPad popover?

2015-04-15 Thread Gerriet M. Denkmann

> 
> 
> On Tue, Apr 14, 2015, at 11:49 PM, Gerriet M. Denkmann wrote:
>> And if there is any way (easy or not) to get this (in a non-deprecated
>> way), I would be very interested to hear about it.
> 
> There is not. Please file a Radar.

I filed two:

20549495 Unable to get popover controller.
20549450 updateSearchResultsForSearchController: does NOT get called when the 
scope changes.


> 
> --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: Master - Detail: How to get back?

2015-04-15 Thread Gerriet M. Denkmann

> On 15 Apr 2015, at 15:37, Quincey Morris 
>  wrote:
> 
> On Apr 15, 2015, at 01:18 , Gerriet M. Denkmann  wrote:
>> 
>> In DetailViewController I added:
>> 
>> - (IBAction)unwindToMainMenu:(UIStoryboardSegue*)sender
> 
> I dunno offhand, but you originally said you’re trying to go back to the 
> master view controller, and the tech note says that the destination needs to 
> implement the action method. It looks like you implemented in the source 
> (detail view controller) instead.

I moved the unwindToMainMenu to the MasterViewController, then control dragged 
from my button to the red Exit symbol in the Master Scene.
An “Unwind segue” appeared in the Detail Scene. Does not need an identifier.

Now it works fine.

Thank you very much!

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: Master - Detail: How to get back?

2015-04-15 Thread Quincey Morris
On Apr 15, 2015, at 01:18 , Gerriet M. Denkmann  wrote:
> 
> In DetailViewController I added:
> 
> - (IBAction)unwindToMainMenu:(UIStoryboardSegue*)sender

I dunno offhand, but you originally said you’re trying to go back to the master 
view controller, and the tech note says that the destination needs to implement 
the action method. It looks like you implemented in the source (detail view 
controller) instead.



___

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: Master - Detail: How to get back?

2015-04-15 Thread Gerriet M. Denkmann

> On 15 Apr 2015, at 14:51, Quincey Morris 
>  wrote:
> 
> On Apr 14, 2015, at 23:47 , Gerriet M. Denkmann  wrote:
>> 
>> Using the Xcode template: iOS - Master-Detail, the Detail view has (in the 
>> top left corner) a Back-Button, which works fine.
>> 
>> Now I added another UIBarButtonItem called: “Do something and go back” 
>> connected to some IBAction in DetailViewController.
>> 
>> But how to make it go back to the MasterView? 
>> 
>> Found some mention of the red Exit symbol. But cannot persuade Xcode to 
>> create an Unwind segue to Master.
>> Tried to Control-Drag from the yellow Detail thing to the red Exit below, 
>> but no effect.
>> 
>> What am I missing?
> 
> https://developer.apple.com/library/ios/technotes/tn2298/_index.html
> 
> The key to this is that the unwind action method must have exactly the 
> parameter type shown. Anything else prevents IB from connecting the Exit 
> button to the  target.

In DetailViewController I added:

- (IBAction)unwindToMainMenu:(UIStoryboardSegue*)sender
{
UIViewController *sourceViewController = sender.sourceViewController;
NSLog(@"%s %@ id %@",__FUNCTION__, sourceViewController, 
sender.identifier);
[ sender perform ];
}

Now I can control-drag from by UIBarButtonItem to the red Exit symbol in the 
Detail Scene. A big step forward.
A new “Unwind segue to Scene Exit Placeholder” appeared. I gave it an 
identifier.


Build, run, click on my button: nothing happens.

I added:

- (IBAction)dummyExit: sender;  
{
(void)sender;
NSLog(@"%s %@ ",__FUNCTION__, sender);
}

and control-dragged from my button to the yellow Detail thing.

Build, run, click on my button: nothing happens.
Nothing means: no NSLog, no anything.

What else am I missing?


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: Master - Detail: How to get back?

2015-04-15 Thread Quincey Morris
On Apr 14, 2015, at 23:47 , Gerriet M. Denkmann  wrote:
> 
> Using the Xcode template: iOS - Master-Detail, the Detail view has (in the 
> top left corner) a Back-Button, which works fine.
> 
> Now I added another UIBarButtonItem called: “Do something and go back” 
> connected to some IBAction in DetailViewController.
> 
> But how to make it go back to the MasterView? 
> 
> Found some mention of the red Exit symbol. But cannot persuade Xcode to 
> create an Unwind segue to Master.
> Tried to Control-Drag from the yellow Detail thing to the red Exit below, but 
> no effect.
> 
> What am I missing?

https://developer.apple.com/library/ios/technotes/tn2298/_index.html 


The key to this is that the unwind action method must have exactly the 
parameter type shown. Anything else prevents IB from connecting the Exit button 
to the  target.



___

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