Re: Updated View Bounds After Orientation Change...

2015-10-26 Thread Ken Thomases
Read these lines over and over until you see it:

On Oct 26, 2015, at 9:49 PM, Peters, Brandon  wrote:
> 
> (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't 
> understand, refer to the documentation for the UIView property 
> translatesAutoresizingMaskIntoConstraints)
> (
>" UIActivityIndicatorView:0x14eb3760.midX == + 10>",

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

Re: Updated View Bounds After Orientation Change...

2015-10-26 Thread Peters, Brandon
David,

In IB, I have a vertical UIStackView with an image view and a text view 
(stacked in that order). I add the activity indicator programmatically:

override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)

// add activity indicator and start animation
if _useActivityIndicator == true {

// set constraints
_imageView.addSubview(_activityIndicator)


_activityIndicator.centerXAnchor.constraintEqualToAnchor(_imageView.centerXAnchor).active
 = true

_activityIndicator.centerYAnchor.constraintEqualToAnchor(_imageView.centerYAnchor).active
 = true

_activityIndicator.startAnimating()
}
}

I get this error:

2015-10-26 22:44:42.971 Historic Sites Navigator[247:13410] Unable to 
simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't 
want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't 
understand, refer to the documentation for the UIView property 
translatesAutoresizingMaskIntoConstraints)
(
"",
"",
"",
"",
"",
"",
"",
"",
""
)

Will attempt to recover by breaking constraint


Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch 
this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed 
in  may also be helpful.

I do not understand how the error is occurring.


On Oct 26, 2015, at 2:02 PM, David Duncan 
mailto:david.dun...@apple.com>> wrote:


On Oct 25, 2015, at 12:13 PM, Peters, Brandon 
mailto:bap...@my.fsu.edu>> wrote:

David,

I tried your suggestion, but the program terminates. I get this in the console:

view did load...
2015-10-25 15:10:57.893 Historic Sites Navigator[766:538109] *** Terminating 
app due to uncaught exception 'NSGenericException', reason: 'Unable to activate 
constraint with items > and > because they have no common ancestor.  Does the 
constraint reference items in different view hierarchies?  That's illegal.’

You need to ensure they have a hierarchy relationship before activating the 
constraints – you probably didn’t add one as a subview of the other yet.

*** First throw call stack:
(0x2635c68b 0x37716e17 0x2635c5d1 0x271fa7cd 0xce7d8 0xceeb4 0x2a43821b 
0x2a43879f 0x2a755c47 0x2a86185d 0x2a7590b1 0x2a547cff 0x2a547b39 0x2a5476ad 
0x2a54724f 0x2a459535 0x2a45942f 0x29cf45a9 0x123ed73 0x1243815 0x2631f9ad 
0x2631dea7 0x26271249 0x26271035 0x2f354ad1 0x2a486899 0xc5a44 0x37e62873)
libc++abi.dylib: terminating with uncaught exception of type NSException

I will continue to work on it though. Thanks...

On Oct 25, 2015, at 1:11 PM, David Duncan 
mailto:david.dun...@apple.com>> wrote:


On Oct 24, 2015, at 8:45 PM, Peters, Brandon  wrote:

Devs,

I have a UIStackView, which holds an image view and a text view. The image view 
has an activity indicator view as a subview (I add this programmatically). When 
the view initially view loads, I center the activity indicator view within the 
image view and starting the animation for the AIV. But, in the process of 
waiting for the image to load, if I rotate the image view, the AIV needs to be 
re-centered. I added code to listen for the status bar orientation change 
notification, and have a method to invoke upon the notification 
(UIApplicationDidChangeStatusBarOrientationNotification). In that method, I 
attempt to get the bounds of the image view and use that to re-center the AIV 
within the image view. But, it seems that the value of the bounds of the image 
view is not changing when the device orientation changes. Is there a “reliable" 
way to get the updated bounds for a view after the device orientation has 
changed? Code ->

Why do all this at all? Just add 2 constraints that tie the center of the 
activity indicator to its superview and it will remain centered always.

[_activityIndicator.centerXAnchor 
constraintEqualToAnchor:_imageView.centerXAnchor].active = YES;
[_activityIndicator.centerYAnchor 
constraintEqualToAnchor:_imageView.centerYAnchor].active = YES;

(or equivalent if you need to support prior to iOS 9).


// start listening for orientation changes
  NSNotificationCenter.defaultCenter().addObserver(self, selector: 
"orientationDidChange:",
  name: UIApplicationDidChangeStatusBarOrientationNotification, 
object: nil)
…
func orientationDidChange(notification: NSNotification) {

  // get image view bounds
  let viewBounds = _imageView.bounds

  // recenter the activity indicator
  _activityIndicator.center = CGPointMake(CGRectGetMidX(viewBounds), 
CGRectGetMidY(viewBounds))

  }

___

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

Please do not post admin requests or modera

Swift charting

2015-10-26 Thread Eric E. Dolecki
[image: chart.gif]

Hey all,

