Date   

Re: How to return data for NXSMLParserDelegate's -parser:resolveExternalEntityName:systemID:

Steve Mills
 

I also wonder (thanks to the lack of documentation) if I should be supplying some standard urls in the allowedExternalEntityURLs property of the NSXMLParser. Would that cause the parser to automatically resolve standard entities? If so, what urls would do that? I haven't been able to find them on sites like w3.org or w3schools.com.

--
Steve Mills
Drummer, Mac geek


Re: How to return data for NXSMLParserDelegate's -parser:resolveExternalEntityName:systemID:

Steve Mills
 

On Dec 11, 2019, at 10:25:45, Glenn L. Austin <glenn@austinsoft.com> wrote:

Have you tried returning a full XML entity, e.g. "<string>&#xa0</string>"?
Same error. Thanks for the suggestion.

--
Steve Mills
Drummer, Mac geek


Re: How to return data for NXSMLParserDelegate's -parser:resolveExternalEntityName:systemID:

Glenn L. Austin
 

On Dec 11, 2019, at 8:52 AM, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

What is the expected value of the returned NSData supposed to be for this method? The docs says "An NSData object that contains the resolution of the given external entity." To me, that means that for entity "nbsp", I should return "&#xa0" as:

[@"&#xa0" dataUsingEncoding:NSUTF8StringEncoding]

But the parser just stops parsing after that and never calls any delegate methods. The parser fails and has error:

The operation couldn't be completed. (NSXMLParserErrorDomain error 111.)

Of course, error 111 isn't listed in the NSXMLParserError enum. It's all so cryptic. Oh, but if I implement -parser:parseErrorOccurred:, that gives me error 26, NSXMLParserUndeclaredEntityError. Still, pretty cryptic when it comes to documenting what is expected of -parser:resolveExternalEntityName:systemID:

Can anyone decipher what Apple really means? I even tried just returning plain ol' unescaped text in the data, [@"x" dataUsingEncoding:NSUTF8StringEncoding] and got the same result.

--
Steve Mills
Drummer, Mac geek
Have you tried returning a full XML entity, e.g. "<string>&#xa0</string>"?

That would be my next experiment...

--
Glenn L. Austin, Computer Wizard and Race Car Driver <><
<http://www.austinsoft.com>


How to return data for NXSMLParserDelegate's -parser:resolveExternalEntityName:systemID:

Steve Mills
 

What is the expected value of the returned NSData supposed to be for this method? The docs says "An NSData object that contains the resolution of the given external entity." To me, that means that for entity "nbsp", I should return "&#xa0" as:

[@"&#xa0" dataUsingEncoding:NSUTF8StringEncoding]

But the parser just stops parsing after that and never calls any delegate methods. The parser fails and has error:

The operation couldn't be completed. (NSXMLParserErrorDomain error 111.)

Of course, error 111 isn't listed in the NSXMLParserError enum. It's all so cryptic. Oh, but if I implement -parser:parseErrorOccurred:, that gives me error 26, NSXMLParserUndeclaredEntityError. Still, pretty cryptic when it comes to documenting what is expected of -parser:resolveExternalEntityName:systemID:

Can anyone decipher what Apple really means? I even tried just returning plain ol' unescaped text in the data, [@"x" dataUsingEncoding:NSUTF8StringEncoding] and got the same result.

--
Steve Mills
Drummer, Mac geek


Re: Crash in Apple code, not mine - what can I do?

Jon Gotow
 

Ugh - I don't have a whole lot of experience with CoreData, but it does add a whole lot of possible failure modes. It's tough that you can't reproduce the issue locally - any chance the customer will send you one of their docs that causes the crash? That'd certainly make it easier.

On Dec 6, 2019, at 12:57 PM, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

Not on my machine. For the customer, he's been able to create and save docs before. But then they all start crashing at some point during save. The document uses CoreData, so much of it is a mystery. I'll see if he can use Console to maybe look for anything that CoreData might be puking out prior to the crash.


Re: Crash in Apple code, not mine - what can I do?

Steve Mills
 

On Dec 6, 2019, at 13:53:12, Jon Gotow <gotow@stclairsoft.com> wrote:

