Post marked as unsolved
84
Views
Hi,
I am facing a strange issue in my app with iOS14 there is a intermittent crash.
_CFGetNonObjCTypeID - https://developer.apple.com/forums/content/attachment/076dfe1b-3d07-4fac-bb52-979c31bb62cb
_pthread_mutex_fairshare_unlock - https://developer.apple.com/forums/content/attachment/5d91dbe3-eb5d-4a79-94ce-ac868ff39cc4
_CFAssertMismatchedTypeID - https://developer.apple.com/forums/content/attachment/daec3951-5419-46da-963d-7b58215dcdff
Post marked as solved
113
Views
We define an event handler for OpenURL
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self
andSelector:@selector(handleGetURLEvent:withReplyEvent:)
forEventClass:kInternetEventClass andEventID:kAEGetURL];
And we handle it here:
(void)handleGetURLEvent:(NSAppleEventDescriptor *)event
withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
// Handler type stuff
}
If I'm debugging in Xcode, I see a SIGCONT before the handler is called. When I continue from the SIGCONT, I enter the handler and everything is fine.
This causes automated tests to break, and is generally a pain in the you-know-where. Outside of Xcode it's fine.
How can I make it stop doing this? Is there some Xcode setting I've overlooked?
Post marked as unsolved
114
Views
Hi,
[NSAttributedString initWithHTML:] fails when running natively on Apple Silicon, but doesn't fail when running on Intel.
In our app, it crashes with "EXC_BREAKPOINT (code=1, subcode=0x1bade08f4)" on this simple example (a unit test with our app as a host application):
(void)testExample {
NSString *string = @"a";
NSData *htmlData = [string dataUsingEncoding:NSUTF8StringEncoding];
NSAttributedString *htmlString = [[NSAttributedString alloc] initWithHTML: htmlData
options: @{
NSDocumentTypeDocumentOption: NSHTMLTextDocumentType,
NSCharacterEncodingDocumentOption: @(NSUTF8StringEncoding),
}
documentAttributes: nil];
XCTAssertNotNil(htmlString);
}
The last of the stack trace when this happens look like this:
thread #1, name = 'UI', queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1bade08f4)
frame #0: 0x00000001bade08f4 JavaScriptCore`void JSC::LinkBuffer::copyCompactAndLinkCodeunsigned int(JSC::MacroAssembler&, JSC::JITCompilationEffort) + 2784
frame #1: 0x00000001baddfd14 JavaScriptCore`JSC::LinkBuffer::linkCode(JSC::MacroAssembler&, JSC::JITCompilationEffort) + 60
frame #2: 0x00000001bb3e08f0 JavaScriptCore`JSC::nativeForGenerator(JSC::VM&, JSC::ThunkFunctionType, JSC::CodeSpecializationKind, JSC::ThunkEntryType) + 1856
frame #3: 0x00000001bb3cdc80 JavaScriptCore`JSC::JITThunks::ctiStub(JSC::VM&, JSC::MacroAssemblerCodeRef(***::PtrTag)3497 (*)(JSC::VM&)) + 140
frame #4: 0x00000001bb3cde50 JavaScriptCore`JSC::JITThunks::ctiInternalFunctionCall(JSC::VM&) + 36
frame #5: 0x00000001bb6e30b0 JavaScriptCore`JSC::VM::VM(JSC::VM::VMType, JSC::HeapType, ***::RunLoop*, bool*) + 14648
frame #6: 0x00000001bb6e3db0 JavaScriptCore`JSC::VM::create(JSC::HeapType, ***::RunLoop*) + 60
frame #7: 0x00000001bf09d81c WebCore`WebCore::PageScriptDebugServer::PageScriptDebugServer(WebCore::Page&) + 72
frame #8: 0x00000001bf07fb98 WebCore`WebCore::InspectorController::InspectorController(WebCore::Page&, WebCore::InspectorClient*) + 436
frame #9: 0x00000001bf266718 WebCore`WebCore::Page::Page(WebCore::PageConfiguration&&) + 360
frame #10: 0x00000001b913ae48 WebKitLegacy`-[WebView(WebPrivate) _commonInitializationWithFrameName:groupName:] + 2752
frame #11: 0x00000001b92547b8 WebKitLegacy`-[WebView(WebPrivate) _initWithFrame:frameName:groupName:] + 116
frame #12: 0x00000001a8f03568 UIFoundation`-[NSHTMLReader _loadUsingWebKit] + 824
frame #13: 0x00000001a8f02eec UIFoundation`-[NSHTMLReader attributedString] + 32
frame #14: 0x00000001a8eee0b8 UIFoundation`_NSReadAttributedStringFromURLOrData + 7072
frame #15: 0x00000001a8eec48c UIFoundation`-[NSAttributedString(NSAttributedStringUIFoundationAdditions) initWithData:options:documentAttributes:error:] + 156
* frame #16: 0x0000000113e4e860 Tests`-[CrashTests testExample](self=0x0000600002ba5e00, _cmd="testExample") at CrashTests.m:45:38
I am not seeing anything obvious we're doing wrong, or that there should be problems calling [NSAttributedString initWithHTML:] on Apple Silicon. I saw a mention somewhere that it has to happen on the main thread, and this is what we're doing, so I'm not sure why it would crash.
Any help wold be appreciated.
Post marked as unsolved
127
Views
My app processes numbers, and depends on the grouping separator on the system locale (Locale.current).
The user can set a completely custom symbol as their number separator in the macOS System Preferences.
In my tests, I need to verify that custom grouping separators on Locale objects work correctly. But I can't set a custom grouping separator as the groupingSeparator property on Locale is read-only:
/// For example, for "en_US", returns ",".
public var groupingSeparator: String? { get }
How do I create a Locale object for testing purposes, that will simulate a custom locale the user might have configured in the System Preferences?
Post marked as unsolved
261
Views
Please read the last thread: Call a Class into views - https://developer.apple.com/forums/thread/671482
The right code for the XML parser is almost set in stone, just I need a way to retrieve article data (not just through loadArticles()) like title, author, etc.
I've decided, and was suggested, that I go the same route as my other app, Lunch Card, where there's a function where you use a dataUrl and data to call ArticlesParser(). Thing is, since the code for the XML parser is a bit more complicated, it's harder to pass variables around just like with Lunch Card. There's another class I have to deal with. So I either have to (1) redefine articles the same way with an Array;
@Published var articles: [ArticleInfo] = []
...or (2), find some other way to call articles from the ObservableObject, maybe in a StateObject or ObservedObject.
I want to try and borrow as much code from Lunch Card as possible, but for an XML parser with multiple classes and extensions, it a bit easier said than done. Here's full code for ArticleInfo and ArticlesView.
ArticleInfo.swift - https://developer.apple.com/forums/content/attachment/d16688a9-f420-4dee-b1f4-ed255e325a3eArticlesView - https://developer.apple.com/forums/content/attachment/fbfb99f1-87a7-448b-ad04-54aef6abe61c
Not sure how ArticleInfo is an integer, so I have no idea what's going on or why it's not working as well. Also, I'm trying to experiment with borrowing the JSON decoder/encoder code, so tell me if that's the wrong way to go.
Post marked as unsolved
171
Views
Can you please give any advice on what to do next?
I saw that the app hangs on a remote session. But I don't know what process hangs the app.
I do realize that the proper way is to move everything except drawing to the BG queues. But I have a lot of legacy code. And my boss definitely isn't going to pay for overriding the whole app. And even then I can't guaranty the problem be solved.
Spindump:
End time:				 2021-01-29 15:58:32.475 +0100\
OS Version:			 macOS 11.1 (Build 20C69)\
Architecture:		 arm64e\
Report Version:	 32\
Share With Devs:	Yes\
\
Data Source:			Stackshots\
Shared Cache:		 64510D3B-D7B4-3C73-803C-AD9F01B790AD slid base address 0x18f298000, slide 0xf298000\
Shared Cache:		 E2B1A630-68DD-30AC-A036-6AC018B154DA slid base address 0x7fff20094000, slide 0x94000\
\
Command:					MyApp\
Path:						 /private/var/folders/*/MyApp.app/Contents/MacOS/MyApp\
Identifier:			 com.companyname.myappid\
Version:					7.3.1 (815)\
Parent:					 launchd [1]\
PID:							2264\
Time Since Fork:	464s\
Note:						 Translocated\
\
Event:						hang\
Duration:				 446.85s\
Duration Sampled: 4.70s (process was unresponsive for 442 seconds before sampling)\
Steps:						47 (100ms sampling interval)\
Report threshold: 2.5s\
\
Hardware model:	 MacBookAir10,1\
Active cpus:			8\
\
Time Awake Since Boot: 2536s\
Time Since Wake:	n/a (machine hasn't slept)\
\
\-------------------------------------------------\
Timeline format: stacks are sorted chronologically\
Use -i and -heavy to re-report with count sorting\-------------------------------------------------\
\
\
Heaviest stack for the main thread of the target process:\
	47	<truncated backtrace>\
	47	-[NSBundle initWithPath:] + 392 (Foundation + 15300) [0x1903a1bc4]\
	47	access + 8 (libsystem_kernel.dylib + 5952) [0x18f548740]\47	??? (kernel.release.t8101 + 30696) [0xfffffe0007c137e8]\
47	??? (kernel.release.t8101 + 1447416) [0xfffffe0007d6d5f8]\
47	??? (kernel.release.t8101 + 6596008) [0xfffffe00082565a8]\
47	??? (kernel.release.t8101 + 2786396) [0xfffffe0007eb445c]\
47	??? (kernel.release.t8101 + 2785876) [0xfffffe0007eb4254]\
47	kauth_authorize_action + 252 (kernel.release.t8101 + 5274992) [0xfffffe0008113d70]\
47	VnodeScopeListener + 1000 (AppleFileUtil + 51028) [0xfffffe0008b98754]\
47	Placeholders_Hydrate + 304 (AppleFileUtil + 54376) [0xfffffe0008b99468]\
47	_Placeholders_Hydrate_Wait_For_Completion + 284 (AppleFileUtil + 56540) [0xfffffe0008b99cdc]\
47	Tickets_WaitOnTicketResponse + 732 (AppleFileUtil + 10076) [0xfffffe0008b8e75c]\
47	Kernel_Cond_Wait + 64 (AppleFileUtil + 45928) [0xfffffe0008b97368]\
47	??? (kernel.release.t8101 + 5591856) [0xfffffe0008161330]\
47	lck_mtx_sleep_deadline + 132 (kernel.release.t8101 + 395372) [0xfffffe0007c6c86c]\
47	??? (kernel.release.t8101 + 462928) [0xfffffe0007c7d050]\
47	??? (kernel.release.t8101 + 468128) [0xfffffe0007c7e4a0]\
	Binary Images:\
					 0x1025ec000 -				0x102afbfff	com.companyname.myappid 7.3.1 (815)	<D7CFCE67-1556-322E-A82B-64604ECBB0E3>							/private/var/folders/*/MyApp.app/Contents/MacOS/MyApp\
					 0x18f547000 -				0x18f579fff	libsystem_kernel.dylib (7195.60.75)			<35BFD663-2C38-3E0F-A35E-8C1BC6400898>							/usr/lib/system/libsystem_kernel.dylib\
					 0x18f57a000 -				0x18f585fff	libsystem_pthread.dylib (454.60.1)			 <EDB716F3-BF94-3941-B7DA-D6C91094C645>							/usr/lib/system/libsystem_pthread.dylib\
					 0x18f5f8000 -				0x18faa1fff	com.apple.CoreFoundation 6.9 (1770.300)	<396F9604-7574-3C1B-ACA7-C7EB24FE3544>							/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation\
					 0x19039e000 -				0x19072ffff	com.apple.Foundation 6.9 (1770.300)			<5CEA7350-F274-39AE-9F27-D9813F2C3A76>							/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation\
					 0x191e10000 -				0x192b6efff	com.apple.AppKit 6.9 (2022.20.119)			 <78F21674-643E-3793-B1CD-C8BDBC76BAD5>							/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit\
	 *0xfffffe0007c0c000 - 0xfffffe00083f7fff	kernel.release.t8101 (7195.60.75)				<48F71DB3-6C91-3E62-9576-3A1DCEF2B536>__TEXT_EXEC	 /System/Library/Kernels/kernel.release.t8101\
	 *0xfffffe0008b8c000 - 0xfffffe0008b9ffff	com.apple.fileutil 20.036.15 (20.036.15) <73495C49-0EF7-3EA5-ADC9-0BD2D90305A0>__TEXT_EXEC	 /System/Library/Extensions/AppleFileUtil.kext/Contents/MacOS/AppleFileUtil\
	 *0xfffffe000a9d8000 - 0xfffffe000a9dffff	com.apple.kec.pthread 1.0 (1)						<EEB71141-5752-31E8-8495-2AF64D829A69>__TEXT_EXEC	 /System/Library/Extensions/pthread.kext/Contents/MacOS/pthread\