I am looking for a bar chart system written in Swift with a feature I
haven't seen yet. You can add value filters - say three of them. High,
medium, low. And the bars go up and would change color at the boundary.
Anyone know of anything? I just started here.

Thanks,
Eric
___

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

Smooth adjustScroll of NSScrollView

2015-10-26 Thread Nick
Hi
I am developing an application that looks similar to the OS X's
Calendar.app.

One of the nice features it has is the "gravity effect" to the grid lines,
when the user performs vertical scrolling - if you scroll the calendar so
that half-row is clipped by the Clip View, it automatically scrolls
 further until the whole row fits into the view.

Documentation says that we should implement the adjustScroll method of the
document view, where, given a proposed NSRect, we can update it however we
want.
I did implement this method, and it works, but the problem is that now
scrolling is not smooth at all - It just scrolls "line by line", as it does
in Windows (as in I move two fingers on the trackpad - and get lines simply
displayed one after the other). Is this the intended behavior? If it is,
how did Apple developers make their  Calendar "adjustScroll"-ed scrolling
so smooth? Or is there anything wrong in my code i should be looking to fix?

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: Scripting Bridge Question

2015-10-26 Thread has

Dave wrote:

> Ok, I hear what you are saying but I’ve almost got it working as it 
is and what I’m doing is not that difficult and I should be able to do 
it in the Scripting Bridge