What's the actual cause of the crash? A segmentation fault (SIGSEGV) or some other memory error could be caused by you corrupting memory, handing NSDocumentController a bad object somehow, or some other application error. My experience with crashes in AppKit is that it's usually something I've done prior to the crash that has scrambled memory or corrupted an object.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00006db9f91b0e58
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [16005]

Is the problem reproducible so you can chase down possibilities?
Not on my machine. For the customer, he's been able to create and save docs before. But then they all start crashing at some point during save. The document uses CoreData, so much of it is a mystery. I'll see if he can use Console to maybe look for anything that CoreData might be puking out prior to the crash.

--
Steve Mills
Drummer, Mac geek


Re: Crash in Apple code, not mine - what can I do?

Jon Gotow
 

What's the actual cause of the crash? A segmentation fault (SIGSEGV) or some other memory error could be caused by you corrupting memory, handing NSDocumentController a bad object somehow, or some other application error. My experience with crashes in AppKit is that it's usually something I've done prior to the crash that has scrambled memory or corrupted an object. Is the problem reproducible so you can chase down possibilities?

- Jon

On Dec 6, 2019, at 12:46 PM, Steve Mills via Groups.Io <sjmills=mac.com@groups.io> wrote:

A customer sent a crashlog that clearly shows Apple's code is what's crashing on 10.14.6. There's no way I can reproduce it. So what can I do? Just submit a bug to Apple with the crashlog (although it's 10.14.6, so I doubt they care)?

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x00007fff6dc0269d objc_msgSend + 29
1 com.apple.AppKit 0x00007fff41034f8b -[NSDocument _silentlyRecoverableVariantOfSavingError:resaver:] + 40
2 com.apple.AppKit 0x00007fff415c7ce1 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke.856 + 620
3 com.apple.AppKit 0x00007fff415c9247 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_3.916 + 209
4 com.apple.AppKit 0x00007fff41068079 __62-[NSDocumentController(NSInternal) _onMainThreadInvokeWorker:]_block_invoke_3 + 152
5 com.apple.AppKit 0x00007fff4106a834 ___NSMainRunLoopPerformBlockInModes_block_invoke + 25
6 com.apple.CoreFoundation 0x00007fff434c4ec4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
7 com.apple.CoreFoundation 0x00007fff434885e7 __CFRunLoopDoBlocks + 394
8 com.apple.CoreFoundation 0x00007fff43487d06 __CFRunLoopRun + 1174
9 com.apple.CoreFoundation 0x00007fff4348761e CFRunLoopRunSpecific + 455
10 com.apple.HIToolbox 0x00007fff426e61ab RunCurrentEventLoopInMode + 292
11 com.apple.HIToolbox 0x00007fff426e5ee5 ReceiveNextEventCommon + 603
12 com.apple.HIToolbox 0x00007fff426e5c76 _BlockUntilNextEventMatchingListInModeWithFilter + 64
13 com.apple.AppKit 0x00007fff40a7e77d _DPSNextEvent + 1135
14 com.apple.AppKit 0x00007fff40a7d46b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
15 com.apple.AppKit 0x00007fff40a77588 -[NSApplication run] + 699
16 com.apple.AppKit 0x00007fff40a66ac8 NSApplicationMain + 777
17 libdyld.dylib 0x00007fff6f3de3d5 start + 1

--
Steve Mills
Drummer, Mac geek




Crash in Apple code, not mine - what can I do?

Steve Mills
 

