NSStackView layout issues
Hello Cocoaphiles, ;) I've just started experimenting with NSStackView, and I'm having a very interesting problem which I can't solve. I've scoured the auto layout guides on Apple's website as well as the NSStackViewdocumentation, and can't seem to find anything. My problem is that I have two identical NSScrollView objects (each with an embedded NSTextView) which are loaded from nib files. When I add these views to my stack view, the one that is added first takes up 100% of the available space, and the second collapses completely down to the bottom with a height of 2 pixels while taking up all available horizontal space. In effect, this looks like the first view is the only one in the window. Here's what it currently looks like: http://i.stack.imgur.com/2tEwm.png It's nearly impossible to see in this example because of the background color, but the scroll view ends a couple pixels above the bottom of the window. Here's a better view from the view hierarchy inspector, where I have this 2 pixel high view selected: http://i.stack.imgur.com/XJeG5.png Here's the relevant setup code: // Load the stack view self.inputViewController = [[NSViewController alloc] initWithNibName:@Document_TextInputView bundle:nil]; self.textView = (NSTextView *)[[(NSScrollView *)self.inputViewController.view contentView] documentView]; self.outputViewController = [[NSViewController alloc] initWithNibName:@Document_TextOutputView bundle:nil]; self.outputView = (NSTextView *)[[(NSScrollView *)self.outputViewController.view contentView] documentView]; // Add all views into the stack view [self.stackView addView:self.inputViewController.view inGravity:NSStackViewGravityTop]; [self.stackView addView:self.outputViewController.view inGravity:NSStackViewGravityBottom]; self.stackView.orientation = NSUserInterfaceLayoutOrientationVertical; // Load the text into the window. [self.textView setString:self.cachedText]; [self.outputView setString:@=== PROGRAM OUTPUT ===\n]; [self.codeActionSegmentedControl setEnabled:NO forSegment:1]; From what I understand, the intrinsic content size should prohibit the view from getting shrunk this small. I'm not too familiar with NSStackView, so any help would be appreciated. Thanks a lot, — SevenBits signature.asc Description: Message signed with OpenPGP using GPGMail ___ 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
Trouble getting ISO-8859-1 encoded feed to parse and display
Hi list, I am having trouble getting useful data from this url on some, but not all, iOS devices: https://www.taxpublications.deloitte.co.uk/tis/dtp.nsf/pub1.xml The feed has this opening tag: ?xml version=1.0 encoding=ISO-8859-1 ? When I just pull in the feed’s contents using a NSURLConnection, it will show up on some, but not all, devices. When I try to log the response data, by creating a string that I init with the downloaded data and NSUTF8StringEncoding, the log will show a null string. So putting the downloaded data into a string using UTF8 doesn’t work. NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSUTF8StringEncoding]; Still, in that case, some devices will show the parsed feed, some won’t. I tried converting the data into NSISOLatin1 and then putting it back into NSData using UTF8, as below, but that doesn’t help. -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSISOLatin1StringEncoding]; [self setDataContainer:[[dataString dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]]; self.xmlItems = [NSMutableArray array]; NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.dataContainer]; [parser setDelegate:self]; [parser parse]; } I validated the feed’s XML and got no errors.. Anybody out there with experience in solving this? Many thanks! Diederik ___ 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: Binding a unique-selection checkbox in a table view?
The code posted by Lee Ann Rucker is good. It implements the ‘activeJob’ in the data model as I recommended. Your “data model” can include whatever classes you need to model your data, not just Job objects. Lee Ann is proposing that your data model also contain a single instance of a DataModel (rename as you like) class, which keeps track of the ‘activeJob’. You will probably find other nifty uses for it in the future. It’s a subtle difference and a subtle change. To correct the smell, you just factor the activeJob property out of your AppDelegate, which is part of your controller layer, and move it into this new DataModel (or whatever) single object instance. This new class is part of your data model, because you say it is, and because it does not do any controller functions, as your app delegate certainly does. It does require a little code to (1) initially create your single DataModel object and (2) for robustness, check for and re-create one if it ever disappears. For a document-based application, you would typically do (1) in -[NSDocument initWithType:error:], because this method runs only for new documents, and do (2) in -readFromData/URL/FileWrapper:ofType:error:. ___ 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: Trouble getting ISO-8859-1 encoded feed to parse and display
First, be sure the content in the XML document you're getting back matches the encoding in the header. If it doesn't and you have no control over the creation of it, you'll have to figure out the character set yourself. There's also some methods in NSString that will try to figure out that for you and return that. Secondly, ISO-8859-1 and UTF-8 are not equivalent. -- Gary L. Wade (Sent from my iPad) http://www.garywade.com/ On Nov 23, 2014, at 1:06 PM, Diederik Meijer | Ten Horses diede...@tenhorses.com wrote: Hi list, I am having trouble getting useful data from this url on some, but not all, iOS devices: https://www.taxpublications.deloitte.co.uk/tis/dtp.nsf/pub1.xml The feed has this opening tag: ?xml version=1.0 encoding=ISO-8859-1 ? When I just pull in the feed’s contents using a NSURLConnection, it will show up on some, but not all, devices. When I try to log the response data, by creating a string that I init with the downloaded data and NSUTF8StringEncoding, the log will show a null string. So putting the downloaded data into a string using UTF8 doesn’t work. NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSUTF8StringEncoding]; Still, in that case, some devices will show the parsed feed, some won’t. I tried converting the data into NSISOLatin1 and then putting it back into NSData using UTF8, as below, but that doesn’t help. -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSISOLatin1StringEncoding]; [self setDataContainer:[[dataString dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]]; self.xmlItems = [NSMutableArray array]; NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.dataContainer]; [parser setDelegate:self]; [parser parse]; } I validated the feed’s XML and got no errors.. Anybody out there with experience in solving this? Many thanks! Diederik ___ 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/garywade%40desisoftsystems.com This email sent to garyw...@desisoftsystems.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
Unexpected extra change notification in 10.10
In my document-based app I'm seeing the following which does not occur on 10.9 or earlier. I create a new document, dirty it by adding some content, then manually save it as a new file. The document's -updateChangeCount: method is called with a change of NSChangeDone. The stack trace shows: #0 0x0001000ad278 in -[GCOrteliusDocument updateChangeCount:] at /Users/grahamcox/Projects/Artboard/Artboard/Source/Code/GCOrteliusDocument.m:1633 #1 0x7fff8252f610 in __52-[NSDocument _checkAutosavingThenUpdateChangeCount:]_block_invoke_3 () #2 0x7fff8252edfb in -[NSDocument _checkAutosavingThenContinue:] () #3 0x7fff8252f4c2 in __52-[NSDocument _checkAutosavingThenUpdateChangeCount:]_block_invoke_2 () #4 0x7fff8bcdf54c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ () #5 0x7fff8bcd1655 in __CFRunLoopDoBlocks () #6 0x7fff8bcd0e0e in __CFRunLoopRun () #7 0x7fff8bcd0838 in CFRunLoopRunSpecific () #8 0x7fff8623143f in RunCurrentEventLoopInMode () #9 0x7fff862311ba in ReceiveNextEventCommon () #10 0x7fff86230ffb in _BlockUntilNextEventMatchingListInModeWithFilter () #11 0x7fff820e4821 in _DPSNextEvent () #12 0x7fff820e3fd0 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #13 0x7fff820d7f73 in -[NSApplication run] () #14 0x7fff820c3424 in NSApplicationMain () This causes the document to be flagged as dirty, prompting the Save changes? dialog when it's closed (if that is enabled). Subsequent saves don't trigger this notification, nor does saving the first time if it replaces an existing file on disk, only if it's a completely new file. I have autosaving enabled for this document. Has anyone else noticed this? It doesn't seem as if I'm doing anything wrong as we're not seeing this except on 10.10 --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: Unexpected extra change notification in 10.10
On 2014 Nov 23, at 19:44, Graham Cox graham@bigpond.com wrote: In my document-based app I'm seeing the following which does not occur on 10.9 or earlier. I create a new document, dirty it by adding some content, then manually save it as a new file. The document's -updateChangeCount: method is called with a change of NSChangeDone. To clarify the issue: -updateChangeCount: is called, as expected, when you dirty the document. It is called again when you save the document, apparently just after you save the document, because This causes the document to be flagged as dirty, prompting the Save changes? dialog when it's closed (if that is enabled). It is the second call to -updateChangeCount:, which occurs during/after the save, that is the issue. Have I understood correctly? Has anyone else noticed this? I just checked this in one of my NSPersistentDocument apps. -updateChangeCount does *not* get called during a save operation. My answer is “no”. It doesn't seem as if I'm doing anything wrong as we're not seeing this except on 10.10 See if it’s putting an action on the undo stack. If that is too opaque, which it will probably will be if app is Core Data, consider the Dave Fernandes Override -willChangeValueForKey: Trick: #if 0 #warning overrode willChangeValueForKey. Do not ship this. /*! @briefIn a Core Data document-based application, you often have the problem of the close button getting a dirty dot immediately after a new document is created or an old one loaded, or you just want to know what the hell is happening when you click Undo and nothing happens. Paste this code into the NSManagedObject subclass that you suspect may be changing, or even better, if you have a NSManagedObject parent class for all your subclasses paste it in there. Activate the #if above, compile, and run your app so that the dot gets dirty. Then click Undo until the dot becomes clean as you watch the console. Any changes to your model will be logged. @details Thanks to Dave Fernandes for this idea! */ - (void)willChangeValueForKey:(NSString*)key { NSUndoManager* um = [[self managedObjectContext] undoManager] ; // Todo: Since NSUndoManager is not thread-safe, should create // an NSInvocation here and invoke these next two on main thread: BOOL isUndoing = [um isUndoing] ; BOOL isRedoing = [um isRedoing] ; if (isUndoing || isRedoing) { NSLog(@%@ %@did changed value for key: %@, [[self entity] name], isUndoing ? @un : @re, key) ; // Optional: Put a breakpoint here and debug to see what caused it ; } [super willChangeValueForKey:key]; } #endif ___ 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: Trouble getting ISO-8859-1 encoded feed to parse and display
On Nov 23, 2014, at 11:06 AM, Diederik Meijer | Ten Horses diede...@tenhorses.com wrote: I am having trouble getting useful data from this url on some, but not all, iOS devices:https://www.taxpublications.deloitte.co.uk/tis/dtp.nsf/pub1.xml The feed has this opening tag: ?xml version=1.0 encoding=ISO-8859-1 ? When I just pull in the feed’s contents using a NSURLConnection, it will show up on some, but not all, devices. When I try to log the response data, by creating a string that I init with the downloaded data and NSUTF8StringEncoding, the log will show a null string. So putting the downloaded data into a string using UTF8 doesn’t work. NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSUTF8StringEncoding]; The above code is wrong in your case. The second parameter must be the encoding that the characters are currently in, not the encoding you want NSString is--at least outwardly--encoding-agnostic. It doesn't care what you feed into it, it will always spit out UTF8 unless you specify otherwise. Still, in that case, some devices will show the parsed feed, some won’t. Separating the erros in your debugging attempts vs what might actually be happening is more useful at the moment. I tried converting the data into NSISOLatin1 and then putting it back into NSData using UTF8, as below, but that doesn’t help. This would be entirely pointless, as the XML parser shouldn't care what character encoding is used, as long as it is declared. UTF8 is magical for the parser. -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *dataString = [[NSString alloc] initWithData:self.dataContainer encoding:NSISOLatin1StringEncoding]; This line is the proper way to convert the data into a string. You can then NSLog() with impunity. I would also include the data length, just to make sure that a nil result is not due to empty or nil data. [self setDataContainer:[[dataString dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]]; self.xmlItems = [NSMutableArray array]; NSXMLParser *parser = [[NSXMLParser alloc] initWithData:self.dataContainer]; [parser setDelegate:self]; [parser parse]; } I validated the feed’s XML and got no errors.. HTH, Keary Suska Esoteritech, Inc. ___ 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: Trouble getting ISO-8859-1 encoded feed to parse and display
On Nov 23, 2014, at 1:06 PM, Diederik Meijer | Ten Horses diede...@tenhorses.com wrote: When I just pull in the feed’s contents using a NSURLConnection, it will show up on some, but not all, devices. What does show up mean in this case? Is there an error? If so, what is it? When I try to log the response data, by creating a string that I init with the downloaded data and NSUTF8StringEncoding, the log will show a null string. So putting the downloaded data into a string using UTF8 doesn’t work. UTF-8 is a completely different encoding. I validated the feed’s XML and got no errors.. It's valid XML, but it's got some problems as an RSS feed; take a look at http://feedvalidator.org/check.cgi?url=https%3A%2F%2Fwww.taxpublications.deloitte.co.uk%2Ftis%2Fdtp.nsf%2Fpub1.xml http://feedvalidator.org/check.cgi?url=https://www.taxpublications.deloitte.co.uk/tis/dtp.nsf/pub1.xml These are mostly minor, like nonstandard extra elements, but it's also got problems with its date formatting, and also the server reports the Content-Type is ASCII while the XML says it's ISO-8859-1. If NSXMLParser is having trouble with the encoding, one problem I've seen before is documents that claim to be ISO-8859-1 while actually being WinLatin, which is a superset with extra characters defined. (The Cocoa encoding name for this is NSWindowsCP1252StringEncoding, IIRC.) (I spent four years of my life immersed in RSS feed parsing, and acquired a solid contempt for the ability of the average web developer to construct a valid feed. You would not believe how many messed-up feeds there are in the real world.) —Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
codesign v2 problem on 10.8.5 and earlier
Hi, switched to codesign v2 to match the new requirements on 10.9.5 and 10.10. The sign works well on 10.9.5 and later, but on 10.8.5 (with the latest security update installed) the verify process (codesign —verify —deep —verbose=2 …) reports “bundle format unrecognized, invalid or unsuitable”, which results Gatekeeper reporting the “.app has been damaged, you should move it to the Trash”. If I don’t miss something, codesign v2 should be compatible with 10.8.5 and earlier. Anyone ran into the same issue? What did I miss? Thank you! Tamas ___ 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