Post marked as unsolved
69
Views
Hi! I don't know why, but the date from formatter is nil.
let date1 = "22/05/1977"
let date2 = "01/06/1975"
let date3 = "26/05/1974"
let formatter = DateFormatter()
formatter.dateFormat = "dd/MM/yyyy"
let d1 = formatter.date(from: data1)
let d2 = formatter.date(from: data2)
let d3 = formatter.date(from: data3)
why d1, d2 and d3 will be nil ?
Post marked as solved
232
Views
Please read the last thread: Parse XML in SwiftUI - https://developer.apple.com/forums/thread/670984
I've got the code to parse articles from XML courtesy of OOPer...but I need to actually execute it in ArticlesView. How would I call ArticlesParser into ArticlesView and related views and run the parser onto an XML file (THS.xml)?
Here's ArticleInfo.swift and ArticlesView.
ArticleInfo.swift:
//
// ArticleInfo.swift
// Hair Society Go
//
// Created by Joshua Srery on 1/13/21.
// Code provided by OOPer on Apple Developer Forums
//
import Foundation
struct Article {
var title: String = ""
var date: Date?
var author: String?
var img: URL?
/// content in HTML
var content: String = ""
}
class ArticlesParser: XMLParser {
// Public property to hold the result
var articles: [Article] = []
var dateTimeZone = TimeZone(abbreviation: "GMT-6")
lazy var dateFormater: DateFormatter = {
let df = DateFormatter()
//Please set up this DateFormatter for the entry `date`
df.locale = Locale(identifier: "en_US_POSIX")
df.dateFormat = "MMM dd, yyyy"
df.timeZone = dateTimeZone
return df
}()
private var textBuffer: String = ""
private var nextArticle: Article? = nil
override init(data: Data) {
super.init(data: data)
self.delegate = self
}
}
extension ArticlesParser: XMLParserDelegate {
// Called when opening tag (`<elementName>`) is found
func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:]) {
switch elementName {
case "posts":
nextArticle = Article()
case "title":
textBuffer = ""
case "date":
textBuffer = ""
case "author":
textBuffer = ""
case "img":
textBuffer = ""
case "content":
textBuffer = ""
default:
print("Ignoring \(elementName)")
break
}
}
// Called when closing tag (`</elementName>`) is found
func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) {
switch elementName {
case "posts":
if let article = nextArticle {
articles.append(article)
}
case "title":
nextArticle?.title = textBuffer
case "date":
print("date: \(textBuffer)")
nextArticle?.date = dateFormater.date(from: textBuffer)
case "author":
nextArticle?.author = textBuffer
case "img":
print("img: \(textBuffer)")
nextArticle?.img = URL(string: textBuffer)
case "content":
nextArticle?.content = textBuffer
default:
print("Ignoring \(elementName)")
break
}
}
// Called when a character sequence is found
// This may be called multiple times in a single element
func parser(_ parser: XMLParser, foundCharacters string: String) {
textBuffer += string
}
// Called when a CDATA block is found
func parser(_ parser: XMLParser, foundCDATA CDATABlock: Data) {
guard let string = String(data: CDATABlock, encoding: .utf8) else {
print("CDATA contains non-textual data, ignored")
return
}
textBuffer += string
}
// For debugging
func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) {
print(parseError)
print("on:", parser.lineNumber, "at:", parser.columnNumber)
}
}
ArticlesView:
//
// ArticlesView.swift
// Hair Society Go
//
// Created by Joshua Srery on 11/29/20.
//
import SwiftUI
struct ArticlesView: View {
var body: some View {
NavigationView {
List {
ForEach(0 ..< 5) { item in
NavigationLink(destination: ArticleView(title: "Replace with Title var", image: "Replace with Img var", content: "Replace with Content var", author: "Replace with Author var", date: "Replace with Date var")) {
ArticleRow(image: "Replace with Img var", title: "Replace with Title var", author: "Replace with Author var", date: "Replace with Date var")
}
}
}
.navigationTitle("Articles")
.toolbar(content: {
Menu {
Button("Date", action: {})
Button("Title", action: {})
Button("Customize…", action: {})
} label: {
Label("Filter", systemImage: "line.horizontal.3.decrease.circle")
}
})
// Ignore the filter Menu for right now
}
}
}
struct ArticleRow: View {
let image: String
let title: String
let author: String
let date: String
var body: some View {
HStack {
Image(image)
.resizable()
.frame(minWidth: 75, maxWidth: 100, maxHeight: 75)
.cornerRadius(12)
VStack(alignment: .leading, content: {
Text(title)
.font(.headline)
Text("\(author) • \(date)")
.font(.subheadline)
})
}
}
}
Post marked as unsolved
1.2k
Views
Hi,
I am facing a strange issue in my app with iOS14 there is a intermittent crash, i am using NetServiceBrowser for MDNS discovery not sure if that is causing the problem crash log has below information:
Crashed: com.apple.main-thread
0 CoreFoundation 0x1a906c4c4 CFAssertMismatchedTypeID + 108
1 CoreFoundation 0x1a8f7db0c CFRunLoopSourceRemoveFromRunLoop + 298
2 CFNetwork 0x1a96255b0 CFNetServiceBrowserStopSearch + 460
3 CoreFoundation 0x1a8f81240 CFRUNLOOPISCALLINGOUTTOASOURCE0PERFORMFUNCTION + 24
4 CoreFoundation 0x1a8f81140 CFRunLoopDoSource0 + 204
5 CoreFoundation 0x1a8f80488 CFRunLoopDoSources0 + 256
6 CoreFoundation 0x1a8f7aa40 CFRunLoopRun + 776
7 CoreFoundation 0x1a8f7a200 CFRunLoopRunSpecific + 572
8 GraphicsServices 0x1bf075598 GSEventRunModal + 160
9 UIKitCore 0x1ab840004 -[UIApplication run] + 1052
10 UIKitCore 0x1ab8455d8 UIApplicationMain + 164
Post marked as unsolved
110
Views
Hello !
i have some issues for extract datas from an HTTP request, please can you help me ??
1)I send a request for asking the datas from a local device :
language
http://192.168.2.1/data/
2) below the device send this result in xml
language
?xml version="1.0" encoding="UTF-8" ?
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
head
titleIndex of /data/100CAMBX//title
/head
body
h2Index of /data/100CAMBX//h2
div class="list"
table summary="Directory Listing" cellpadding="0" cellspacing="0"
thead
tr
th class="n"Name/th
th class="m"Last Modified/th
th class="s"Size/th
th class="t"Type/th
/tr
/thead
tbody
tr class="d"
td class="n"
a href="../"Parent Directory/a//td
td class="m"&nbsp;/td
td class="s"- &nbsp;/td
td class="t"Directory/td
/tr
tr
td class="n"
a href="Video1.MOV"CMBX0007.MOV/a
/td
td class="m"2000-Jan-01 22:46:48/td
td class="s"1.5G/td
td class="t"video/quicktime/td
/tr
tr
td class="n"
a href="CMBX0009.MOV"CMBX0009.MOV/a
/td
td class="m"2000-Jan-13 08:28:24/td
td class="s"92.4M/td
td class="t"video/quicktime/td
/tr
tr
td class="n"
a href="CMBX0010.MOV"CMBX0010.MOV/a
/td
td class="m"2021-Mar-10 16:53:18/td
td class="s"1.8M/td
td class="t"video/quicktime/td
/tr
/tbody
/table
/div
div class="foot"lighttpd/1.4.41/div
/body
/html
3) i want to extract in this file theses 5 values integrate in the body
language
th class="n"Video1.MOV/th. //title of the video
th class="n"CMBX0007.MOV/th. // filename video
th class="m"2000-Jan-01 22:46:48/th //date&time
th class="s"1.5G/th // video size
th class="t"Type/th // video type
I need also to create an loop function for getting these 5 parameters for each videos files and store them in a structure.
everybody can help me please ?
Post marked as solved
218
Views
In my App I work with a "tree" structure (nested NSArrays and NSDictionaries) and have stored them in the file system using NSPropertyListSerialization, which always works fine.
In general loading the same structure via NSPropertyListSerialization works fine too, but if the "tree" is getting larger (nested deeper), NSPropertyListSerialization can no longer read the file (even if it was able to saved it without error before).
It will fail with the error "Too many nested arrays or dictionaries".
The issue seems to be the nesting level, not the general amount of nodes in the property list, because the file itself is very small (about 50 KB) .
I've never seen this in the past, so this might be a new issue of iOS 14.
So my question is: is there another way to read the propertylist file? The problem is that the file is stored in the binary format (not the plain XML format), so just using a general XML parser is not an option, the binary file format seems to be undocumented by Apple.
Post marked as solved
221
Views
Using the Combine URLSessionTask Publisher, is there a way to still access a reference to the URLSessionTask to set a delegate?
What I'm trying to do is collect network metrics by handling the delegate calls of URLSession did finish collecting metrics.
Post marked as solved
884
Views
hello,
i don't think it is provided by the system already so i'd like to implement a smart version of DispatchQueue.async function - the one that will not reschedule the block if i am already on the queue in question and call the block directly instead in this case.
extension DispatchQueue {
func asyncSmart(execute: @escaping () -> Void) {
if DispatchQueue.current === self { // ?????
execute()
} else {
async(execute: execute)
}
}
}
the immediate problem is that there is no way to get the current queue (in order to compare it with the queue parameter and do the logic branch).
anyone've been through it and solved this puzzle?
Post marked as unsolved
229
Views
Dear Team,
We are receiving the below crash from Crashlytics in recent times,
Could you please confirm on the reason behind and how that can be avoided
Fatal Exception: NSInvalidArgumentException[NSTaggedPointerString stringByReplacingCharactersInRange:withString:]: nil argument
0 CoreFoundation __exceptionPreprocess
1 libobjc.A.dylib objc_exception_throw
2 Foundation
[NSUserDefaults(NSUserDefaults_NSURLExtras) _web_defaultsDidChange]
3 TextInput[TIDocumentState(StateTransitions) documentStateAfterReplacingText:withText:]
40 UIKitCore
UIApplicationMain
41 main + 33
42 libdyld.dylib start
A quick help will be much appreciated.
Post marked as solved
158
Views
Hello everyone,
I have an app that lets users create and save meeting information. They can enter a date and set a repeat (like Apple's calendar app) if the meeting repeats every week, every month, every day, etc.
I'm storing these dates in CoreData using a date attribute. My questions are:
Can I store an array of dates in one date attribute in CoreData?
How should I create a repeating rule for the dates? Right now, I let users choose a repeat by using a picker:
Picker("Repeats", selection: $repeats) {
Text("Every week").tag("1")
Text("Every month").tag("2")
Text("Every day").tag("3")
}
I'm thinking this will probably involve a few if statements (e.g. if repeats == 1, set this rule, else if repeats == 2, set this rule, etc.)
But what would this rule look like?