A customer sent a crashlog that clearly shows Apple's code is what's crashing on 10.14.6. There's no way I can reproduce it. So what can I do? Just submit a bug to Apple with the crashlog (although it's 10.14.6, so I doubt they care)?

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libobjc.A.dylib 0x00007fff6dc0269d objc_msgSend + 29
1 com.apple.AppKit 0x00007fff41034f8b -[NSDocument _silentlyRecoverableVariantOfSavingError:resaver:] + 40
2 com.apple.AppKit 0x00007fff415c7ce1 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke.856 + 620
3 com.apple.AppKit 0x00007fff415c9247 __85-[NSDocument(NSDocumentSaving) _saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_3.916 + 209
4 com.apple.AppKit 0x00007fff41068079 __62-[NSDocumentController(NSInternal) _onMainThreadInvokeWorker:]_block_invoke_3 + 152
5 com.apple.AppKit 0x00007fff4106a834 ___NSMainRunLoopPerformBlockInModes_block_invoke + 25
6 com.apple.CoreFoundation 0x00007fff434c4ec4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
7 com.apple.CoreFoundation 0x00007fff434885e7 __CFRunLoopDoBlocks + 394
8 com.apple.CoreFoundation 0x00007fff43487d06 __CFRunLoopRun + 1174
9 com.apple.CoreFoundation 0x00007fff4348761e CFRunLoopRunSpecific + 455
10 com.apple.HIToolbox 0x00007fff426e61ab RunCurrentEventLoopInMode + 292
11 com.apple.HIToolbox 0x00007fff426e5ee5 ReceiveNextEventCommon + 603
12 com.apple.HIToolbox 0x00007fff426e5c76 _BlockUntilNextEventMatchingListInModeWithFilter + 64
13 com.apple.AppKit 0x00007fff40a7e77d _DPSNextEvent + 1135
14 com.apple.AppKit 0x00007fff40a7d46b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
15 com.apple.AppKit 0x00007fff40a77588 -[NSApplication run] + 699
16 com.apple.AppKit 0x00007fff40a66ac8 NSApplicationMain + 777
17 libdyld.dylib 0x00007fff6f3de3d5 start + 1

--
Steve Mills
Drummer, Mac geek


Playing a sequence of notes with AVAudioSourceNode

Steve Mills
 

Is it possible to set up an AVAudioEngine and friends so I could feed it a sequence of MIDI notes and have it play that sequence, using an AVAudioSourceNode as the sound source? The AVAudioSourceNode is just using a render block to produce a sine wave of a given pitch. Apple doesn't seem to have any sample code for AVFoundation that I could find, and all the examples I see online are too simplified (load a midi file and sound bank file, play it).

I've gotten as far as loading a short midi file as a test, but get an error that there's no AU connected to the track, and I can't figure out how to make that happen. But ideally, I'd like to generate the midi on the fly and feed the notes into an AVAudioSequencer (I think).

--
Steve Mills
Drummer, Mac geek


Re: Parsing Javascript simply

Sandor Szatmari
 

We use a WebView/WKWebView for accessing web page DOMs using xPath queries.  We used to be able to even interact with Java Applets, but security improvements have killed that functionality after 10.6.  And Applets are a dead technology for the most part.    We still support 10.6 to interact with legacy web pages.  Please, I hope they go away!  But a great deal can still be accomplished this way.  Using the delegates will let you know when the page loads are complete and the DOM is in it’s final state.  Make sure to query after that to ensure the javascript is loaded/interpreted.

Sandor

On Dec 3, 2019, at 17:48, Graham Cox <graham@...> wrote:

Thanks - indeed simple to try, but unfortunately doesn’t work in this case.

I’ll try loading it into an off-screen WKWebView.

—Graham



On 3 Dec 2019, at 12:47 pm, Quincey Morris <quinceymorris@...> wrote:

I tried something similar recently, and got better-than-anticipated results using this NSAttributedString initializer:


IIRC, this gave me an attributed string with (Javascript-generated) links embedded, so you might have to scan for ”a” tags instead of “video” tags. I dunno, it might not work for you, but it should be simple to try.



Re: Parsing Javascript simply

Graham Cox
 

Thanks - indeed simple to try, but unfortunately doesn’t work in this case.

I’ll try loading it into an off-screen WKWebView.

—Graham



On 3 Dec 2019, at 12:47 pm, Quincey Morris <quinceymorris@...> wrote:

I tried something similar recently, and got better-than-anticipated results using this NSAttributedString initializer:


IIRC, this gave me an attributed string with (Javascript-generated) links embedded, so you might have to scan for ”a” tags instead of “video” tags. I dunno, it might not work for you, but it should be simple to try.



Re: Parsing Javascript simply

Sandor Szatmari
 

Did you try loading the page in a WebView? Then you should be able to traverse the DOM.

Sandor

On Dec 2, 2019, at 20:36, Graham Cox <graham@mapdiva.com> wrote:

Hi all,

I made an app that scrapes web pages looking for a specific tag - namely, the <video> tag to get the address of a video stream. If you display the page in e.g Safari, the video portion can be right-clicked and it gives you a “Copy Video Address” menu that extracts the URL. My app is intended to obtain that same URL.

On some sites, the video address is generated by some obfuscating Javascript rather than simply embedded in the HTML of the page. Nevertheless once displayed, Safari still allows you to manually copy the video stream’s URL, so the obfuscation doesn’t provide any real security - it just makes my page scraping effort more difficult.

My question is, is there a way to run the Javascript using some built-in classes to get the final page rendering, so that the video address can be obtained? I don’t want to write my own Javascript parser, that’s crazy. Besides, I don’t know Javascript very well, so I’d rather just leave it to some existing code, then make use of its output. Is this possible, or what strategy can I use?

—Graham





Re: Parsing Javascript simply

Quincey Morris
 

On Dec 2, 2019, at 17:35 , Graham Cox <graham@...> wrote:

My question is, is there a way to run the Javascript using some built-in classes to get the final page rendering, so that the video address can be obtained? I don’t want to write my own Javascript parser, that’s crazy. Besides, I don’t know Javascript very well, so I’d rather just leave it to some existing code, then make use of its output. Is this possible, or what strategy can I use?

I tried something similar recently, and got better-than-anticipated results using this NSAttributedString initializer:


IIRC, this gave me an attributed string with (Javascript-generated) links embedded, so you might have to scan for ”a” tags instead of “video” tags. I dunno, it might not work for you, but it should be simple to try.


Parsing Javascript simply

Graham Cox
 

Hi all,

I made an app that scrapes web pages looking for a specific tag - namely, the <video> tag to get the address of a video stream. If you display the page in e.g Safari, the video portion can be right-clicked and it gives you a “Copy Video Address” menu that extracts the URL. My app is intended to obtain that same URL.

On some sites, the video address is generated by some obfuscating Javascript rather than simply embedded in the HTML of the page. Nevertheless once displayed, Safari still allows you to manually copy the video stream’s URL, so the obfuscation doesn’t provide any real security - it just makes my page scraping effort more difficult.

My question is, is there a way to run the Javascript using some built-in classes to get the final page rendering, so that the video address can be obtained? I don’t want to write my own Javascript parser, that’s crazy. Besides, I don’t know Javascript very well, so I’d rather just leave it to some existing code, then make use of its output. Is this possible, or what strategy can I use?

—Graham


Re: Advice on implementing a URL Text Field

Gary L. Wade
 

Have you turned on the data detectors options available in text views? That might be enough unless you’re seeing something it doesn’t give you.
--
Gary L. Wade
http://www.garywade.com/

On Nov 28, 2019, at 8:14 AM, Rick Aurbach via Groups.Io <rlaurb@...> wrote:

I am looking for some advice and/or suggestions on implementing an iOS text field with the following properties:
  • The user can enter text into the field easily (via keyboard, pasting, etc).
  • If the contents of the field is a URL, then a tap in the field will be recognized as a request to open that URL 
  • BUT, even so, the user should still have a way to edit that URL text.
I was thinking about something like:
  • A tap in an empty field (or a field containing text which is not a structurally-valid URL) means editing.
  • A tap in a field containing a structurally-valid URL means "open URL"
  • A long-press in a field containing a structurally-valid URL means editing.
But I'm not particularly wedded to this idea (particularly if you have a better one!)

If you've tried to deal with an issue like this, I'd love to hear from you. (And if you have some code to share...)

Thank you. And for everyone in the US, Happy Thanksgiving.

Rick Aurbach


Advice on implementing a URL Text Field

Rick Aurbach
 

I am looking for some advice and/or suggestions on implementing an iOS text field with the following properties:
  • The user can enter text into the field easily (via keyboard, pasting, etc).
  • If the contents of the field is a URL, then a tap in the field will be recognized as a request to open that URL 
  • BUT, even so, the user should still have a way to edit that URL text.
I was thinking about something like:
  • A tap in an empty field (or a field containing text which is not a structurally-valid URL) means editing.
  • A tap in a field containing a structurally-valid URL means "open URL"
  • A long-press in a field containing a structurally-valid URL means editing.
But I'm not particularly wedded to this idea (particularly if you have a better one!)

If you've tried to deal with an issue like this, I'd love to hear from you. (And if you have some code to share...)

Thank you. And for everyone in the US, Happy Thanksgiving.

Rick Aurbach


Re: NSAttributedString + NSLayoutManager versus Core Text

Gary L. Wade
 

I haven’t done this with CoreText personally, but you need to traverse the runs yourself to know where the characters are rather than rely on callbacks.  What code do you use for the CoreText solution?

On Nov 22, 2019, at 5:28 PM, Graham Cox <graham@...> wrote:

Still, if anyone’s in the mood to offer a Core Text solution to this overall problem, I’d be happy to hear it.



Re: Weird crash with Mojave, no crash on High Sierra

Alex Zavatone
 

I trust it is a Mac app?

What is the crash log?

On Nov 9, 2019, at 7:37 AM, Markus Ruggiero <mailinglists@kataputt.com> wrote:

Way back when I dabbled around with ObjC (that was in 2002!) I created a small app that shows images from disk. About a year ago I upgraded this app to 64bit and ARC. This went well after a bit of flapping on my side because of deprecation warnings and things. But hey, it functioned and I built the app and it ran well. Btw this has been my only atempt at Cocoa programming since, so I am not a guru at all here).