Only if SB lets you do it. There's lots of stuff that works perfectly in 
AS that you *cannot do* in SB because SB is crippled and broken *by 
design*. (I've long since stopped counting. Any AE bridge that pukes its 
guts out at mere sight of InDesign simply isn't fit for use.)


Unfortunately, I have no experience scripting Outlook so cannot tell you 
offhand how - or even if - you can do it in SB. One thing I can say is 
that your AS code looks a bit odd and non-idiomatic itself (though that 
is often the case with Office apps as their Apple event interfaces are 
weird and cranky as hell):


set myObjectID to the id of (object of myWindow)
set myContent to the plain text content of message id myObjectID

In a standard Apple Event Object Model, an `id` value is a unique 
identifier for a single object; thus, a by-id specifier, which is what 
`message id ...` is roughly analogous to a managed pointer. So I 
wouldn't normally expect to be able to take the id of a window object 
and use it as the id of a message object; but then, like I say, Office 
apps' AE interfaces aren't exactly standard.


Oh, and realize SB is spectacularly bad at coping with the more 
"eccentric" scriptable apps, so it may not be possible to do the same 
thing in SB. If so, you won't be the first person who's had to fall back 
to AS for some things, or just abandon SB completely.


HTH

has
___

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: Scripting Bridge Question

2015-10-26 Thread Dave
Ok, I hear what you are saying but I’ve almost got it working as it is and what 
I’m doing is not that difficult and I should be able to do it in the Scripting 
Bridge, the thing that is confusing me is that:

set myObjectID to the id of (object of myWindow)
set myContent to the plain text content of message id myObjectID

what is "message id” in this case? In 

There is a definition of:

@interface SXOutlook2011Object : SXOutlook2011Item
- (NSInteger) id;  // The unique ID of a record.
@end

Which shows the id as being an Integer but on SBElementArray, there is a method:

- (ObjectType) objectWithID:(id)identifier;


Which takes an object, not an integer, I think if I could get the correct ID 
for the message I could just call this method which would solve my problem.

I’ve got a work-around that seems to work which is to get the Outgoing Message 
from the current messages array instead of via the Window. This does seem to 
work, but and I think it will be ok to use it, I’m just slightly worried that 
there may be a case where the message of the front window is not the same as 
the current message…..

All the Best
Dave

> On 26 Oct 2015, at 14:23, has  wrote:
> 
> Dave wrote:
> 
> > I’m using the Scripting Bridge to Target MS Outlook. I’m trying to figure 
> > out how to do the following AppleScript using the Scripting Bridge. Please 
> > see Full Script below, I’ve got most of the code, but I can’t seem to 
> > figure out the right Objective-C code for these two statements:
> 
> Scripting Bridge doesn't work properly; never has, never will. According to 
> the Apple developer that wrote it, it wasn't designed to work with Carbon 
> apps (which is funny cos it doesn't work right with Cocoa ones either). Maybe 
> your AS code will translate; maybe it won't. Maybe it'll work, maybe it 
> won't. If it doesn't, you'll have zero clue why. For anything non-trivial, 
> you're best sticking to AppleScript: it's the ONLY[1] solution that actually 
> works right.
> 
> Since you're using ObjC/Cocoa and already have a working AppleScript 
> implementation, the neatest solution is to use the AppleScript-ObjC bridge to 
> call your AppleScript code directly. Just wrap your AS code as handlers in 
> script objects that inherit from NSObject, and you can call them pretty much 
> as you would native ObjC methods. Quick how-to here:
> 
>http://appscript.sourceforge.net/asoc.html
> 
> HTH
> 
> has


___

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: Scripting Bridge Question

2015-10-26 Thread has

Dave wrote:

> I’m using the Scripting Bridge to Target MS Outlook. I’m trying to 
figure out how to do the following AppleScript using the Scripting 
Bridge. Please see Full Script below, I’ve got most of the code, but I 
can’t seem to figure out the right Objective-C code for these two 
statements:


Scripting Bridge doesn't work properly; never has, never will. According 
to the Apple developer that wrote it, it wasn't designed to work with 
Carbon apps (which is funny cos it doesn't work right with Cocoa ones 
either). Maybe your AS code will translate; maybe it won't. Maybe it'll 
work, maybe it won't. If it doesn't, you'll have zero clue why. For 
anything non-trivial, you're best sticking to AppleScript: it's the 
ONLY[1] solution that actually works right.


Since you're using ObjC/Cocoa and already have a working AppleScript 
implementation, the neatest solution is to use the AppleScript-ObjC 
bridge to call your AppleScript code directly. Just wrap your AS code as 
handlers in script objects that inherit from NSObject, and you can call 
them pretty much as you would native ObjC methods. Quick how-to here:


http://appscript.sourceforge.net/asoc.html

HTH

has

--

[1] Specifically, it's the only *currently supported* solution that 
works right. I no longer support appscript, am not going to waste 
anyone's time promoting AppleEventBridge (which I only did in a failed 
attempt to prevent the Automation team screwing up JavaScript too), and 
I'm not interested in finishing/supporting SwiftAE unless Apple can be 
persuaded to adopt it for OS X. If anyone here still cares about Mac 
Automation, please feel free to contact me off-list with any 
advice/criticism/encouragement/support.


http://appscript.sourceforge.net
https://bitbucket.org/hhas/appleeventbridge
https://bitbucket.org/hhas/swiftae  (docs: http://hhas.bitbucket.org)
___

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

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

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

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

Scripting Bridge Question.....

2015-10-26 Thread Dave
Hi,

I’m using the Scripting Bridge to Target MS Outlook. I’m trying to figure out 
how to do the following AppleScript using the Scripting Bridge. Please see Full 
Script below, I’ve got most of the code, but I can’t seem to figure out the 
right Objective-C code for these two statements:

set myObjectID to the id of (object of myWindow)
set myContent to the plain text content of message id myObjectID

on run
tell application id "com.microsoft.Outlook"
activate
set myWindow to the front window
if class of myWindow is not draft window then
return "Error - Not Draft Window"
end if

set myObjectID to the id of (object of myWindow)
set myContent to the plain text content of message id myObjectID

return myContent
end tell
end run


I have the following Objective-C code:

-(BOOL) outlookGetDraftWindowForWindowIndex:(NSInteger) theWindowIndex 
returnDraftWindow:(SXOutlook2011DraftWindow**) theDraftWindowPtr  
returnMessage:(SXOutlook2011OutgoingMessage**) theOutgoingMessagePtr
{
SXOutlook2011Application*   myOutlookApp;
SBElementArray* myOutgoingMessageArray;
SBElementArray* myDraftWindowsArray;
SXOutlook2011DraftWindow*   myDraftWindow;
SXOutlook2011OutgoingMessage*   myOutgoingMessage;
SXOutlook2011Object*myDraftObject;
NSInteger   myDraftObjectID;

//**
//**Get the Outlook Application
//**
myOutlookApp = [self.pSingletonManager.pScriptingBridgeManager 
getHandlerWithAppInternalID:kBundleIDOutlook];
if (myOutlookApp == nil)
return NO;

if (theDraftWindowPtr != NULL)
*theDraftWindowPtr = nil;

if (theOutgoingMessagePtr != NULL)
*theOutgoingMessagePtr = nil;

myOutgoingMessageArray = [myOutlookApp outgoingMessages];
myDraftWindowsArray = [myOutlookApp draftWindows];
if ([myDraftWindowsArray count] < theWindowIndex)
return NO;

myDraftWindow = [myDraftWindowsArray objectAtIndex:theWindowIndex];
if ([myDraftWindow exists] == NO)
return NO;

//**
//**Save the Window before Getting the Message
//**
[myDraftWindow saveIn:nil as:myDraftWindow.name];

myDraftObject = myDraftWindow.object;
if ([myDraftWindow exists] == NO)
return NO;

myDraftObjectID = myDraftObject.id;
myOutgoingMessage = [self findMessageWithID:myDraftObjectID 
inArray:myOutgoingMessageArray];

if (theDraftWindowPtr != NULL)
*theDraftWindowPtr = myDraftWindow;

if (theOutgoingMessagePtr != NULL)
*theOutgoingMessagePtr = myOutgoingMessage;

return YES;
}


Which works but takes for ever because:

myOutgoingMessage = [self findMessageWithID:myDraftObjectID 
inArray:myOutgoingMessageArray];

Does a sequential search of the Outgoing Message array, which is ok if there 
are only a few messages but as soon as you get more than about 100 it takes way 
too long.

Any ideas on this would be 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