Re: exposing only what you want - headers and Swift?
Jim, When you ship a Swift framework it does not contain source code. But if you want to give someone else the ability to build the framework (say because you don’t support a specific compiler version or specific ABI, or so unneeded parts can be left out), you must ship the source. Some software distributions come in binary form, some come in source form, and some come in both. But a Swift framework is what it is. Tom Wetmore > On Jun 26, 2016, at 5:19 PM, Jim Adams wrote: > > Don’t you have to ship your Swift source code with a framework because of > source incompatibility and ABI issues? > >> On Jun 26, 2016, at 3:06 PM, Thomas Wetmore wrote: >> >> A framework does not include source. It as an opaque bundle that contains a >> public API and compiled code as an integrated whole. >> >>> On Jun 26, 2016, at 2:48 PM, William Squires wrote: >>> >>> True, but they'd still have the source .swift file as the compiler would >>> need this to know what symbols, identifiers, etc... there were, even if >>> they were marked private. Whereas in ObjC, I can give someone the header >>> and the framework, and they can't see the internals, and thus be tempted to >>> program to an implementation (or, for that matter, myself) :) >>> >>> On Jun 25, 2016, at 3:11 PM, Quincey Morris >>> wrote: >>> >>>> On Jun 25, 2016, at 12:57 , Quincey Morris >>>> wrote: >>>>> >>>>> provide a framework >>>> >>>> Sorry, just to clarify since you asked about this, a Swift language >>>> framework module only exposes things explicitly declared “public”. Things >>>> without access controls are implicitly “internal” and so not exposed in >>>> frameworks. >>>> >>> >>> ___ >>> >>> 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/ttw4%40verizon.net >>> >>> This email sent to t...@verizon.net >> >> >> ___ >> >> 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/jim.adams%40sas.com >> >> This email sent to jim.ad...@sas.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: exposing only what you want - headers and Swift?
A framework does not include source. It as an opaque bundle that contains a public API and compiled code as an integrated whole. > On Jun 26, 2016, at 2:48 PM, William Squires wrote: > > True, but they'd still have the source .swift file as the compiler would need > this to know what symbols, identifiers, etc... there were, even if they were > marked private. Whereas in ObjC, I can give someone the header and the > framework, and they can't see the internals, and thus be tempted to program > to an implementation (or, for that matter, myself) :) > > On Jun 25, 2016, at 3:11 PM, Quincey Morris > wrote: > >> On Jun 25, 2016, at 12:57 , Quincey Morris >> wrote: >>> >>> provide a framework >> >> Sorry, just to clarify since you asked about this, a Swift language >> framework module only exposes things explicitly declared “public”. Things >> without access controls are implicitly “internal” and so not exposed in >> frameworks. >> > > ___ > > 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/ttw4%40verizon.net > > This email sent to t...@verizon.net ___ 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: Adding Constraints in Code
This looks like you are trying to push both the stack view and the detail view to the left and to the right at the same time, inconsistent with the overall horizontal constraint. Isn’t the error message indicating that there is something wrong with the provided options? I’d experiment with those options to see what happens. Should you be using top and bottom instead? Tom Wetmore > On Sep 14, 2015, at 5:35 AM, Dave wrote: > > myConstraintsArray = [NSLayoutConstraint > constraintsWithVisualFormat:@"H:[StackView]-(<=1)-[DetailView]" > options:NSLayoutFormatAlignAllLeft metrics:nil > views:myConstraintsViewDictionary]; > > myConstraintsArray = [NSLayoutConstraint > constraintsWithVisualFormat:@"H:[StackView]-(<=1)-[DetailView]" > options:NSLayoutFormatAlignAllRight metrics:nil > views:myConstraintsViewDictionary]; ___ 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: Setting NSOutlineView Delegate When a Subview
Note to self: Never ask Cocoa dev questions at 4:00 am. Sorry for wasting bandwidth. Problem was simply because I stupidly added delegate and dataSource as properties to the custom NSView. The compiler was telling me exactly what was wrong. Tom Wetmore > On Jul 30, 2015, at 4:22 AM, Thomas Wetmore wrote: > > I have a custom NSView that has an NSOutlineView as a subview. Instances are > created and used programatically. The code is implemented in Swift 1.2. In > order to set the delegate and data source for the NSOutlineView I assumed I > should just add the following methods to the custom NSView: > > … > var outlineView: NSOutlineView! > var dataSource: NSOutlineViewDataSource? > var delegate: NSOutlineViewDelegate? > … > func setDelegate (delegate: NSOutlineViewDelegate?) { > outlineView.setDelegate(delegate) } > func setDataSource (dataSource: NSOutlineViewDataSource?) { > outlineView.setDataSource(dataSource) } > … > > However, when I do I get a similar compiler error for each method. For the > setDelegate method I get: > > “Method ‘setDelegate’ with Objective-C selector 'setDelegate:' conflicts with > setter for 'delegate' with the same Objective-C selector." > > I changed my method names to setOutlineViewDelegate and > setOutlineViewDataSource to get around the compiler, but I don’t understand > why I have to use the workaround, which feels icky to me. Can anyone provide > insight? Thanks. > > Xcode 6.4 on Mac OS X 10.10.4. > > Tom Wetmore, COF ___ 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
Setting NSOutlineView Delegate When a Subview
I have a custom NSView that has an NSOutlineView as a subview. Instances are created and used programatically. The code is implemented in Swift 1.2. In order to set the delegate and data source for the NSOutlineView I assumed I should just add the following methods to the custom NSView: … var outlineView: NSOutlineView! var dataSource: NSOutlineViewDataSource? var delegate: NSOutlineViewDelegate? … func setDelegate (delegate: NSOutlineViewDelegate?) { outlineView.setDelegate(delegate) } func setDataSource (dataSource: NSOutlineViewDataSource?) { outlineView.setDataSource(dataSource) } … However, when I do I get a similar compiler error for each method. For the setDelegate method I get: “Method ‘setDelegate’ with Objective-C selector 'setDelegate:' conflicts with setter for 'delegate' with the same Objective-C selector." I changed my method names to setOutlineViewDelegate and setOutlineViewDataSource to get around the compiler, but I don’t understand why I have to use the workaround, which feels icky to me. Can anyone provide insight? Thanks. Xcode 6.4 on Mac OS X 10.10.4. Tom Wetmore, COF ___ 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 and Resizable NSViews
> On Jul 20, 2015, at 7:53 PM, Quincey Morris > wrote: > > On Jul 20, 2015, at 16:41 , Thomas Wetmore wrote: >> >> Here is the mouse-down method with event loop. As you can see I am calling >> setFrameOrigin in the dragging case and setting frame directly in the >> resizing case. > > So I think you need to retool your thinking. With auto layout, you no longer > change the size or position of views, but rather change the constraints that > are applied to those view, as Ken Thomases explained in his post. > > As a side issue, given that you’ll need to update constraints and re-layout > your view hierarchy every time the mouse moves during a drag, it might be > worthwhile retooling your code to use mouseDown/mouseDragged events > non-modally, instead of using your current modal loop. I am worried about the performance implications of this. Should I not be? Implementation will tell, of course. I have gone back and forth between the modal approach and the “three-method” approach a couple times. I am now using the modal approach because it resulted in much smoother dragging and resizing. But I have recently upgraded to a new iMac Retina, with much faster processor; I’ll shift back to the three methods when I put in the fix. Tom Wetmore ___ 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 and Resizable NSViews
Clearly Quincey can read minds. He is exactly right about the wrongness of my thinking. I hope he doesn’t read my mind too much longer, or he will get horribly tangled in dusty cob webs of ill-conceived good intentions! Tom Wetmore > On Jul 20, 2015, at 5:15 PM, Quincey Morris > wrote: > > On Jul 20, 2015, at 13:50 , Gary L. Wade wrote: >> >> Depending on your design, why not just use an NSSplitView to do all that for >> you? > > Um, before we go API-hog-wild here, we need to rule out the possibility that > the OP is just Doing It Wrong™. Because I’m 99.% certain that the OP is > just Doing It Wrong™: > >> On Jul 20, 2015, at 13:30 , Thomas Wetmore wrote: >>> >>> I would really like to be able to do resizing using a mouse event loop, but >>> have the layout constraints somehow involved. Reading through references >>> for NSView I don’t see how to do this. I guess I am looking for a way from >>> within the event loop to be able to check whether a proposed new frame >>> rectangle for the view obeys the view’s size constraints. > > So, he’s resizing the view using setFrame**, which is to say he’s not really > using Auto Layout at all. What he apparently wants is *manual* resizing and > repositioning with automatic application of *manual* size limits. This is > functionality that doesn’t exist in Cocoa, and it’s certainly not Auto Layout. > > > ** Probably. There’s still about 0.0001% of doubt 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
Re: Auto Layout and Resizable NSViews
Ken, Thank you! The lights are coming on. Things can become quite obvious when they become obvious, can’t they? Tom Wetmore > On Jul 20, 2015, at 5:13 PM, Ken Thomases wrote: > >> On Jul 20, 2015, at 3:30 PM, Thomas Wetmore wrote: >> >> I would really like to be able to do resizing using a mouse event loop, but >> have the layout constraints somehow involved. Reading through references for >> NSView I don’t see how to do this. I guess I am looking for a way from >> within the event loop to be able to check whether a proposed new frame >> rectangle for the view obeys the view’s size constraints. > > What you should do when using auto layout is place and size the view using > constraints. Thus moving the view involves modifying the placement > constraints and resizing the view involves modifying the size constraints. > For the size constraints, they should be lower priority than your > minimum-size constraints (if you want to keep those separate). Therefore, no > matter what the drag-tracking code does to those size constraints, your view > still won't go below the minimum size. Of course, a reasonable alternative > is to just use the one set of size constraints and, in your code, disallow > ever setting them below your minimums. You'll have to do something like > that, anyway, to prevent the size constraint constants from going negative, > since that's not allowed. > > You should avoid using any of the -setFrame… methods. I assume that's what > you have been using to place and size the view, but frames set that way get > overridden by the next layout pass. > > 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: Auto Layout and Resizable NSViews
Gary, I am working on an application that supports the old fashioned research process of using 3x5 index cards to hold sources and research notes. I have a hierarchy of NSView sub-classes to represent the cards. At the top of the hierarchy is CardView which simply provides the ability to drag and resize with the option of placing any number of other “controls” (NSBezierPaths) around the border of the card for arbitrary operations. Next layer down in the class hierarchy are “cards" that hold content subviews. For example, there is the OutlineCardView, where the content is an NSOutlineView, used to hold generic information in an outline form. Functionality added at this layer in the hierarchy includes editing the outline with undo and redo and commit, things like that. At the next layer down are cards that represent particular types of information. For example, there is a PersonCardView that represents genealogical data about a person expressed in outline form and displayed in an NSOutlineView. Functionality added at this layer in the hierarchy includes knowledge of life events, relationships between persons, dates, places, and so on. The overall look and feel of this application, as I mentioned to David, is as a large work surface (a near full screen NSWindow) with lots of instances of CardView subclasses that the user can move around, access, put away, search for and bring in, and so forth, while thinking through a research project. I’m not sure how a NSSplitView will particularly solve my resizing problems, but as I implied, I am struggling to learn the best way to get to my goals, and my direction could now be in a dark alley. Tom Wetmore > On Jul 20, 2015, at 4:50 PM, Gary L. Wade > wrote: > > Depending on your design, why not just use an NSSplitView to do all that for > you? > -- > Gary L. Wade (Sent from my iPhone) > http://www.garywade.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: Auto Layout and Resizable NSViews
> On Jul 20, 2015, at 4:45 PM, David Duncan wrote: > > >> On Jul 20, 2015, at 1:30 PM, Thomas Wetmore wrote: >> >> I really try to figure this stuff out. No kidding. I am trying this simple >> experiment: >> >> I define an NSView that has nothing more than a resize handle, defined as a >> rectangular NSBezierPath in its lower right corner. There are no subviews >> and no superviews involved here. I resize the NSView by implementing a mouse >> event loop in the NSView code. I also drag the NSView within its window >> within the same mouse event loop if the mouse down was not in the resize >> Bezier path. >> >> In the view’s initializer I create two NSLayoutConstraints, to set a minimum >> height and minimum width on the NSView, and add them to the view. I also set >> the NSView’s translatesAutoresizingMaskIntoConstraints property to false, so >> that these are the only two constraints defined on the the view. >> >> This is all done programmatically. There is no NIB for this NSView. For >> reference here is the code that creates and adds the constraints, found >> inside the view’s initializer: >> >> widthConstraint = NSLayoutConstraint(item: self, attribute: >> NSLayoutAttribute.Width, >> relatedBy: NSLayoutRelation.GreaterThanOrEqual, toItem: nil, >> attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: >> 100.0) >> heightConstraint = NSLayoutConstraint(item: self, attribute: >> NSLayoutAttribute.Height, >> relatedBy: NSLayoutRelation.GreaterThanOrEqual, toItem: nil, >> attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: >> 100.0) >> addConstraint(widthConstraint) >> addConstraint(heightConstraint) > > Nit: instead of using addConstraint(), you can use .active = true on the > constraints themselves and the constraints will find the most appropriate > view to add themselves to. David, Thanks for that tip. I missed that in the docs. I added the constraints directly to the view itself as the view met the definition of “closest ancestor” as found in the docs. >> [Peeve, before I move on. I have to include the names of the two enum types >> (NSLayoutAttribute and NSLayoutRelation) in this code in order for the >> compiler to be happy — why? — I thought the compiler knows what the >> parameter types are so only the enum constants should be needed. End peeve.] >> >> When I instantiate one of these views and place it in an NSWindow, I can >> drag it around and I can resize it, as expected. Notably, however, I can >> resize it down to zero size (and even smaller!), even though the two >> constraints exist. I kind of expected the program to crash when the >> constraints were violated, but things keep on running. I can drag and resize >> the view at will with no repercussions. > > Since you’ve only given height & width constraints, you have an ambiguous > position for this view and no actual relation to the superview. Likely when > you get into this case the view is still respecting the size you gave it, but > since there is no relation to its parent, the parent will simply size smaller > and clip it. Ah. When I add the view to its window, it becomes a sub-view of the window’s content view. Yes, I understand that. However, when I add the view to the window, I have an algorithms that decides where to put it, so I define its location in the window programatically. I didn’t think about the ramifications of that with respect to the constraint system. I am now wondering whether I do have to. (Think of the window as a large working surface, and think of the views as note cards that can be moved around on the surface.) > If you add constraints to match this view to its superview’s > top/leading/bottom/trailing you will likely see the behavior you expect. > >> >> I would really like to be able to do resizing using a mouse event loop, but >> have the layout constraints somehow involved. Reading through references for >> NSView I don’t see how to do this. I guess I am looking for a way from >> within the event loop to be able to check whether a proposed new frame >> rectangle for the view obeys the view’s size constraints. >> >> Anyone have advice of what I should be reading to figure out what to do? All >> the examples I can find seem so simple. Whenever I get into one these, what >> seems to me to be a simple, real world situations (how unusual is a >> resizable view with constraints, after all?), I seem to get lost reading a >> plethora of confusing documents. It’s either me or the documentation, or >> maybe
Re: Auto Layout and Resizable NSViews
Quincey, Thanks. I’m using Xcode Version 6.4 (6E35b). Mac running 10.10.4. Programming in Swift 1.2. Here is the mouse-down method with event loop. As you can see I am calling setFrameOrigin in the dragging case and setting frame directly in the resizing case. override func mouseDown (event: NSEvent) { var resizing = false var dragging = false let clickLocation = convertPoint(event.locationInWindow, fromView: nil) if resizePath.containsPoint(clickLocation) { resizing = true } else { dragging = true } // Remain in an event loop until left mouse up. let mask = NSEventMask.LeftMouseUpMask | NSEventMask.LeftMouseDraggedMask var lastDragLocation = superview!.convertPoint(event.locationInWindow, fromView: nil) while resizing || dragging { let event = window!.nextEventMatchingMask(Int(mask.rawValue)) if event == nil { continue } if event!.type == NSEventType.LeftMouseUp { resizing = false dragging = false } else if event!.type == NSEventType.LeftMouseDragged { let dragLocation = superview!.convertPoint(event!.locationInWindow, fromView: nil) if dragging { var origin = frame.origin origin.x += dragLocation.x - lastDragLocation.x origin.y += dragLocation.y - lastDragLocation.y setFrameOrigin(origin) needsDisplay = true } else if resizing { var origin = frame.origin var size = frame.size origin.y += dragLocation.y - lastDragLocation.y size.height -= dragLocation.y - lastDragLocation.y size.width += dragLocation.x - lastDragLocation.x frame = CGRect(origin: origin, size: size) needsLayout = true needsDisplay = true } lastDragLocation = dragLocation } } Tom Wetmore > On Jul 20, 2015, at 4:43 PM, Quincey Morris > wrote: > > On Jul 20, 2015, at 13:30 , Thomas Wetmore wrote: >> >> When I instantiate one of these views and place it in an NSWindow, I can >> drag it around and I can resize it, as expected. Notably, however, I can >> resize it down to zero size (and even smaller!), even though the two >> constraints exist. I kind of expected the program to crash when the >> constraints were violated, but things keep on running. I can drag and resize >> the view at will with no repercussions. > > a. What version of Xcode are you using? > > b. What mechanism are you using (inside the mouse-down event loop) to change > the size? > ___ 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
Auto Layout and Resizable NSViews
I really try to figure this stuff out. No kidding. I am trying this simple experiment: I define an NSView that has nothing more than a resize handle, defined as a rectangular NSBezierPath in its lower right corner. There are no subviews and no superviews involved here. I resize the NSView by implementing a mouse event loop in the NSView code. I also drag the NSView within its window within the same mouse event loop if the mouse down was not in the resize Bezier path. In the view’s initializer I create two NSLayoutConstraints, to set a minimum height and minimum width on the NSView, and add them to the view. I also set the NSView’s translatesAutoresizingMaskIntoConstraints property to false, so that these are the only two constraints defined on the the view. This is all done programmatically. There is no NIB for this NSView. For reference here is the code that creates and adds the constraints, found inside the view’s initializer: widthConstraint = NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.GreaterThanOrEqual, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: 100.0) heightConstraint = NSLayoutConstraint(item: self, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.GreaterThanOrEqual, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: 100.0) addConstraint(widthConstraint) addConstraint(heightConstraint) [Peeve, before I move on. I have to include the names of the two enum types (NSLayoutAttribute and NSLayoutRelation) in this code in order for the compiler to be happy — why? — I thought the compiler knows what the parameter types are so only the enum constants should be needed. End peeve.] When I instantiate one of these views and place it in an NSWindow, I can drag it around and I can resize it, as expected. Notably, however, I can resize it down to zero size (and even smaller!), even though the two constraints exist. I kind of expected the program to crash when the constraints were violated, but things keep on running. I can drag and resize the view at will with no repercussions. I would really like to be able to do resizing using a mouse event loop, but have the layout constraints somehow involved. Reading through references for NSView I don’t see how to do this. I guess I am looking for a way from within the event loop to be able to check whether a proposed new frame rectangle for the view obeys the view’s size constraints. Anyone have advice of what I should be reading to figure out what to do? All the examples I can find seem so simple. Whenever I get into one these, what seems to me to be a simple, real world situations (how unusual is a resizable view with constraints, after all?), I seem to get lost reading a plethora of confusing documents. It’s either me or the documentation, or maybe a lack of documentation. I can easily believe it’s me. But that doesn’t help me get this experiment to work. Clearly what I need is a better mental model of how the auto constraint system operates at run time. Maybe someone can point me in the direction of a good tutorial. Thanks, Tom Wetmore ___ 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: Errors resulting from Cocoa datatype changes 10.9 -> 10.10
Carl, There is nothing wrong with the code. It is good C code from the good ole days. Size of pointers has no effect, other than in the total sizes of the arrays being allocated. Similar for the size of ints themselves. However, you stop short in your example, and you don’t show either how you 1) put values into the arrays, or 2) use those values. I would guess the problem is in one of those two places, and not in the allocation of the arrays nor in the nature of 64-bit arithmetic. I would recommend you insert some code directly after you create the arrays, that first loads them with a simple pattern of values, and you then immediately print them out or look at them with a debugger. You need to first assure yourself that the arrays are holding exactly what you think they should be holding before you start looking at the overall results of arithmetic operations. Good luck, Tom Wetmore > On Jul 6, 2015, at 3:38 PM, Carl Hoefs wrote: > > We have a legacy Cocoa library of mathematical algorithms that has worked > fine since OS X 10.6, but running this same code on 10.10 results in odd > numerical errors (that is, incorrect results). I'm thinking this could be > the result of differences in ILP32 vs LP64? > > The code variables are ints and pointers, and there's a bunch of memory > allocation for arrays that looks fragile. I know that the size of ints has > not changed, but pointers have gone from 4 bytes to 8 bytes in LP64. Could > this be the problem? > > Here's a sample of affected code: > > int ***hov; > > /* memory allocation for data arrays */ > if((hov=(int ***)malloc(LNUM*sizeof(int **)))==NULL) > { > fprintf(stderr,"Error in memory allocation for hov!\n"); > return(-1); > } > for(k=0;k { > if((hov[k]=(int **)malloc(XDIM*sizeof(int *)))==NULL) > { > fprintf(stderr,"Error in memory allocation for hov[%d]!\n",k); > return(-1); > } > for(i=0;i { > if((hov[k][i]=(int *)malloc(YDIM*sizeof(int)))==NULL) > { > fprintf(stderr," in memory allocation for hov[%d][%d]!\n",k,i); > return(-1); > } >} > } > > /* calculate total field in deg^2 tested per level */ > TOTAL_VF=XDIM*YDIM*(GRES/60.0)*(GRES/60.0); > >. . . etc. > > I've tried promoting the ints to longs, but the errors in the mathematical > computations became much worse. > -Carl > > > ___ > > 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/ttw4%40verizon.net > > This email sent to t...@verizon.net ___ 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: Overlapping NSViews and mouseDown Events
Graham, Xcode 6.3.2; OS X 10.10.3; Base SDK 10.10; Deployment Target 10.10; Swift 1.2; iMac 24” early 2009. I think we have to go back to around 10.5 to get to the time of no assumptions about z-order of overlapping sibling views. Thanks, Tom Wetmore > On Jun 25, 2015, at 12:22 AM, Graham Cox wrote: > > >> On 25 Jun 2015, at 2:08 pm, Thomas Wetmore wrote: >> >> I assume the quirks of dealing with overlapping views have long been ironed >> out. > > > What SDK and minimum target version do you have? > > I’m just wondering if there’s a compatibility thing kicking in for older > systems, which did not make any guarantees about Z-order of overlapping views. > > —Graham > > ___ 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: Overlapping NSViews and mouseDown Events
> On Jun 24, 2015, at 8:44 PM, Thomas Wetmore wrote: > > So I have a view in which one of the subviews seems to work fine with respect > to mouse events, but the border subview around it seems to be invisible to > the event system. Experimentation has proven this statement incorrect. The border view is not invisible. When the window calls hitTest on the view the border view IS returned. However, the window choses to send the event to one of the other, lower in z-order, views. It is hard to believe that I am not doing something stupid; I assume the quirks of dealing with overlapping views have long been ironed out. Tom Wetmore > > How do I make the border areas visible to the window when it decides where to > dispatch the mouse events? Does anyone have any advice? Thanks. ___ 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: Overlapping NSViews and mouseDown Events
Ken, First followup. I added an override of hitTest to my custom view. Behavior is a bit confusing. Say I have three overlapping views. If I click in a spot where they all overlap over their respective table subview areas, hitTest is called on all three of the custom views, and all three then return their table subviews, as they should, and somehow the window figures out to send the event to the top table subview. I would assume it just uses z-order as implied by the ordering of the subviews. But, if I click in the border of the view on top, but the click point is above table subviews in the views below, I do get back the fact that the boundary was hit on the top view, and the table subviews were hit on the other two. But the window always sends the click to one of those table subviews instead of to the boundary on the top view. So the window is getting non-nil back from all three calls to hitTest, but picking the wrong view to send the event to. It can’t be using z-order to make the choice. Do you think it is using one of the others because their hits were deeper into their view hierarchies? Shouldn’t z-order be used? Tom > On Jun 24, 2015, at 10:20 PM, Ken Thomases wrote: > > On Jun 24, 2015, at 7:44 PM, Thomas Wetmore wrote: > >> I am having a problem with NSViews and mouseDown events. >> >> I have defined a custom view (call it CardView) that is an NSOutlineView >> centered in a slightly larger view used as a border. When displayed, a >> CardView looks like an index card holding an outline inside a narrow border. >> There are a few small bezier paths defined in the border that are used as >> controls; one is used as a resize handle. >> >> If the user clicks in the resize handle the view resizes correctly. If the >> user clicks in any non-control part of the border, the view becomes >> draggable and the user can drag it anywhere in the window. All the other >> control functions also. >> >> I can put as many of these CardViews into a window as I like, overlap them >> anyway I like, and they all drag around fine and they all resize fine. >> >> EXCEPT FOR ONE THING, and I haven’t been able to find any help from the docs >> or from Googling: >> >> When I click in the BORDER area of a CardView, and the click spot happens to >> be OVER an OUTLINE part of an UNDERLYING CardView, the UNDERLYING >> NSOutlineView gets the mouseDown event instead of border of the top CardView >> (“top” here is defined as the CardView that is first in the list of subviews >> of the Window’s content view). However, if I click in the outline area of >> the CardView on top, regardless what other CardViews are under that >> CardView, the top outline view always gets the mouseDown as it should. >> >> So I have a view in which one of the subviews seems to work fine with >> respect to mouse events, but the border subview around it seems to be >> invisible to the event system. >> >> How do I make the border areas visible to the window when it decides where >> to dispatch the mouse events? Does anyone have any advice? Thanks. > > Make sure that -[NSView hitTest:] is returning self for any point which is > supposed to hit it (rather than, say, one of its subviews or a view behind > it). Call through to super and, if super returned nil, check the position > against relevant parts of self's frame (note the point is in the superview's > coordinate, so that's frame, not bounds) and, if it's a hit, return self. > Otherwise, return whatever super returned. > > If your view completely fills its bounds with opaque drawing, then it can > override -isOpaque to return true. > > 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: Overlapping NSViews and mouseDown Events
Ken, Thanks. I must admit that I will have to work for awhile to figure out what your answer means. This is the first time I’ve done any out of the ordinary custom view stuff, and I’m having to learn almost everything as I go along. Getting dragging and resizing to work cleanly was a big accomplishment for me. Though, when it’s done, it’s surprising how little code is needed. I don’t yet know what call through to super means in this context. Do you mean to try calling hitTest on the superview? I did just override opaque in the custom view to be true (yes, I’m doing it all in Swift) , but it didn’t change the behavior. I was hoping for an easy fix! Thanks again. Tom Wetmore > On Jun 24, 2015, at 10:20 PM, Ken Thomases wrote: > > On Jun 24, 2015, at 7:44 PM, Thomas Wetmore wrote: > >> I am having a problem with NSViews and mouseDown events. >> >> I have defined a custom view (call it CardView) that is an NSOutlineView >> centered in a slightly larger view used as a border. When displayed, a >> CardView looks like an index card holding an outline inside a narrow border. >> There are a few small bezier paths defined in the border that are used as >> controls; one is used as a resize handle. >> >> If the user clicks in the resize handle the view resizes correctly. If the >> user clicks in any non-control part of the border, the view becomes >> draggable and the user can drag it anywhere in the window. All the other >> control functions also. >> >> I can put as many of these CardViews into a window as I like, overlap them >> anyway I like, and they all drag around fine and they all resize fine. >> >> EXCEPT FOR ONE THING, and I haven’t been able to find any help from the docs >> or from Googling: >> >> When I click in the BORDER area of a CardView, and the click spot happens to >> be OVER an OUTLINE part of an UNDERLYING CardView, the UNDERLYING >> NSOutlineView gets the mouseDown event instead of border of the top CardView >> (“top” here is defined as the CardView that is first in the list of subviews >> of the Window’s content view). However, if I click in the outline area of >> the CardView on top, regardless what other CardViews are under that >> CardView, the top outline view always gets the mouseDown as it should. >> >> So I have a view in which one of the subviews seems to work fine with >> respect to mouse events, but the border subview around it seems to be >> invisible to the event system. >> >> How do I make the border areas visible to the window when it decides where >> to dispatch the mouse events? Does anyone have any advice? Thanks. > > Make sure that -[NSView hitTest:] is returning self for any point which is > supposed to hit it (rather than, say, one of its subviews or a view behind > it). Call through to super and, if super returned nil, check the position > against relevant parts of self's frame (note the point is in the superview's > coordinate, so that's frame, not bounds) and, if it's a hit, return self. > Otherwise, return whatever super returned. > > If your view completely fills its bounds with opaque drawing, then it can > override -isOpaque to return true. > > 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
Overlapping NSViews and mouseDown Events
I am having a problem with NSViews and mouseDown events. I have defined a custom view (call it CardView) that is an NSOutlineView centered in a slightly larger view used as a border. When displayed, a CardView looks like an index card holding an outline inside a narrow border. There are a few small bezier paths defined in the border that are used as controls; one is used as a resize handle. If the user clicks in the resize handle the view resizes correctly. If the user clicks in any non-control part of the border, the view becomes draggable and the user can drag it anywhere in the window. All the other control functions also. I can put as many of these CardViews into a window as I like, overlap them anyway I like, and they all drag around fine and they all resize fine. EXCEPT FOR ONE THING, and I haven’t been able to find any help from the docs or from Googling: When I click in the BORDER area of a CardView, and the click spot happens to be OVER an OUTLINE part of an UNDERLYING CardView, the UNDERLYING NSOutlineView gets the mouseDown event instead of border of the top CardView (“top” here is defined as the CardView that is first in the list of subviews of the Window’s content view). However, if I click in the outline area of the CardView on top, regardless what other CardViews are under that CardView, the top outline view always gets the mouseDown as it should. So I have a view in which one of the subviews seems to work fine with respect to mouse events, but the border subview around it seems to be invisible to the event system. How do I make the border areas visible to the window when it decides where to dispatch the mouse events? Does anyone have any advice? Thanks. Tom Wetmore ___ 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: Language options: Objective-C, Swift, C or C++?
Swift looks like the future; I now use it for new development; and I am porting old projects to it as time permits. I was leary at first, but once it stopped crashing twenty times a day, and performance began approaching that of Obj-C, I converted. I won’t look back unless Apple does an about face and pulls the plug. And slowly but surely the error and warning messages are starting to make sense. I’ve been writing software since 1967 (some overlap in years): Fortran 11 years Algol 2 years COBOL 1 year Pascal2 years C20 years PL-1 2 years C++ 4 years Java 6 years Obj-C 7 years Swift 1 year I enjoyed using all except COBOL, PL-1 and C++. I have been gung-ho for two, Java and Swift. But now I am porting some of my old Java legacy to Swift. I was almost gung-ho for Obj-C, but Apple made so many changes to it over the past few years, I gave up, and Swift has been a cool breath of fresh air. In fact, Swift makes me feel young again. I love the way it looks on the screen. What more is there? If you see your future in building software for Apple platforms (I am retired now, and limit myself to Mac OS X, so am in that category), Swift seems the only realistic road. Else C++. Tom Wetmore > On Jun 12, 2015, at 8:51 PM, Maxthon Chan wrote: > > News outlets says that Objective-C is quickly falling out of people’s > attention and developers are turning away from it to Swift and C++. So what > language will you use to code various parts of your new project? Objective-C? > Swift 2? C++? Or the good old plain C? > > For me, it is still Objective-C and plain C, maybe Swift 2 in the future. I > always hated C++ for its confusing feature set and difficulty in mastering > it, let alone fragile ABI and inability to use modules to accelerate > compilation time. I never looked at the original version of Swift language > closely because it is not feature stable yet and it is confusing since all my > previous experiences are Objective-C, Visual Basic .net and a little bit C# > (I am a convert from Windows and Windows Phone camp, gave up Microsoft four > years ago when I began to see the downfall of Windows as a decent operating > system) The Objective-C and C also have the advantage of being able to be > ported rather effortlessly to Linux using GNUstep. > > Swift 2 though, provided all (Objective-)C currently have, so I am interested > and will look into it once I downloaded Xcode 7. > ___ ___ 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: Sketch TNG Code?
Rick, I requested that code and was told it was not packaged for release as a sample project. I then requested an as-is copy, and am awaiting a reply. If you manage to find a copy I would appreciate hearing about it. Tom Wetmore > On Apr 27, 2015, at 8:52 PM, Rick Mann wrote: > > Is the Sketch TNG sample code available anywhere? Session 2014-212 showed > something I need to do, but didn’t explain how it was done (connecting the > selected shape's properties to the inspector side bar). > -- > 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: NSTableCellView Constraints?
> On Jan 27, 2015, at 7:48 PM, Roland King wrote: > >> On 28 Jan 2015, at 08:35, Kyle Sluder wrote: >> >> On Tue, Jan 27, 2015, at 05:34 PM, Roland King wrote: >>> No I don’t think so. I can’t think of a case IB adds constraints to >>> anything automatically at this point. >> >> If you do not specify any constraints on a view, at compile time Xcode 6 >> will install leading, top, width, and height constraints to mimic the >> behavior you get with auto layout disabled. This makes it possible to >> compile, debug, and test your app before you've set up all your >> constraints. Without this feature, all your underspecified views get >> resized to (0,0,0,0). > > Yes I pointed that out a few mails back up the thread. > > let me re-phrase to be clearer. IB no-longer adds (and attempts to maintain, > and refuses to allow you to remove) explicit constraints when you add views > to your layout as it used to back in Xcode 4. Hence I don’t think the lack of > automatically added explicit constraints between a dragged-in NSTableCellView > and its subviews is because auto layout is ‘in flux’ but because that’s how > Xcode works these days, and much better for it it is too. I defer to the experts. But for me view-based tables no longer work 'as expected’ (how they worked with cell-based tables). That is, one now has to explicitly add constraints in order to get the text in cells to widen and shrink properly as the user widens and shrinks column headers. To me, a non expert, this is disconcerting when first encountered, and seems sloppy, and like something overlooked. It is just one more of thousands of little irksome details that I must fight may way through to learning in order to get a good looking Mac app. But thanks to this list I can add constraints in order to get that expected behavior. Tom Wetmore ___ 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: NSTableCellView Constraints?
> On Jan 27, 2015, at 12:06 PM, Steve Mills wrote: > > On Jan 27, 2015, at 10:48:29, Roland King wrote: >> >>> >>> Using IB to check the constraints on the NSTextField within the >>> NSTableCellView, IB states: “The selected views have no constraints. At >>> build time, explicit left, top, width, and height constraints will be >>> generated for the view.” If this is true, then the constraints that are >>> generated are preventing the text field from getting wider than the launch >>> time width of the column. >> >> So there you go. Exactly as I said there are no constraints fixing the text >> field to the cell so it's getting a fixed width and height and position at >> runtime. So add some. Don't worry about the cell itself, the table view will >> sort that out, just constrain your text view to pin to the edges of the cell >> so it expands as the column does. > > I was also just messing around with a table view and adding constraints. I > selected each NSTextField inside the table view cells, clicked the Pin button > at the bottom, and turned on the left and right constraints, leaving the > default values of 2 and 3). Now the cells resize as I resize the columns and > as I resize the window (because the table view is pinned to the 4 sides of > the window). Thanks. This worked for me also. I believe IB should set up these constraints by default, but that things are still in a state of flux. Tom Wetmore ___ 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: NSTableCellView Constraints?
> On Jan 27, 2015, at 10:48 AM, Roland King wrote: > > >> On 27 Jan 2015, at 22:32, Thomas Wetmore wrote: >> There must be a constraint problem, and I have been playing around with them >> for awhile, but no joy yet. Googling has not turned up a similar issue. I >> would have assumed that when I dragged the NSTableCellView into the >> NSTableColumn using IB, that IB would have established the constraints >> between the cell view and the column view properly. > > No it probably didn’t, but that’s ok, the tableview knows how to keep the > cell the width as the column. It may do it with constraints, or use > autoresizing masks. I would assume this also. But it does not seem to be happening. > >> Apparently not. Is this a known Swift/Cocoa bug or IB bug? > > None of the above I’d expect. What constraints are there between the text > view and the cell which contains it? I don’t remember there being any by > default, which means at runtime some would be implicitly added, probably a > fixed position and fixed width constraint if you hadn’t added some in > yourself. > > Using IB to check the constraints on the NSTextField within the NSTableCellView, IB states: “The selected views have no constraints. At build time, explicit left, top, width, and height constraints will be generated for the view.” If this is true, then the constraints that are generated are preventing the text field from getting wider than the launch time width of the column. Checking the constraints on the NSTableCellView within the NSTableColumn, IB states: “This view has no constraints.” As always I am probably doing something stupid possibly obviously stupid. I will reread the Table View Programming guide another time! Thanks, Tom Wetmore ___ 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: NSTableCellView Constraints?
I have the XIB set for auto layout. However, after dragging an NSTableCellView into the NSTableHeader, IB’s size inspector (for the table cell view) reports that there are no constraints on the cell view. This is clearly the issue. Since I am learning Swift, cell-based views, and auto-layout all at the same time now, I am still a bit caught up in separating the wheat of knowledge from the chaff of information. The Apple example for view-based tables, TableViewPlayground, does not use auto layout, and has the autoresizing mask for the cell view set to exactly track the enclosing view. I must learn how to do the same with auto layout. I am just surprised that IB didn’t set the right constraints. This may have been my fault because I converted to table to view-based by manually by removing all the cells and then changing its type directly, and then adding in the cell views. Maybe the manual conversion rather than starting with a new table set for view cells causes IB it omit a step. Still experimenting to find out. Thanks, Tom Wetmore > On Jan 27, 2015, at 10:23 AM, Keary Suska wrote: > > Well, constraints are fully inspectable. What do they show? ___ 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
NSTableCellView Constraints?
I have a multi-column table that I am converting from an ObjC/cell-based implementation to a Swift/view-based implementation. The cells are text, so I am now using a vanilla text-only NSTableCellView in each column. When the application launches, I can shrink the columns just fine — the text shrinks as it should. BUT, when I widen the columns the text widens until it reaches the width of the INITIAL LAUNCH TIME WIDTH, and widens no further, no matter how wide I make the columns. There must be a constraint problem, and I have been playing around with them for awhile, but no joy yet. Googling has not turned up a similar issue. I would have assumed that when I dragged the NSTableCellView into the NSTableColumn using IB, that IB would have established the constraints between the cell view and the column view properly. Apparently not. Is this a known Swift/Cocoa bug or IB bug? Does anyone know the proper workaround? I am running Xcode 6.2 beta 4. Thanks. Tom Wetmore, Chief Bottle Washer DeadEnds Software ___ 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: Dependency cycle for target "xxx.lib" detected: xxx.lib -> xxx.lib
On Dec 8, 2013, at 5:58 PM, Fritz Anderson wrote: > On 6 Dec 2013, at 5:39 AM, Thomas Wetmore wrote: > >> I'm using Xcode 4 and have a few static libraries that provide >> infrastructure for my applications. >> >> When I build the libraries I get the warning: "Dependency cycle for target >> "xxx.lib" detected: xxx.lib -> xxx.lib" >> >> Intellectually I understand what the dependencies are, classes that mutually >> refer to one another. But my naive assumption is that the linker works it >> out if only because the ranlib program is run on the archive files. I've >> been getting this warning on just about every static library I've written >> for years, so certainly nothing urgent here. It is only a warning and I've >> never had any problems linking against these libraries. >> >> I've googled for information and I searched through the Apple and GNU docs >> for help understanding this warning message, but so far have had no success >> finding info that directly addresses this warning and its consequences. When >> I google the only real results I get are my posting of about this same >> question two and half years ago! >> >> Can anyone offer any context? Should I be worrying about these warnings? > > I'd proceed from the notion that the error message means exactly what it > says: Your target that produces xxx.lib depends on xxx.lib to build it. Check > the Build Phases tab of your Target editor, and look at the Target > Dependencies, Compile Sources, and Link Binary With Libraries phases to see > if xxx.lib (or something that needs xxx.lib to build it) is present. > > — F Thanks for responding. I am proceeding with that notion. For one of the libraries that generates the message, the Target Dependences is empty, the Compile Sources is the five .m files in the library, and the Link Binaries with Libraries holds only Foundation.framework. The library is as vanilla as one can get, wholly self-contained except for Foundation. There are no dependency loops in the library code that I can find, and the library is so simple that I believe a quick visual check is sufficient to prove this. It is interesting that the summary view in the middle of the header area displays "No issues". The warning is found only in the detailed log of build activity in the Build Preparation area of the log (rightmost tab in the Navigator). Does anyone know of an option that would show the dependency cycle? Running the analyzer does not. The message: "Dependency cycle for target 'GeoNamesLibrary' detected: GeoNamesLibrary -> GeoNamesLibrary" isn't helpful. Tom ___ 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
HTML to Text to Tagged Text to XHTML
I am looking for some pointers or advice. I am developing an application to semantically tag HTML pages with genealogical information as defined by the schema.org/Person object and related objects. The NLP required to do the semantic analysis resides in a well-proven text processing library that I have developed over the past couple years. Once the text from the HTML page has been put into a pure string form (i.e., tags removed), the NLP is run and the results catalog every semantic object (e.g, names, dates, places, birth and death events, parent-child relationships) to its position (i.e., NSRange) within the pure text string. FYI my NLP results on simple things like names, dates and other entities, are considerably better than those from Apple's semantic tagging system. So the overall program does the following: 1. Read an HTML file (I am doing this by building an NSXMLDocument with the HTML tidy feature, so the output will be good XHTML regardless of the input). 2. Create the untagged equivalent of the text from the document for use by the NLP and semantic tagging. 3. Do the NLP processing to find and catalog all the semantic objects within the text. 4. Convert the untagged text back into HTML with new tags that match as closely as possible the tags used on the original page, but with extra and/or tags inserted as required to hold semantic information -- the page must render exactly as it used to, but with the semantic tags added. It is in the fourth area -- converting text with auxiliary semantic information back into HTML form that matches a previous HTML page -- that seems to have some marvelous challenges. I've been prototyping a few ideas on how to do this, but the algorithms seem finicky enough that I thought I would ask to see if anyone here has come across a similar type project. Do any of you know of any applications that round trip HTML text to pure strings and then back to possibly modified HTML text? Tom Wetmore, Chief Bottle Washer DeadEnds Software ___ 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: Exception After Adding a WebView to a NIB
Danger Man, I got the include part but forgot the framework part. Thanks! Tom Wetmore On Aug 24, 2013, at 7:27 PM, dangerwillrobinsondan...@gmail.com wrote: > Did you add the WebKit framework to your project and #include it ? > > > On 2013/08/25, at 4:08, Thomas Wetmore wrote: > >> I am writing an app that does NLP on web pages for genealogical information >> and adds semantic tags to the HTML showing the results. >> >> I am having a basic problem. When I add a WebView object to the main NIPB >> using the interface builder, the app immediately crashes by throwing an objc >> exception at the testb instruction below in NSApplicationMain: >> >> 0x7fff96ce99dc: jne0x7fff96ce9a07; NSApplicationMain + 406 >> 0x7fff96ce99de: leaq 13979171(%rip), %rax ; GCC_except_table67 + 16 >> 0x7fff96ce99e5: movq (%rax), %rcx >> 0x7fff96ce99e8: movq 13142833(%rip), %rsi ; SecKeySignDigest + 36 >> 0x7fff96ce99ef: movq 13292330(%rip), %rdi ; >> Security::PasswordDBLookup::lookupInfoOnUID(unsigned int) + 84 >> 0x7fff96ce99f6: movq %r15, %rdx >> 0x7fff96ce99f9: callq *11792009(%rip) ; >> _value_entry_table_resize + 213 >> 0x7fff96ce99ff: testb %al, %al >> >> I see the exception occurs right after some security stuff. Does anyone know >> what is going on here? >> >> I am still just prototyping the user interface. No outlets and actions are >> set up. I just added the WebView and ran the program to see what the UI >> would look like. If I take the WebView out it runs fine again. I tried the >> WebView first in a tab view within a split view, and second in a split view. >> >> Thanks, >> >> Tom Wetmore >> >> >> ___ >> >> ___ 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
Exception After Adding a WebView to a NIB
I am writing an app that does NLP on web pages for genealogical information and adds semantic tags to the HTML showing the results. I am having a basic problem. When I add a WebView object to the main NIPB using the interface builder, the app immediately crashes by throwing an objc exception at the testb instruction below in NSApplicationMain: 0x7fff96ce99dc: jne0x7fff96ce9a07; NSApplicationMain + 406 0x7fff96ce99de: leaq 13979171(%rip), %rax ; GCC_except_table67 + 16 0x7fff96ce99e5: movq (%rax), %rcx 0x7fff96ce99e8: movq 13142833(%rip), %rsi ; SecKeySignDigest + 36 0x7fff96ce99ef: movq 13292330(%rip), %rdi ; Security::PasswordDBLookup::lookupInfoOnUID(unsigned int) + 84 0x7fff96ce99f6: movq %r15, %rdx 0x7fff96ce99f9: callq *11792009(%rip) ; _value_entry_table_resize + 213 0x7fff96ce99ff: testb %al, %al I see the exception occurs right after some security stuff. Does anyone know what is going on here? I am still just prototyping the user interface. No outlets and actions are set up. I just added the WebView and ran the program to see what the UI would look like. If I take the WebView out it runs fine again. I tried the WebView first in a tab view within a split view, and second in a split view. Thanks, Tom Wetmore ___ 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: Fastest way to replace characters in string
On Aug 23, 2013, at 9:40 AM, Alex Zavatone wrote: > > Why isn't it a good idea to have everything set up before you need it? > > In my reasoning, If there is downtime when items can be set up of prefetched > before they are needed, then they are ready for use when needed. > > If you don't do that, then there is some delay when you need the items that > is handled ahead of time, resulting in a delay before the items are available > for use or displayed to the user. > > Of course, this implied lazy instantiation and with it, I wonder why lazy > instantiation is so big. If we're focused on performance, doesn't it make > sense to have the items ready before we need them? > > Sure, I use lazy instantiation at times as well, but I'm rather curious as to > why this is such a preferred method. 1. It shortens the time before a system becomes responsive to the user. 2. The container might not be used at all, so its a win-win-win. 3. The time it takes to lazy allocate a container is lost in the noise. Tom Wetmore ___ 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: Fastest way to replace characters in string
Steve, Sorry, again I was unclear. Here is what I am trying to say: Pre-allocation means to allocate space before you need it, which would be at init time. But there is no need to pre-allocate -- the first allocation can be postponed until the first item is put in the container or characters in the string. I assume the capacity argument is used at that first allocation. Pre-allocation and the capacity argument are wholly orthogonal concepts. Tom Wetmore ___ 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: Fastest way to replace characters in string
Steve, I apologize that what I wrote wasn't clear. Pre-allocation simply means to allocate space BEFORE you need it. And all that means is that the FIRST allocation doesn't occur at init time, but WAITS until you actually put something in the string or container. From that point of view pre-allocation is NEVER required. As I said, the capacity argument MUST BE RESPECTED at the point of the first allocation, whenever that occurs, and at all following re-allocations. My assumption has always been that the capacity increment of each subsequent allocation may grow from the initial capacity size. Tom Wetmore On Aug 22, 2013, at 1:43 PM, Steve Mills wrote: > On Aug 22, 2013, at 12:31:55, Thomas Wetmore > wrote: > >> Pre-allocation doesn't really matter as long as the re-allocations, whenever >> they occur, respect the capacity argument. > > Sure they do. If you don't preallocate, but instead keep appending, and the > pointer needs to grow with every append, it *could* reallocate with every > append. > > -- > Steve Mills > office: 952-818-3871 > home: 952-401-6255 > cell: 612-803-6157 > > > > ___ > > 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/ttw4%40verizon.net > > This email sent to t...@verizon.net ___ 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: Fastest way to replace characters in string
Pre-allocation doesn't really matter as long as the re-allocations, whenever they occur, respect the capacity argument. Tom Wetmore On Aug 22, 2013, at 1:22 PM, Keary Suska wrote: > On Aug 22, 2013, at 9:06 AM, Jens Alfke wrote: > >> create the empty output mutable string with sufficient capacity (i.e. maybe >> 2x the input string length) > > On an entirely different note, does the various initWithCapacity methods of > mutable classes actually do any pre-allocation? Last I understood they really > didn't... > > Keary Suska ___ 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: IOS floating point performance
David, Why don't you increment T by a little bit in each iteration, say by jj/1000., to prove that no optimization is occurring? I would do it but I develop for Mac OSX only. Tom Wetmore On Aug 8, 2013, at 3:59 PM, David Rowland wrote: > I ran it in Debug mode which should turn off most optimizations. I ran the > loop 100 times and then 200 times. The latter took almost exactly twice the > time as the former. The results are saved in instance variables of the C++ > class this belongs to. > > > On Aug 8, 2013, at 12:06 PM, Sandy McGuffog wrote: > >> Be careful using that code as a test; a good optimizing compiler could pick >> up that sin is a library function without side effects, and no result is >> saved, and optimize that loop to two calls to adjustValueRadians. >> >> Sandy >> >> On Aug 8, 2013, at 8:17 PM, Thomas Wetmore wrote: >> >>> David, >>> >>> Those are lightening speeds. So I agree with you wholeheartedly -- there is >>> no sense in working on a custom table-driven approach. The current approach >>> must already be table-based with speeds like that. >>> >>> Tom Wetmore >>> >>> >>> On Aug 8, 2013, at 1:26 PM, David Rowland wrote: >>> >>>> I wrote an app that calculates the positions of Sun and Moon and other >>>> information as well. The heart of the Moon calculation is this. I added a >>>> loop around it and called a stopwatch at the beginning and end. >>>> >>>> startTime(); >>>> for (int jj = 0; jj<100;++jj) >>>> { >>>> //in radians >>>> double lambda = 3.81040282295402 + 8399.70910754626 * T >>>> + 0.109781209950443 * sin(adjustValueRadians(2.35619449019234 + >>>> 8328.69146829639 * T)) >>>> - 0.022165681500328 * sin(adjustValueRadians(4.5256387504213 - >>>> 7214.06294691607 * T)) >>>> >>>> One hundred times through this loop, on my iPhone 5, took about 0.0028 >>>> seconds. Two hundred times took about 0.0056 sec. >>>> >>>> I infer that one pass takes about 0.28 seconds, or 28.0 microseconds. >>>> >>>> The functions are probably very carefully written and could not be >>>> improved by table lookups, vector libraries, etc. That is barking up the >>>> wrong tree. >>>> >>>> David ___ 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: IOS floating point performance
David, Those are lightening speeds. So I agree with you wholeheartedly -- there is no sense in working on a custom table-driven approach. The current approach must already be table-based with speeds like that. Tom Wetmore On Aug 8, 2013, at 1:26 PM, David Rowland wrote: > I wrote an app that calculates the positions of Sun and Moon and other > information as well. The heart of the Moon calculation is this. I added a > loop around it and called a stopwatch at the beginning and end. > > startTime(); > for (int jj = 0; jj<100;++jj) > { > //in radians > double lambda = 3.81040282295402 + 8399.70910754626 * T > + 0.109781209950443 * sin(adjustValueRadians(2.35619449019234 + > 8328.69146829639 * T)) > - 0.022165681500328 * sin(adjustValueRadians(4.5256387504213 - > 7214.06294691607 * T)) > > One hundred times through this loop, on my iPhone 5, took about 0.0028 > seconds. Two hundred times took about 0.0056 sec. > > I infer that one pass takes about 0.28 seconds, or 28.0 microseconds. > > The functions are probably very carefully written and could not be improved > by table lookups, vector libraries, etc. That is barking up the wrong tree. > > David ___ 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: IOS floating point performance
Fritz, I know you know that the accuracy of this approach goes far beyond being accurate only on the half degrees. The interpolation, which can be done by very simple linear interpolation, will convey almost the same level of accuracy on all intervening angle values. There are some places where the trig function reach zeros and infinities, and these have to be handled with care, but it isn't rocket science. Note you never have to call tan() since tan = sin/cos, though you do have to worry about when cos(α) is zero. (Don't have to call any other trig function either). Tom Wetmore On Aug 8, 2013, at 11:19 AM, Fritz Anderson wrote: > And if half-degrees are too coarse for you, you can take advantage of the > cyclic nature of the derivatives of sine and cosine, and run the Taylor > series out as far as you like (though you'd probably lose out to a > professionally-crafted trig library pretty quickly). I guess that could be > vectorized, but it's one more thing to debug. Profile the > Accelerate.framework functions first. > > — F > > On 8 Aug 2013, at 10:01 AM, Thomas Wetmore wrote: > >> p.s. Of course you don't have to call sin() and cos() for >> every half degree when building these tables. You can take advantage >> of how trig functions repeat in the four quadrants, and you can >> take advantage of other inverse and pythagorean reationships >> that exist between them. Even the initial table building >> can be optimized. >> >> Tom Wetmore >> >> On Aug 8, 2013, at 10:53 AM, Thomas Wetmore wrote: >> >>> Returning strictly to the issue of trig performance. A solution I >>> have used in the past is to initialize tables of trig functions, >>> say by calling sin() and cos() for every half a degree, and then >>> interpolating those tables, never calling sin() or cos() again. >>> I did this 29 years ago on an Atari 520ST to simulate the solar >>> system, and it worked well. You only need enough trig accuracy >>> for graphics to plot to the correct pixels. It takes very few >>> decimal places to get that accuracy. >>> >>> Tom Wetmore ___ 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: IOS floating point performance
p.s. Of course you don't have to call sin() and cos() for every half degree when building these tables. You can take advantage of how trig functions repeat in the four quadrants, and you can take advantage of other inverse and pythagorean reationships that exist between them. Even the initial table building can be optimized. Tom Wetmore On Aug 8, 2013, at 10:53 AM, Thomas Wetmore wrote: > Returning strictly to the issue of trig performance. A solution I > have used in the past is to initialize tables of trig functions, > say by calling sin() and cos() for every half a degree, and then > interpolating those tables, never calling sin() or cos() again. > I did this 29 years ago on an Atari 520ST to simulate the solar > system, and it worked well. You only need enough trig accuracy > for graphics to plot to the correct pixels. It takes very few > decimal places to get that accuracy. > > Tom Wetmore > ___ > > 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/ttw4%40verizon.net > > This email sent to t...@verizon.net ___ 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: IOS floating point performance
Returning strictly to the issue of trig performance. A solution I have used in the past is to initialize tables of trig functions, say by calling sin() and cos() for every half a degree, and then interpolating those tables, never calling sin() or cos() again. I did this 29 years ago on an Atari 520ST to simulate the solar system, and it worked well. You only need enough trig accuracy for graphics to plot to the correct pixels. It takes very few decimal places to get that accuracy. Tom Wetmore ___ 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, exactly constitutes a mutable action on an instance?
Alex, Forget what I said about memory management. It is wrong. Your confusion probably stems from the fact that the pointer named myString is allowed to point to any number of string during the execution of your program. It is the objects that are immutable, not the pointers to them. Tom Wetmore On May 28, 2013, at 12:11 PM, Thomas Wetmore wrote: > Alex, > > What your three lines of code do: > >> NSString *myString; > > Compiler allocates space for a pointer on the run time stack. > >> myString = @"Hi"; > > Compiler creates an NSString object somewhere in the heap with the value > @"Hi" and points the pointer to it. > >> myString = @"Hi there"; > > Compiler creates another NSString object somewhere else in the heap with the > value @"Hi there" and points the pointer to it. Depending on the type of > memory management you are using the first string might leak since there is > nothing pointing to it any more. If you are using ARC the compiler will > insert a call to release to remove the first string. > > There is nothing in your code that tries to mutate a string. All it does is > create two different strings. > > Tom Wetmore > ___ > > 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/ttw4%40verizon.net > > This email sent to t...@verizon.net ___ 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, exactly constitutes a mutable action on an instance?
Alex, What your three lines of code do: > NSString *myString; Compiler allocates space for a pointer on the run time stack. > myString = @"Hi"; Compiler creates an NSString object somewhere in the heap with the value @"Hi" and points the pointer to it. > myString = @"Hi there"; Compiler creates another NSString object somewhere else in the heap with the value @"Hi there" and points the pointer to it. Depending on the type of memory management you are using the first string might leak since there is nothing pointing to it any more. If you are using ARC the compiler will insert a call to release to remove the first string. There is nothing in your code that tries to mutate a string. All it does is create two different strings. Tom Wetmore ___ 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: Changing Subview Order Prevents Dragging
Not only does this work, it also does not add duplicates to the subviews array. Tom On May 13, 2013, at 11:56 PM, Thomas Wetmore wrote: > This works. Thanks for the tip. > > Tom Wetmore > > On May 13, 2013, at 11:38 PM, Quincey Morris > wrote: > >> -- Invoke 'addSubview: self' without first removing self. The NSView >> machinery may be clever enough merely to move the view to the end of the >> subviews array, without actually removing and re-adding 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
Re: Changing Subview Order Prevents Dragging
This works. Thanks for the tip. Tom Wetmore On May 13, 2013, at 11:38 PM, Quincey Morris wrote: > -- Invoke 'addSubview: self' without first removing self. The NSView > machinery may be clever enough merely to move the view to the end of the > subviews array, without actually removing and re-adding 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
Changing Subview Order Prevents Dragging
I've been experimenting with a UI for a program that manages many small, draggable views, that can be moved around in the same superview. The following mouse events work well for providing the dragging basics. However, when I drag a view relative to the other views I also want it to end up on top if there is overlap. If I add the three lines of code that are commented out in the mouseDown method, the mouseDragged method stops being called, so the views won't move. On the other hand, if I add those three lines to the mouseUp method, the views move fine, and they transition to the top fine, but only at the very end of the drag, which looks strange as the view pops up through all the other views that were over it. Can anyone suggest why adding the three lines in mouseDown prevents dragging? Using ARC. Thanks, Tom Wetmore - (void) mouseDown: (NSEvent*) event { //NSView* superView = [self superview]; //[self removeFromSuperview]; //[superView addSubview: self]; _startClick = [event locationInWindow]; _startFrame = [self frame]; _dragging = YES; } - (void) mouseDragged: (NSEvent*) event { if (_dragging) { NSPoint clickPoint = [event locationInWindow]; NSRect frame = [self frame]; frame.origin.x = _startFrame.origin.x + clickPoint.x - _startClick.x; frame.origin.y = _startFrame.origin.y + clickPoint.y - _startClick.y; [self setFrame: frame]; [self setNeedsDisplayInRect: frame]; [self autoscroll: event]; } } - (void) mouseUp: (NSEvent*) event { _dragging = NO; //NSView* superView = [self superview]; //[self removeFromSuperview]; //[superView addSubview: self]; } ___ 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: Main Window Disappears when Loaded from Separate NIB File
Steven, Thanks! That did it. Tom Wetmore On May 7, 2013, at 5:57 PM, Steven Degutis wrote: > ARC is on. Retain the window controller. > > On Tue, May 7, 2013 at 4:52 PM, Thomas Wetmore wrote: >> I hope someone can put me straight. I created a vanilla Cocoa App. I deleted >> the window from the MainMenu.xib and created a MainWindow.xib with >> essentially an identical window (no views). >> >> I created a MainWindowController with one overriding method, init, see >> below. In the app delegate's applicationDidFinishLaunching method I create >> the main window controller and attempt to show the main window. If I >> breakpoint just after the [mainController showWindow: nil] method I can see >> the proper user interface with the main menu and main window. However, when >> I let the program run the window immediately disappears. As none of my code >> runs after that point I'm at a bit of a loss discovering what makes the >> window go away. >> >> What am I doing (or not doing) that causes the main window to close or >> become invisible? The code is below. ___ 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
Main Window Disappears when Loaded from Separate NIB File
I hope someone can put me straight. I created a vanilla Cocoa App. I deleted the window from the MainMenu.xib and created a MainWindow.xib with essentially an identical window (no views). I created a MainWindowController with one overriding method, init, see below. In the app delegate's applicationDidFinishLaunching method I create the main window controller and attempt to show the main window. If I breakpoint just after the [mainController showWindow: nil] method I can see the proper user interface with the main menu and main window. However, when I let the program run the window immediately disappears. As none of my code runs after that point I'm at a bit of a loss discovering what makes the window go away. What am I doing (or not doing) that causes the main window to close or become invisible? The code is below. Thanks, Tom Wetmore AppDelegate.h: -- @interface AppDelegate : NSObject @end AppDelegate.m: -- #import "AppDelegate.h" #import "MainWindowController.h" @implementation AppDelegate - (void) applicationDidFinishLaunching: (NSNotification*) aNotification { MainWindowController* mainController = [[MainWindowController alloc] init]; [mainController window]; // force controller to load nib. [mainController showWindow: nil]; // show window -- which promptly disappears } @end MainWindowController.h: --- @interface MainWindowController : NSWindowController @end MainWindowController.m: --- #import "MainWindowController.h" @implementation MainWindowController - (id) init { return [super initWithWindowNibName: @"MainWindow"]; } @end ___ 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
Restricting NSWindow Movement
Is there a way to restrict the movement of an NSWindow to a frame of another window (that may underly it) or to some other fixed rectangular sub-area on the screen? Searching the web there was a CocoaBuilder thread 12 years ago that indicates that it was unknown how to do this then, implying that optimization in the Window Manager was an issue, but holding out the possibility that a layer below Cocoa might allow it. The windowWillMove: delegate method does not allow vetoing the move. In contrast to the windowWillResize:toSize: delegate method that does allow resizing to be vetoed. If your answer to this question would be to ask me why I should want to do such a thing, please consider that that is not an answer. Thanks, Tom Wetmore ___ 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: Parsing XML Files Consisting of a Sequence of Top Level Elements
Thanks for the responses. In the past I have always used NSXMLParser to take control of the structures built during parsing. However, for the past couple years I have used the DOM approach with NSXMLNode and its descendants. After some experimentation with very large XML files I have found that the DOM approach, though more expensive in time and space, is, in Apple's implementation, extremely fast, and with large RAMs and plenty of virtual memory, XML files of many, many megabytes are easily handled. Note, however, that I am exclusively a Mac OS X enterprise developer, not an iOS guy. So I can afford to waste memory on a DOM. The clincher is the availability of the "nodesForXPath:error:" method on the NSXMLNode class. For my recent applications the convenience of this method has outweighed any advantages that SAX-type parsing might bring to bear. I could use NSXMLParser to build NSXMLNode-based DOM's, and then used the nodesForXPath method, but that's a bit of a stretch. In terms of the original question I posed here, the following code takes care of my "problem": // Create a file URL for the file and then create an XML document from that URL. NSURL* url = [NSURL fileURLWithPath: path]; NSString* string = [NSString stringWithContentsOfURL: url encoding: NSUTF8StringEncoding error: &error]; // Add a new root element to the string in case there isn't one. string = [NSString stringWithFormat: @"%@", string]; // Create an XML document from the string. NSXMLDocument* xmlDocument = [[NSXMLDocument alloc] initWithXMLString: string options: 0 error: &error]; Many thanks for taking the time to think about this. Tom Wetmore, CBW, DeadEnds Software On Oct 22, 2012, at 1:02 PM, koko wrote: > /* > Called to parse an element. We make a selector from the element name and > then if we respond to selector it is called from here. Selectors we respond > to have an attribute dictionary > */ > - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName > namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName > attributes:(NSDictionary *)attributeDict > { > m_selString = [NSString stringWithFormat:@"%@:",elementName]; > > SEL selector = NSSelectorFromString(m_selString); > > if([self respondsToSelector:selector]) > [self performSelector:selector withObject:attributeDict]; > } > > On Oct 21, 2012, at 4:02 PM, Graham Cox wrote: > >> >> On 21/10/2012, at 9:50 PM, Thomas Wetmore wrote: >> >>> Is there a way to easily parse an XML file consisting of a sequence of top >>> level elements? >> >> >> What about NSXMLParser? This gives you finer-grained access to the XML >> without expecting a specific structure (other than valid XML). >> >> --Graham >> >> >> ___ >> >> 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/koko%40highrolls.net >> >> This email sent to k...@highrolls.net >> > ___ 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: Parsing XML Files Consisting of a Sequence of Top Level Elements
Doing it programmatically is trivial so I'll stick with it. Tom Wetmore, CBW, DeadEnds Software On Oct 21, 2012, at 6:50 AM, Thomas Wetmore wrote: > I am using NSXMLDocument to parse XML files. Some of the files are not legal > XML because they contain a sequence of top level elements (legal XML must > have a unique root element). > > Currently I handle this issue by programmatically adding a root element to > surround the entire file before parsing. This seems ugly and heavy-handed. > > Is there a way to easily parse an XML file consisting of a sequence of top > level elements? I don't actually need the NSXMLDocument object for anything. > If there were an easy way to parse the files to an array of NSXMLElements it > would be fine. > > Thanks, > > Tom Wetmore ___ 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
Parsing XML Files Consisting of a Sequence of Top Level Elements
I am using NSXMLDocument to parse XML files. Some of the files are not legal XML because they contain a sequence of top level elements (legal XML must have a unique root element). Currently I handle this issue by programmatically adding a root element to surround the entire file before parsing. This seems ugly and heavy-handed. Is there a way to easily parse an XML file consisting of a sequence of top level elements? I don't actually need the NSXMLDocument object for anything. If there were an easy way to parse the files to an array of NSXMLElements it would be fine. Thanks, Tom Wetmore ___ 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: Reading Very Large Files (300 Mb to 3 Gb)
Greg, Thanks for the INSTANT answer! I added the auto-release pool inside the read loop and ran the program on the largest data file I have, 3.46 Gb. The program ran perfectly in just under nine minutes and never built up any virtual memory. In hindsight I am embarrassed I did not come to the answer myself, as I have a fairly good understanding of all the supported memory management models. ARC tends to make one stop worrying, which tends to make one stop thinking. No excuses, though. I was too dim to see it. Thanks again. You nailed it for me. Tom Wetmore On Jul 26, 2012, at 11:29 PM, Greg Parker wrote: > On Jul 26, 2012, at 8:20 PM, Thomas Wetmore wrote: >> I need to process very large files, and below is the program I use to do the >> work. I have run this program on data files from very small up to over 3 Gb >> in length. Much of my testing has been done with files in the 200 to 300 Mb >> size, and the program works fine at that size. >> >> However, when I move up files in the 2 to 4 Gb range, behavior changes. The >> program starts consuming great amounts of virtual memory, around 14 Gb, >> takes more than a half hour to run, and after the functional part of the >> program is over, it takes another half hour for the program to give back >> much of the virtual memory, and once the program does fully quit, it takes >> the operating system another 10 minutes or so of thrashing before the final >> amount of virtual memory is returned and the hard drive finally calms down. >> >> I've never processed such massive files before, but I am surprised by the >> behavior. As you will see I'm using memory mapped NSData, and once I start >> processing the data I simply proceed through the data from beginning to end, >> separating the data into newline-separated lines and processing the lines. >> That processing is simple, just breaking each line into vertical-bar >> separated fields, and putting some of those field values into dictionaries. >> >> If I am simply reading through memory mapped data like this, why does the >> program use about six times as much virtual memory as the amount of memory >> needed by the file itself; why does the virtual memory accumulate in the >> first place, since I never return to memory pages I have already read >> through, and why does it take three quarters of an hour for the system to >> calm down once again after the processing has finished. > > You should use the Allocations instrument to see what is hogging your memory. > > My guess is that the memory-mapped NSData is fine, but that your NSString and > other code inside processLine() is allocating objects and not freeing them. > > One simple possibility is that you are creating lots autoreleased objects, > but not cleaning up any autorelease pools so they don't get deallocated until > you are all done. Try this: > > while (YES) { > @autoreleasepool { > if (start >= length) break; > while (end < length && bytes[end] != '\n') { > end++; > } > line = [[NSString alloc] initWithBytes: bytes + start length: end - > start encoding: 4]; > processLine(line); > start = end + 1; > end = start; > } > } > > (Also, if you are not using ARC then that NSString is leaking, which will > also cost lots of memory.) > > > -- > Greg Parker gpar...@apple.com Runtime Wrangler > > ___ 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
Reading Very Large Files (300 Mb to 3 Gb)
I need to process very large files, and below is the program I use to do the work. I have run this program on data files from very small up to over 3 Gb in length. Much of my testing has been done with files in the 200 to 300 Mb size, and the program works fine at that size. However, when I move up files in the 2 to 4 Gb range, behavior changes. The program starts consuming great amounts of virtual memory, around 14 Gb, takes more than a half hour to run, and after the functional part of the program is over, it takes another half hour for the program to give back much of the virtual memory, and once the program does fully quit, it takes the operating system another 10 minutes or so of thrashing before the final amount of virtual memory is returned and the hard drive finally calms down. I've never processed such massive files before, but I am surprised by the behavior. As you will see I'm using memory mapped NSData, and once I start processing the data I simply proceed through the data from beginning to end, separating the data into newline-separated lines and processing the lines. That processing is simple, just breaking each line into vertical-bar separated fields, and putting some of those field values into dictionaries. If I am simply reading through memory mapped data like this, why does the program use about six times as much virtual memory as the amount of memory needed by the file itself; why does the virtual memory accumulate in the first place, since I never return to memory pages I have already read through, and why does it take three quarters of an hour for the system to calm down once again after the processing has finished. I hope someone with some experience dealing with very large files might see something pretty silly in this code and have a pointer of two to share. Thanks, Tom Wetmore, Chief Bottle Washer, DeadEnds Software #import static void processLine (NSString*); int main(int argc, const char * argv[]) { @autoreleasepool { NSError* error; NSString* path = @"/Volumes/Iomega HDD/Data/data"; NSData* data = [NSData dataWithContentsOfFile: path options: NSDataReadingMappedAlways + NSDataReadingUncached error: &error]; NSUInteger length = [data length]; const Byte* bytes = [data bytes]; NSUInteger start = 0; NSUInteger end = 0; NSString* line; while (YES) { if (start >= length) break; while (end < length && bytes[end] != '\n') { end++; } line = [[NSString alloc] initWithBytes: bytes + start length: end - start encoding: 4]; processLine(line); start = end + 1; end = start; } } return 0; } void processLine (NSString* line) { ... break link into 74 vertical-bar separated fields ... and do simple things } ___ 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: Frameworks (ConnectionKit)
The startImmediately parameter is a BOOL, not a string. Use YES instead of @"YES" and see if that helps. Tom W. On Aug 9, 2011, at 10:44 AM, Amy Gibbs wrote: > I'm certainly noy tied to FTP, and I'll have a go with NSURLConnection. I did > try to use that for another part but I just couldn't get it to work. Is there > a particular sample/tutorial you could recommend? > > In the following code, accessing the URL in a webView works, but the > NSURLConnection doesn't; > [code] > > NSURL *uploadURL = [[NSURL alloc] initWithString:escapedUrl]; > NSMutableURLRequest* post = [NSMutableURLRequest > requestWithURL: uploadURL]; > //NSURLConnection *connect = [NSURLConnection > initWithRequest:post delegate:self startImmediately:@"YES"]; > NSLog (@"uploadurl is: %@", uploadURL); > > > [[uploadWeb mainFrame] loadRequest:[NSURLRequest > requestWithURL:uploadURL]]; > > [/code] ___ 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: Referencing an object after sending a release message to it
It may look odd to use an object that has been just released, but there is nothing wrong in this case, and no assumptions are needed here. As soon as the object has been added to the array it has been safely retained on the same thread by well-understood and well-documented rules, and it should be released as soon thereafter as is practical. I too don't like the way this code feels, but moving the release to the end has no effect other than making some of us possibly feel good. For those who feel best when memory is released as soon as it is possible to do so, this code is fine. For however laudable it is to write comfortable code one must decide for oneself where to put the release. What I found more odd about the example code was the idea that I would use a controller to create an object, and then immediately turn around and tell the controller to save the object it just created. Why not have the controller do that directly and return the object autoreleased? No memory management needed by the controller user. On Aug 6, 2011, at 5:36 PM, Scott Ribe wrote: > On Aug 6, 2011, at 3:06 PM, Jon Boone wrote: > >> Is it dangerous to send the release message to p right after adding it to >> the array? Should I put the release at the end of the method? > > You should release it when you're done with it. Granted, you can probably get > away with it here, under a reasonable set of assumptions: employeeController > actually retains it, rather than copying it, or just using it in the > addObject method and not keeping a reference to it, and rearrangedObjects > doesn't cause it to be released, and there's not some background thread that > will modify employeeController and release it asynchronously. > > But it would be a terrible habit to get in to. (Note how many assumptions it > relies on...) ___ 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: [ANN] CoreParse
On Jun 5, 2011, at 6:12 PM, Thomas Davie wrote: > On 5 Jun 2011, at 18:22, Jens Alfke wrote: >> On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote: >> >>> I've just completed firming up the API and documentation for CoreParse. >>> CoreParse provides a powerful tokenisation and parsing engine, which uses >>> shift-reduce parsing (unlike ParseKit) to support a wide range of context >>> free grammars. >>> >>> Parsers can be built quickly and easily using BNF like syntax. >> >> Cool! What advantages does this have over using a more-established tool like >> ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t >> look that difficult to call into ANTLR-generated C++ code from Obj-C.) > > I've not investigated ANTLR, but you're right, my primary goal was a nice, > clean, cocoa-like API in pure Obj-C only API. The only comparable API that I > know of is ParseKit which uses recursive decent, and hence doesn't support a > lot of grammars. By comparison there, I support SLR, LR(1) and LALR(1), so > there's rather more coverage. > > I'd really appreciate you taking a look and reporting back if you find any > interesting things that ANTLR or other tools does better. And just a reminder that Yacc/Bison is supported by Xcode with builtin build rules and build settings. Yacc/Bison is the original LALR(1) parser generator written by Steve Johnson of Bell Labs in the middle 1970's. Apple has cleverly set things up so that by using a .ym file instead of a .y file, all semantic actions can be written in Objective-C. Other settings are available to allow multiple Yacc-generated parsers per executable. It's an ancient tool, but it works well. Tom Wetmore ___ 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: Cannot find protocol declaration for 'NSTableViewDelegate'
Here is a followup. I have taken a few suggestions to no effect yet. I found something suggestive, however. If I preprocess the offending file, the preprocessor output has the line... @interface NSObject(NSTableViewDelegate) which proves that a pre-10.6 version of NSTableView.h was really included. Both my root SDK and deployment SDK are set to 10.6, and the version of the header file that shows in the Frameworks section in the Xcode project is the 10.6 version. I've been checking other settings but nothing is suspicious yet. Now I'm starting to wonder whether there may be a precompiling issue. I've cleaned the project and its static libraries with the option to rebuild the precompiled headers to no effect. I've tried all versions of the compiler with no effect. I'm running Xcode 3.2.4. Here is something else interesting. Based on a suggestion I created an empty Cocoa app and added the NSTableViewDelegate protocol to the application delegate's interface, and everything was fine; that is, the proper 10.6 version of NSTableView.h got included. So there MUST be something esoteric and wrong about my target build settings. This result changes from a Cocoa issue to an Xcode one. I may re-summarize and post there if I can't find the problem. Any other suggestion gratefully welcome. Tom Wetmore On Nov 5, 2010, at 12:48 AM, Thomas Wetmore wrote: > I've been staring at this error message for the past hour. > > When trying to compile the code ... > > - > #import > > @interface TWInterpreterController : NSWindowController > ... > @end > -- > > the compiler issues the error: > > "Cannot find protocol declaration for 'NSTableViewDelegate'" > > The import of Cocoa/Cocoa.h causes the import of AppKit/NSTableView.h which > contains the protocol definition of NSTableViewDelegate, so I fail to see > what's happening here. Googling the error message leads to the advice that > all circular/recursive import/include loops be avoided, but I fail to see how > one could be happening here. > > In versions of NSTableView.h before 10.6 the delegate was not defined as a > protocol but as a category on NSObject, so if an older version of the header > file were being imported I could understand the message. > > But I'm assuming the NSTableView.h that is being imported must be the one > that I see when I check under the header files under the Frameworks tab in > the Xcode Groups&Files navigator. I do see the older version of NSTableView.h > that define the delegate in a category in the directory: > > /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSTableView.h > > But I'm building with the 10.6 SDK. Is there some mechanism that might be > causing the older NSTableView.h to nevertheless get imported? > > Thanks, > Tom Wetmore___ > > 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/ttw4%40verizon.net > > This email sent to t...@verizon.net ___ 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
Cannot find protocol declaration for 'NSTableViewDelegate'
I've been staring at this error message for the past hour. When trying to compile the code ... - #import @interface TWInterpreterController : NSWindowController ... @end -- the compiler issues the error: "Cannot find protocol declaration for 'NSTableViewDelegate'" The import of Cocoa/Cocoa.h causes the import of AppKit/NSTableView.h which contains the protocol definition of NSTableViewDelegate, so I fail to see what's happening here. Googling the error message leads to the advice that all circular/recursive import/include loops be avoided, but I fail to see how one could be happening here. In versions of NSTableView.h before 10.6 the delegate was not defined as a protocol but as a category on NSObject, so if an older version of the header file were being imported I could understand the message. But I'm assuming the NSTableView.h that is being imported must be the one that I see when I check under the header files under the Frameworks tab in the Xcode Groups&Files navigator. I do see the older version of NSTableView.h that define the delegate in a category in the directory: /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSTableView.h But I'm building with the 10.6 SDK. Is there some mechanism that might be causing the older NSTableView.h to nevertheless get imported? Thanks, Tom Wetmore___ 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
Interacting Sizes of NSScrollView and its NSClipView and a Custom NSView
I have a question based on my confusion over the interacting behaviors of an NSScrollView, its NSClipView and a custom NSView being displayed and clipped. I have an NSScrollView which resizes as its window resizes. Therefore the NSClipView resizes within the NSScrollView as the the window resizes. The custom NSView being displayed is small enough in size so that by enlarging the window far enough the NSClipView can become larger than the custom NSView. At this point the custom NSView becomes "locked" to the lower left corner of the NSScrollView and extra space is added to the top and right margins outside the bounds of the custom NSView. I would like the custom NSView to "float" in the middle of the NSScrollView under these conditions. Other applications seem to implement this behavior. I've been experimenting with settings but haven't been able to figure out how to get what I want. For the time being I have added the window delegate method windowWillResize:toSize: to force the window to stop growing at the point where the NSClipView reaches the same size as the custom NSView, so at least things look nice and neat, with the scroll bars going inactive at the exact point where the window stops growing, but I'd rather have the floating behavior. Can anyone offer any advice? Tom Wetmore, Massachusetts___ 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: TUTORIAL: Generating Unique ID Strings
I must say that I am constantly amused by the nanniness of the Apple discussion lists, telling people what is safe and what is dangerous. There is nothing dangerous about bit-twiddling code. You test it til it works and then it works forever. It doesn't develop bugs later. My goal was to use the 128 bits of a UUID and encode them for use in genealogical database applications using the smallest record id strings possible. My choice was to break the 128-bits into 22 6-bit sequences and encode each 6-bit sequence as a simple character. This is good, honest, easy to write, easy to debug software. In my application databases can be very large, having millions if not billions of records. The goal is that every instance of the application, wherever it is being run, will generate record ids that are not only unique to itself, but to every other instance of the application. In this way people can share information with one another knowing with assurance that any data imported from a database created by another instance of the program will never have id clashes. It is not intended that massive numbers of records be transferred over the network, though they could be, just that data can be shared between databases to any extent with no clashes. There are other benefits such a system has for genealogical data, but what I have described here is good enough. Tom "danger is my middle name" Wetmore On May 14, 2010, at 1:00 PM, Jens Alfke wrote: > (2) If you do need to convert to string, it would be safer to use an existing > Base64 converter rather than writing your own as you've done. This kind of > bit-twiddling code is very prone to error. Probably the quickest way is to > use the Base64 support in the OpenSSL library; a bit of searching in the list > archives should turn up some sample code. > > (3) I'm sort of confused by Thomas Wetmore's comment that "my application > generates billions of [unique ids]". That's way too many to be sending over > the network, so these must be used locally. But in that case, generating > unique IDs becomes much easier, and the IDs a lot smaller: just increment a > 32-bit counter. ___ 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: [iPhone] How to create a unique string
UUID is the way to go. Here is a category I use to generate unique ids. It uses core foundation to generate a 128-bit UUID and converts that to a 22-character string. The conventional string form of a UUID is 36 characters long. A goal of this code was to minimize the size of the id since my application generates billions of them. static unichar x (unsigned int); // This category uses Apple's core foundation to generate a 128-bit universal id and then // encodes the bits into a 22 character string. The conventional string form of a universal // id is 36 characters long, so this saves 14 characters. // @implementation NSString (TWUUID) + (NSString*) stringWithUniqueId { CFUUIDRef uuid = CFUUIDCreate(NULL); CFUUIDBytes b = CFUUIDGetUUIDBytes(uuid); unichar unichars[22]; unichar* c = unichars; *c++ = x(b.byte0 >> 2); *c++ = x((b.byte0 & 3 << 4) + (b.byte1 >> 4)); *c++ = x((b.byte1 & 15 << 2) + (b.byte2 >> 6)); *c++ = x(b.byte2 & 63); *c++ = x(b.byte3 >> 2); *c++ = x((b.byte3 & 3 << 4) + (b.byte4 >> 4)); *c++ = x((b.byte4 & 15 << 2) + (b.byte5 >> 6)); *c++ = x(b.byte5 & 63); *c++ = x(b.byte6 >> 2); *c++ = x((b.byte6 & 3 << 4) + (b.byte7 >> 4)); *c++ = x((b.byte7 & 15 << 2) + (b.byte8 >> 6)); *c++ = x(b.byte8 & 63); *c++ = x(b.byte9 >> 2); *c++ = x((b.byte9 & 3 << 4) + (b.byte10 >> 4)); *c++ = x((b.byte10 & 15 << 2) + (b.byte11 >> 6)); *c++ = x(b.byte11 & 63); *c++ = x(b.byte12 >> 2); *c++ = x((b.byte12 & 3 << 4) + (b.byte13 >> 4)); *c++ = x((b.byte13 & 15 << 2) + (b.byte14 >> 6)); *c++ = x(b.byte14 & 63); *c++ = x(b.byte15 >> 2); *c = x(b.byte15 & 3); CFRelease(uuid); return [NSString stringWithCharacters: unichars length: 22]; } @end // Convert six-bit values into letters, numbers or _ or $ (64 characters in that set). // unichar x (unsigned int c) { if (c < 26) return 'a' + c; if (c < 52) return 'A' + c - 26; if (c < 62) return '0' + c - 52; if (c == 62) return '$'; return '_'; } On May 13, 2010, at 11:05 AM, Michael Ash wrote: > > CFUUID includes the MAC address, so unless your MAC address is cloned > or you manage to generate two UUIDs on the same device in the same > 100ns time interval or the calendar rolls over (which will take about > 3700 years), they are entirely unique within the universe of CFUUID > strings. > > Mike > ___ > > 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/ttw4%40verizon.net > > This email sent to t...@verizon.net Tom Wetmore, Chief Bottle Washer, DeadEnds Software ___ 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: self = [super init], nil?
Being nervous about applying the ! operator to a pointer is needless. It has always been well defined. From the C specification: "The operand of the ! operator must have arithmetic type or be a pointer, and the result is 1 if the value of its operand compares equal to 0, and 0 otherwise. The type of the result is int." The concept of Boolean isn't even mentioned here, as it is really just a fiction anyway. Know thy language. >> By the way, I concur with Thomas Davie: treating a pointer as a Boolean >> makes me nervous. Tom Wetmore ___ 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: self = [super init], nil?
This is the initializer pattern I settled on a few years back: - (id) init... { if (!(self = [super init])) return nil; ... return self; } Trillions of calls later I can report upon its serviceability. I come from an old school, formed in the mid 60's, the Savers Institute for Indentation Levels and Code, when Fortran on punch cards was de rigueur. My graduate work was done at the Bell Labs Institute of Advanced Obfuscation when C was cool. Both schools have since lost their raison d'être, and are sometimes ridiculed, but old alumni still cherish their dogmas. Tom Wetmore, Chief Bottle Washer, DeadEnds Software ___ 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: Bison/Yacc with Objective-C ?
On Mar 12, 2010, at 9:00 AM, steven Hooley wrote: >> Bloomin' magic! Thanks, Filip, it worketh well. Hardy souls all. >> Tom W. > > Is it possible to see an example of how this might be used? I'd like > to understand Bison/Yacc better and i think an example relevant to > Cocoa / Objective-C would really help. > > Thanks, > Steven Steve, The interpreter I am working on is a work in progress, but here is a copy of the yacc/bison file as it exists as I start work on it today. It imports (not includes) the Cocoa Foundation and the semantic actions are written in Objective-C. This file is incomplete as it is only two days old and I am in the process of writing the semantic actions for the statement and expression types now. But you can still see the statement and expression types that will be handled by reading the grammar. The language itself is nearly complete. As it stands now it has only one shift/reduce conflict, that caused by the inherent ambiguity in the if/else statement, but the yacc/bison approach to resolving these conflicts by using shift is the proper handling in this case. (All this means is that the parser will make sure that else statements bind to the closest "then" part.) This is a typical example of using yacc/bison. The language defined is a general purpose programming language. During parsing a semantic tree of the program is built out of Objective-C objects (including the representations of different kinds of statements and expressions, values, types, modules and so on). Building the tree is what the semantic actions (the code with the $$ and $1 things scattered among the rules) do. Once this representation is built, the tree is validated for programming errors as any normal compiler would do (for example, undeclared variables, argument/parameter mismatches, assigning a number to a set, and so on) and then the program is run by an interpreter. The interpreter is similar to, though much simpler than, the Java virtual machine, as it executes the semantic trees as if they were instructions to a virtual machine, while managing the run time stack and the currently active subtree of symbol tables. I am writing the validator and interpreter in parallel with the parser, so there is a lot of stuff not visible here. This is all part of a Cocoa-based genealogical software application, where this part allows users to run their own algorithms on records in their databases or to generate their own specialty reports without having to modify the application itself. The genealogical records (eg, info about events, persons, families, and so on) are all kept in tree structures that can be represented in the application's databases or externally as XML or other types of structured text (GEDCOM is the format often chosen for genealogical software but it suffers from a variety of limitations.) Thus my earlier and not so positive reference to XSLT, which is the "official" (and much harder) way to do this, though I expect that an XSLT "program" would not be able to affect the database holding the records it processes. Needless to say I am extremely pleased that all I had to do was make the suffix to the yacc file be .ym instead of .y to get Xcode to do all the right things. I don't know whether bison itself was modified or whether the Xcode build rules just do the proper renaming, but the fact that someone at Apple worried about it and then made it work, is just one of those little things that makes me so content, one might even say smirkily self-satisfied, to be developing for the Mac. And then the fact that someone on this list (thanks, Filip) knew this was even better, as I have yet to find any actual DOCUMENTATION that states that this would happen! Easter eggs in spring. Tom Wetmore, Chief Bottle Washer, DeadEnds Software // Interpreter.ym // // Created by Thomas Wetmore on 3/10/2010. // Last changed on 3/12/2010. // Copyright 2010 DeadEnds Software. All rights reserved. %{ #import #import "TWInterpreter.h" #import "TWInterpStatement.h" #import "TWInterpExpression.h" #import "TWInterpModule.h" #import "TWInterpLexer.h" // For this parser every semantic type is an Objective-C object. #define YYSTYPE id extern TWInterpreterLexer* lexer; void yyerror (char* message); int yylex (); %} %token TYPE %right ASGNOP %left OROP %left ANDOP %left EQOP %left RELOP %left ADDOP %left MULOP %right UNARYOP %right NOTOP %token IDEN ICONS FCONS SCONS BCONS %token WHILE DO IF ELSE %token BREAK CONTINUE RETURN %% definitions : definition | definitions definition ; definition : declaration { [globalDeclarations addObject: $1]; }
Answer: Bison with Objective-C Semantic Actions? Works
Just a quick thank-you to those who responded to my question about using bison to generate a language intepreter in an Cocoa Foundation/Xcode/Objective-C environment. Xcode does everything needed to make it seamless. I named the yacc file Interpreter.ym and made the semantic value type for all terminals and non-terminals on the parsing stack to be the general Objective-C id type and have had no problems. My semantic actions are all written using Objective-C messaging with the $$, $1, ..., $n stack variables. No perspiration; no worries. Thanks again for the great help available from this group. (Cross posted to the Xcode group since Xcode makes working with yacc/bison almost trivial.) Tom Wetmore, Chief Bottle Washer, DeadEnds Software ___ 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: Bison/Yacc with Objective-C ?
Bloomin' magic! Thanks, Filip, it worketh well. Hardy souls all. Tom W. On Mar 9, 2010, at 6:43 PM, F van der Meeren wrote: > You can just use your objc magic inside the curly braces... All you have to > do is rename your file to *.ym instead of *.y > Then all your files will be named *.m > > To call upon yacc with objc code is currently a no go. Therefor you still > need to call the basic yyparse methods, or add a special directive for the > bison compiler to generate push/pull methods. Those can be created and > deallocated at will and will run next to each other without any problems. > > Filip ___ 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: Bison/Yacc with Objective-C ?
Graham, Definitely not nonsense, and is the solution I will use unless I can find a more direct route. I have done this in the past for YACC to generate C++ on Windows systems. The headache with this solution is that the Xcode has a built-in rule that goes from YACC to C and tries to compile immediately. I will have to learn how to replace the built-in YACC rule with something else. Thanks again for your suggestion, Tom Wetmore On Mar 9, 2010, at 6:33 PM, Graham Cox wrote: > > On 10/03/2010, at 9:00 AM, Thomas Wetmore wrote: > >> Yacc (and Bison) convert yacc files into C files. Instead I would like to >> generate Objective-C files so I can use Cocoa containers classes and >> NSString to get Unicode for free. I do see that bison can generate C++ >> instead of C. Does anyone know whether there is any version of yacc or bison >> that has been modified to generate Objective-C? Or if there is any other >> parser generator available that can generate Objective-C. > > > I haven't tried it, so this might be nonsense, but I think that YACC simply > copies the emitted code from the source file to the final C file. That means > that could be Objective-C code - you'd only need to change the file extension > from .c to .m to compile it. As long as the emitted code is the only > Objective-C and therefore not required to be parsed by YACC, I reckon it > ought to work. > > --Graham > > ___ 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
Bison/Yacc with Objective-C ?
I'm porting an old interpreter from a C-based program that used yacc to parse report generating programs and convert them into interpretable programs that could then generate reports. A system akin to XSLT but using a procedural language rather XML as a programming language, ahem. Yacc (and Bison) convert yacc files into C files. Instead I would like to generate Objective-C files so I can use Cocoa containers classes and NSString to get Unicode for free. I do see that bison can generate C++ instead of C. Does anyone know whether there is any version of yacc or bison that has been modified to generate Objective-C? Or if there is any other parser generator available that can generate Objective-C. Thanks, Tom Wetmore, Chief Bottle Washer, DeadEnds Software ___ 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
initWithCoder / unarchiveObjectWithData Memory Management Question
I have a memory management question involving the interaction of: - (id) initWithCoder: (NSCoder*) coder from any class that implements and + (id) unarchiveObjectWithData: (NSData*) data from the NSKeyedUnarchiver (or any unarchiver) class. After the following lines of code run ... NSData* data = [NSData dataWithContentsOfFile: myObjectPath]; myObject = [NSKeyedUnarchiver unarchiveObjectWithData: data]; (error handling removed), has myObject been retained, or must I now retain it. The unarchiveObjectWithData class method causes myObject's class's initWithCoder object method to run. I assume that initWithCoder obeys memory management rules and returns a newly alloc'ed and retained object. Does the unarchiveObjectWithData method return that retained object unaltered, or does it autorelease it first, so that the unarchiveObjectWithData method obeys the usual convention of class factory methods to return autoreleased objects? I apologize for asking this seemingly basic question, but I can't find the answer in the Apple docs or via googling, and there seems to me to be a clash of well-established conventions involved. The question came up because I found a case in my code where I convinced myself I was over-releasing an object created in this fashion, but the application never fails because of it. Thanks, Tom Wetmore, Chief Bottle Washer, DeadEnds Software ___ 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: Julian date
Here a couple methods that go to and from modified julian day numbers to values. These algorithms are found in a number of standard sources for astronomical computing. These are methods from a date class that I use. They only thing necessary to know about that class is that three of its instance variables are day, month and year. Making these methods work as an NSDate category should be straightforward. Tom Wetmore // Return the modified julian date of this day. //- - (long) toJulian { NSInteger m = month; NSInteger y = year; if (m <= 2) { m += 12; --y; } NSInteger b; if ((1L*y + 100*m + day) <= 15821004L) b = -2 + ((y + 4716)/4) - 1179; // Julian calendar else b = (y/400) - (y/100) + (y/4); // Gregorian calendar return 365L*y - 679004L + b + (NSInteger)(30.6001*(m + 1)) + day; } // Return the day for a modified julian date. //-- + (TWDay*) fromJulian: (long) mjd { long a = mjd + 241; long b, c, d, e, f; if (a < 2299161) { b = 0; c = a + 1524; } else { b = (long) ((a - 1867216.25)/36524.25); c = a + b - (b/4) + 1525; } d = (long) ((c - 122.1)/365.25); e = 365*d + d/4; f = (long) ((c - e)/30.6001); NSInteger day = (int) (c - e - (int) (30.6001*f)); NSInteger month = (int) (f - 1 - 12*(f/14)); NSInteger year = (int) (d - 4715 - (7 + month)/10); return [[[TWDay alloc] initDay: day month: month year: year] autorelease]; } ___ 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: beginner question, NSNumber, NSDecimalAsNumber
Yes, yours is much nicer. TW On Nov 9, 2009, at 12:32 PM, Alastair Houghton wrote: On 9 Nov 2009, at 17:20, Thomas Wetmore wrote: I offer the following as a "Cocoa solution" to the OP's query, whatever that might be taken to mean... (For extra credit: why must the parameter be unsigned?) Tom Wetmore NSString* binaryRepresentation (NSUInteger number) { unichar buffer[64]; NSUInteger n = 0; while (number) { buffer[n++] = (number & 1) + '0'; number >>= 1; } NSInteger i = 0, j = n - 1; while (i < j) { unichar temp = buffer[j]; buffer[j] = buffer[i]; buffer[i] = temp; i++, j--; } return [NSString stringWithCharacters: buffer length: n]; } Surely NSString *binaryRepresentation (NSUInteger number) { unichar buf[64]; unichar *ptr = buf + 64; do { *--ptr = (number & 1) ? '1' : '0'; } while ((number >>= 1)); return [NSString stringWithCharacters:ptr length:buf + 64 - ptr]; } is simpler, as well as actually working when you pass in 0 (yours doesn't). (I should add that I haven't tested this at all; I just wrote it in Mail.app...) Kind regards, Alastair. -- http://alastairs-place.net ___ 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: beginner question, NSNumber, NSDecimalAsNumber
I offer the following as a "Cocoa solution" to the OP's query, whatever that might be taken to mean... (For extra credit: why must the parameter be unsigned?) Tom Wetmore NSString* binaryRepresentation (NSUInteger number) { unichar buffer[64]; NSUInteger n = 0; while (number) { buffer[n++] = (number & 1) + '0'; number >>= 1; } NSInteger i = 0, j = n - 1; while (i < j) { unichar temp = buffer[j]; buffer[j] = buffer[i]; buffer[i] = temp; i++, j--; } return [NSString stringWithCharacters: buffer length: n]; } ___ 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: beginner question, NSNumber, NSDecimalAsNumber
These functions return how many one bits there are in a number, not how many bit positions are needed to represent the number as a bit- string with no leading zeros. They are fun but have no utility in solving the OP's question. TW There are some examples of how to do this here, including some really, really clever methods. http://gurmeetsingh.wordpress.com/2008/08/05/fast-bit-counting-routines/ ___ 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: beginner question, NSNumber, NSDecimalAsNumber
The approach found by Ron prints the bits in correct order. The suggested replacement prints them backwards. Other correct solutions can be done without recursion, but require a char buffer that must either be reversed or printed in reverse order. Tom Wetmore On Nov 9, 2009, at 5:27 AM, Graham Cox wrote: On 09/11/2009, at 9:01 PM, Ron Fleckner wrote: void to_binary(int n) { int r; r = n % 2; if (n >= 2) to_binary(n / 2); putchar('0' + r); return; } The above sledgehammer-hammer-ammer-mmer-mer-er is not required to crack such a nut: voidto_binary( int n ) { do putchar(( n & 1 )? '1' : '0'); while( n >>= 1 ); } --Graham ___ 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/ttw4%40verizon.net This email sent to t...@verizon.net ___ 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: pointer to structure member reference?
Chuck, NSRange and NSSize are C structures, not Objective-C objects. The -> operator is the C operator used to access structure fields from a structure pointer. You can use dot notation if you like: (*aRange).location = 0; (*aSize).height = 4.0; But if you do so you are NOT using the new Objective-C dot notation, but only the "old" C dot notation. You should probably take a look at a C reference book to understand fully. Regards, Tom Wetmore On Nov 2, 2009, at 7:58 PM, Chunk 1978 wrote: having a bit of a time understanding this: -> i think it's used to point to a member of a supplied argument of the method? - (void)method:(NSRange *)aRange ofSize:(NSSize *)aSize { aRange->location = 0; aSize->height = 4.0; } is it not possible to use dot notation here? ___ 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/ttw4%40verizon.net This email sent to t...@verizon.net ___ 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: real verses Virtual memory
Please take this off list. Thanks, Tom Wetmore On Oct 10, 2009, at 3:28 PM, Shawn Erickson wrote: I meant to ask if you are accessing the HTTP or using WebKit's DOM API to get at the pages content? Basically how are using using WebView to access the data you need. -Shawn On Sat, Oct 10, 2009 at 12:25 PM, Shawn Erickson wrote: ___ 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: Hide an Item on Desktop
Dot files have been used by many program, for many years, in all UNIX based systems, for all kinds of reasons. To claim that they are "reserved for the system" is patently false. Just cd around your file system and try a few "ls -a" 's here and there. What has "being supported by the finder" go to do with anything? Tom Wetmore On Oct 8, 2009, at 9:18 PM, M Pulis wrote: On Oct 8, 2009, at 4:37 PM, I. Savant wrote: On Oct 8, 2009, at 7:24 PM, Maggie Zhang wrote: Does anyone know if it's possible to programmatically hide an single item (e.g. a file or a mounted disk or a directory) from the Desktop? Rename it so that it starts with a period. "Dot-files" are hidden. -- I.S. Please do not advise this hack. It is not supported by the Finder. dot files are hidden for a reason. The Finder does not show nor allow users to create "dot" files nor directories because they are reserved for the system. Unless you can absolutely prove that your file fits Apple specs for a legitimately installed "dot" system file that is not the best practice to make a non-system file invisible. Seek an alternative. There are temp directories and other legit facilities. Under prior Mac OS's, dot files were divers. You could trash a system by rebooting after saving a file with the name ".sony". Even if 10.6 doesn't barf, there is no guarantee that your unknown- to-Apple-and-you-were-warned-not-to-do-this dot file will not corrupt future systems or not be casually destroyed in the background as part of a system cleanup properly identifying (your) suspicious files as viral data. Be very careful. Gary ___ 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/ttw4%40verizon.net This email sent to t...@verizon.net ___ 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
NSOpenPanel Performance the Second Time
I use the following function to show an open panel and get the path to a file. I have inserted three NSLog calls. This first time I call this function the panel opens immediately and the three log messages follow each other immediately. The second and every later time I call this function, performance is terrible -- there is about two or three seconds between the first two log messages though the third follows immediately after the second. The evidence is that [NSOpenPanel openPanel] is the culprit. Is there something I need to do (i.e., close) to the open panel before I return from this function? I tried making the openPanel static and only creating it once, but this caused a crash. Thanks very much for any advice. Tom Wetmore // Use a NSOpenPanel to choose the name of a Gedcom file to read. //-- NSString* openFile (NSString* title) { NSLog(@"openFile called"); // TODO: Remove. NSOpenPanel* oPanel = [NSOpenPanel openPanel]; <--- PERFORMANCE SUFFERS HERE- NSLog(@"back from openening panel"); // TODO: Remove. [oPanel setCanChooseDirectories: NO]; [oPanel setCanChooseFiles: YES]; [oPanel setCanCreateDirectories: NO]; [oPanel setAllowsMultipleSelection: NO]; [oPanel setAlphaValue: 0.99]; [oPanel setTitle: title]; NSArray* fileTypes = [NSArray arrayWithObjects: @"txt", @"ged", @"gedcom", nil]; [oPanel setAllowedFileTypes: fileTypes]; NSLog(@"about to runModal"); // TODO: Remove if ([oPanel runModal] != NSOKButton) return @""; // Return the file name. NSArray* files = [oPanel filenames]; if ([files count] == 0) return @""; NSString* filePath = [files objectAtIndex:0]; return filePath; } ___ 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
Working with an Unsupported Character Encoding (ANSEL)
I am writing software to handle GEDCOM files. These files are usually in ASCII format, though some are in ANSEL format (the format they are supposed to be in), and in recent years more and more are in UNICODE encodings. A GEDCOM file is supposed to include an attribute that specifies its character set, but, as in HTML files, they are not always there, or if there, they are not always correct. And if they are in UNICODE the attribute does not specify the specific encoding. ANSEL is an 8-bit encoding where the lower half is ASCII and the upper half includes some non-spacing diacritics as well as a few specific Latin letter and diacritic combinations. There is no Cocoa/NSString/ CFString support for ANSEL that I have found. My current approach is to read the file using NSASCIIStringEncoding and to then determine the encoding of the file by scanning through it. I decided to do this since most files are indeed ASCII so in most cases no further I/O or character conversion is needed. While scanning the file I look for the attribute that specifies what the file should be, but I also do other checks. For example I check whether any of the upper half bytes are illegal ANSEL. And I check for UTF-8 multi-byte encodings. At the end I know whether the file is either valid ASCII, not ASCII but valid ANSEL, not ASCII or ANSET but vaild UTF-8, and if it's not valid as any of those three I assume it's UTF-16. If the file is UTF-8 or UTF-16 I can just reread it with the correct encoding. However, if it is ANSEL I must do some delicate fiddling to convert it to Unicode. I am relatively new to Cocoa and NSStrings, so this has lead to a few questions. 1. Apparently reading a file to an NSString using the NSASCIIStringEncoding returns each of the bytes of the file exactly as they were, that is, the 8-bit bytes seem to be read exactly as they were. So is it true that reading with NSASCIIStringEncoding doesn't mess around with any of the 8-bit bytes in the file? 2. Given I have an NSString that I read in as NSASCIIStringEncoding but I later determine it should have been read as UTF8 or UTF16, can I transform that NSString in place, or must I reread the file with the proper encoding? I don't mind doing the latter, but if there is conversion solution it would have better performance. 3. I'm imagining two ways to do the ANSEL to UNICODE transformation to get the NSString. a. Create a C-array of 16-bit shorts and convert the ANSEL to pure UNICODE. Is there an API to convert a such a C-array of 16-bit shorts to an NSString? b. Create a new NSString directly by building it up character by character. Would performance suffer greatly over the former approach? c. Is there an easier approach I am not seeing? Thanks very much for any advice. Tom Wetmore ___ 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
NSTabView Tutorial
I'm looking for a simple NSTabView tutorial. I've found references to the MultipleNIBTabView tutorial but I can't find it in the current Xcode Examples area or at the Developer site. Anyone know where it is located, or whether there is another tutorial around? Thanks, Tom Wetmore ___ 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
Confusion about Lablel Font Size: 13 or 10 ?
I am writing a genealogy program that provides a variety of forms for entering data from many sources, eg, censuses, marriage registers. Instead of custom designing user input panels for each type of record, I am using a specification file that describes the fields and tool tips needed for each form and then use a custom layout manager to layout a specific user interface panel/dialog for each form on the the fly. In writing this I have discovered that the font used in labels is LucidaGrande with a font size of 13. The value of labels is generally just an NSString which Aqua lays out in LucidaGrande/13. For the layout manager I must calculate the lengths of all the labels to be used on a given form so I can lay them all out together using Apple UI guidelines. To find the sizes of the label text I create an NSAttributedString for each one with the correct font and font size and then ask for the length of this attributed string. This all works and seems to be fine, but I have found something that bothers me a little bit. As mentioned I have discovered that the font size in labels (when created directly from Interface Builder) is 13. However, when using the NSFont method +(CGFloat)labelFontSize the value returned is 10. Before I discovered that the font size used in labels was 13 I was using the labelFontSize when setting up the attributed strings, so things didn't work. My question is. Why are labels rendered at 13 font when the NSFont method labelFontSize returns a value of 10? What deep dark secrets do I still have to learn? Tom Wetmore ___ 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