Recently I upgraded from High Sierra to Mojave and my little app still runs - but it crashes somewhere deep inside Cocoa after the (only) window is closed. Why? I do have that crash consistently but it seems not to happen at the same place all the time. It happens to the built app as well as the app running within Xcode under debugger control. Unfortunately I have no idea how to debug this as my window has been closed and removed and only the menu bar should remain, ready to create a new window. There seems nothing of my code to be involved here

I did hear from a colleague that he has apps (not written by himself) that show the exact same behavior: running fine but crashing when the last window is closed. Is this something known? Anyone has an idea what could be the cause and how to prevent it?

Thanks a lot
---markus---


Re: Weird crash with Mojave, no crash on High Sierra

Markus Ruggiero
 

Thanks a lot, seems to have cured things. I added a line to set the window delegate to nil before [myWindow close] and things are ok now.

---markus---

On 23 Nov 2019, at 19:50, Quincey Morris <quinceymorris@...> wrote:

On Nov 22, 2019, at 13:50 , Markus Ruggiero <mailinglists@...> wrote:

Anyway hopefully someone can make some sense of this.

There’s not really enough information here to really solve the problem. The overall “feel” of the crash is a memory management problem related to the various objects used alongside a NSWindow. It is more than possible that you’ve had the problem all along, and you’ve just been unlucky this hasn’t crashed earlier. It’s presumably crashing now because the timing of various parts of app termination changed, and that’s exposing the long-standing bug.

At the top of your backtrace is this:

0   com.apple.AppKit               0x00007fff3c3cbbd6 -[NSWindow(NSFullScreen) _didExitFullScreen] + 48

My guess is that AppKit is about to invoke the corresponding window delegate method:


but your window delegate (probably a NSWindowController) has already been deallocated.

This sort of thing is really hard to debug and fix. The easiest thing to try is to make sure your window controller sets its window’s “delegate” property to nil before it deallocates. If you’re lucky, that will solve it. If not, that might just push the crash to a different place.




Re: manual item enabling

Graham Cox
 

Kurt,

The menu key equivalents are pulled out before -keyDown: is called. You can override that event in -performKeyEquivalent:, a methof of NSResponder (and therefore views, etc). You can probably call your menu update method and then call super to handle the key equivalent.

I recall the menu update mechanism from TCL very well, and I don’t think it’s a terrible way to do it, but certainly it’s a little different in Cocoa. You might find that converting your code to use -validateMenuItem: is not as bad as you’d think though, it’s broadly similar to the TCL way, just you get each menu item passed in turn, rather than the whole menu. But the code in that method deals with all of the menu items applicable to the receiving object, just like the TCL way does, and then punts any others to the next responder.

—Graham

On 25 Nov 2019, at 8:28 am, Kurt Bigler via Cocoa-dev <cocoa-dev@lists.apple.com> wrote:

The last possible moment for key equivalents is a keyDown event. Unfortunately Cocoa doesn't seem to let me catch this event and act on it to update menus prior to key equivalent processing.

-Kurt Bigler
_______________________________________________

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/graham.cox%40bigpond.com

This email sent to graham.cox@bigpond.com

301 - 320 of 1425