Posts

Post not yet marked as solved
33 Replies
5.3k Views
I'm looping through all pages in a PDFDocument (300+ pages) but app crashes with> Message from debugger: Terminated due to memory issueThe pdf is approx 4mb in size yet each iteration of the loop jumps the memory up approx 30mb. That memory is never reclaimed because the loop ends i get the crash.@objc func scrapePDF(){ let documentURL = self.documentDisplayWebView!.url! let document = PDFDocument(url: documentURL) let numberOfPages = document!.pageCount DispatchQueue.global().async { for pageNumber in 1...numberOfPages { print(document?.page(at: pageNumber)!.string!) } } }I found that rather than passing a reference to the `PDFDocument` inside the loop, if instead I create a new instance for each loop this strangely solves the memory issue. I don't quite understand why though. `PDFDocument` is a Class not a Struct so is passed by reference. Meaning it is only created once and then referenced to inside my loop. So why would it cause a memory issue?@objc func scrapePDF(){ let documentURL = self.documentDisplayWebView!.url! let document = PDFDocument(url: documentURL) let numberOfPages = document!.pageCount DispatchQueue.global().async { for pageNumber in 1...numberOfPages { let doc = PDFDocument(url: documentURL) print(doc?.page(at: pageNumber)!.string!) } } }Though the above code clears the memory issue the problem with it is that its too slow. Each loop takes 0.5 seconds and with 300+ pages I can't accept that. Any tips on speeding it up? Or why it doesn't give the memory back if referencing the `PDFDocument` from outside the loophave tried autoreleasepool{} no effect
Posted
by RyanTCB.
Last updated
.
Post marked as solved
1 Replies
372 Views
Trying to build remote push notifications into an iOS application I discover that in order to send them my domain host needs to open port 2195. They won't. So Ive come here hoping to get a list of suggested webhosts that do open port 2195. ( I know I can use 3rd party like UrbanAirship im not asking about those)Please reply with a host that you use that opens this port for APNS.
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
1 Replies
1.7k Views
Trying to validate an archive build with Xcode 9. For some reason Xcode is converting one of my `.swift` files to a `.o` file. This causes the validation to fail.> Invalid Bundle Structure - The binary file 'MYAPPNAME.app/TCBConnection.o' is not permitted. Your app can’t contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure for information on the iOS app bundle structure.The file xcode complains as `TCBConnection.o`is in fact `TCBConnection.swift`.The contents of the `TCBConnection.swift` (shown) file is a wrapper for a Apples `Reachability.h/.m` Class.// // TCBConnection.swift // // Created by TCB-iMAC on 24/11/2016. // Copyright © 2016 TCB-iMAC. All rights reserved. // import UIKit class TCBConnection: NSObject { @objc class func isConnectedToInternet() -> Bool { if (Reachability.forInternetConnection().currentReachabilityStatus() == NetworkStatus.NotReachable){ UIApplication.shared.keyWindow?.rootViewController?.present(Reachability.showNoNetworkUIAlertController(), animated: true, completion: { }) return false } return true } }I have a bridging header file for the `Reachability.h` in my project.Testing and running the project on a device or simulator all works fine. However for some reason I can not validate the archive as Xcode changes the `.swift` file to a `.o` file.Why is this and how I can fix it?
Posted
by RyanTCB.
Last updated
.
Post marked as solved
2 Replies
1.2k Views
In the latest beta (6) of xcode 9 and iOS 11 I can no longer access UIColors from the .xcassets folder with UIColor(named: )Application crashes with no useful output in thr debugger to suggest whyAnyone else having this issue?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
2 Replies
1.5k Views
I have an .xcassets folder containing Colours. The target membership of the folder is same as my project. As are all the colours inside the folder.In code I access with UIColor(named:)var colour = UIColor(named: "<#a colour that exists with this name#>")but I get aThread 1: EXC_BAD_ACCESS (code=1, address=0x8)I am having same uses trying to access images from a separate .xcassets folder.Colours and Images exist yet Xcode crashes.Its as if the colours and images don't exist but they do.I have tried removing and re-adding the colours and images buts same useless error each time.included the backtrace> (lldb) bt> * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)> frame #0: 0x000000018c3510f0 CoreUI`-[CUINamedColor cgColor] + 88> frame #1: 0x000000018ed957d8 UIKit`-[_UIAssetManager colorNamed:withTraitCollection:] + 248> frame #2: 0x000000018e77cda8 UIKit`+[UIColor(UIColorNamedColors) colorNamed:inBundle:compatibleWithTraitCollection:] + 168> frame #3: 0x00000001022d71b8 MY_APPLICATION_NAME`@nonobjc UIColor.__allocating_init(named:) at ViewController.swift:0 * frame> #4: 0x00000001022d69d4 MY_APPLICATION_NAME`ViewController.pickerView(pickerView=0x0000000103314930,> row=0, component=0, view=nil, self=0x000000010330f2b0) at> ViewController.swift:117> frame #5: 0x00000001022d73cc MY_APPLICATION_NAME`@objc ViewController.pickerView(_:viewForRow:forComponent:reusing:) at> ViewController.swift:0> frame #6: 0x000000018e539a30 UIKit`-[UIPickerView tableView:cellForRowAtIndexPath:] + 616> frame #7: 0x000000018ed5d6ac UIKit`-[UIPickerColumnView tableView:cellForRowAtIndexPath:] + 168> frame #8: 0x000000018e6180e8 UIKit`-[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 668> frame #9: 0x000000018e61864c UIKit`-[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80> frame #10: 0x000000018e5f82e4 UIKit`-[UITableView _updateVisibleCellsNow:isRecursive:] + 2140> frame #11: 0x000000018e602888 UIKit`-[UITableView _cellForRowAtIndexPath:usingPresentationValues:] + 232> frame #12: 0x000000018e3fdbb8 UIKit`-[UITableView cellForRowAtIndexPath:] + 76> frame #13: 0x000000018eba84d4 UIKit`-[UIPickerTableView selectRow:animated:notify:updateChecked:] + 352> frame #14: 0x000000018e5383d4 UIKit`-[UIPickerView _resetSelectionOfTables] + 184> frame #15: 0x000000018e538258 UIKit`__30-[UIPickerView layoutSubviews]_block_invoke + 6612> frame #16: 0x000000018e2f2480 UIKit`+[UIView(Animation) performWithoutAnimation:] + 104> frame #17: 0x000000018e53683c UIKit`-[UIPickerView layoutSubviews] + 152> frame #18: 0x000000018e5392ec UIKit`-[UIPickerView selectedRowInComponent:] + 52> frame #19: 0x000000018e534d94 UIKit`-[UIPickerView _updateSelectedRows] + 144> frame #20: 0x000000018e534e44 UIKit`-[UIPickerView didMoveToWindow] + 104> frame #21: 0x000000018e2e1178 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 1496> frame #22: 0x000000018e2e0e68 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 712> frame #23: 0x000000018e2e0e68 UIKit`-[UIView(Internal) _didMoveFromWindow:toWindow:] + 712> frame #24: 0x000000018e2e0324 UIKit`__45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 156> frame #25: 0x000000018e2e017c UIKit`-[UIView(Hierarchy) _postMovedFromSuperview:] + 796> frame #26: 0x000000018e2ebd98 UIKit`-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1728> frame #27: 0x000000018e2eafd0 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 688> frame #28: 0x000000018e2e8014 UIKit`-[UIWindow _setHidden:forced:] + 272> frame #29: 0x000000018e3579f8 UIKit`-[UIWindow makeKeyAndVisible] + 48> frame #30: 0x000000018e5471b4 UIKit`-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3616> frame #31: 0x000000018e54bf44 UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1712> frame #32: 0x000000018e7cb5c8 UIKit`__111-[__UICanvasLifecycleMonitor_Compatability> _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke> + 800> frame #33: 0x000000018ea91bb0 UIKit`+[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160> frame #34: 0x000000018e7cb22c UIKit`-[__UICanvasLifecycleMonitor_Compatability> _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 252> frame #35: 0x000000018e7cba9c UIKit`-[__UICanvasLifecycleMonitor_Compatability> activateEventsOnly:withContext:completion:] + 748> frame #36: 0x000000018ef15c24 UIKit`__82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke> + 260> frame #37: 0x000000018ef15ac8 UIKit`-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 448> frame #38: 0x000000018eca00b0 UIKit`__125-[_UICanvasLifecycleSettingsDiffAction> performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke> + 220> frame #39: 0x000000018ee30290 UIKit`_performActionsWithDelayForTransitionContext + 112> frame #40: 0x000000018ec9ff60 UIKit`-[_UICanvasLifecycleSettingsDiffAction> performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]> + 252> frame #41: 0x000000018ea91210 UIKit`-[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 364> frame #42: 0x000000018e54a688 UIKit`-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540> frame #43: 0x000000018e938c24 UIKit`-[UIApplicationSceneClientAgent> scene:didInitializeWithEvent:completion:] + 364> frame #44: 0x00000001875e6968 FrontBoardServices`-[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364> frame #45: 0x00000001875ef270 FrontBoardServices`__56-[FBSWorkspace> client:handleCreateScene:withCompletion:]_block_invoke_2 + 224> frame #46: 0x000000010317d45c libdispatch.dylib`_dispatch_client_callout + 16> frame #47: 0x0000000103189b74 libdispatch.dylib`_dispatch_block_invoke_direct + 268> frame #48: 0x000000018761ab04 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36> frame #49: 0x000000018761a7a8 FrontBoardServices`-[FBSSerialQueue _performNext] + 404> frame #50: 0x000000018761ad44 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56> frame #51: 0x0000000184ef8358 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__> + 24> frame #52: 0x0000000184ef82d8 CoreFoundation`__CFRunLoopDoSource0 + 88> frame #53: 0x0000000184ef7b60 CoreFoundation`__CFRunLoopDoSources0 + 204> frame #54: 0x0000000184ef5738 CoreFoundation`__CFRunLoopRun + 1048> frame #55: 0x0000000184e162d8 CoreFoundation`CFRunLoopRunSpecific + 436> frame #56: 0x0000000186c9cf84 GraphicsServices`GSEventRunModal + 100> frame #57: 0x000000018e34827c UIKit`UIApplicationMain + 208> frame #58: 0x00000001022e147c MY_APPLICATION_NAME`main at AppDelegate.swift:12> frame #59: 0x000000018493a56c libdyld.dylib`start + 4 (lldb)
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
447 Views
Standard set up for Watch OS > 2.WCSessionDelegate used to coordinte data between main application and Watch.An App Group "group.***********.TodayExtensionWidget" used to coordinate data between main application and its Today Extension widget via UserDefaults(suiteName: "group.***********.TodayExtensionWidget")When I make a change from the watch it communicates that change with the main application. Then the main application (once launched) communicates this on to the Today Extension.What I would like to do is communicate the change in the watch app to the Today extension without needing to launch the main app first.Is there a best practice to communicate between between a watch app and a Today Extension widget?
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
328 Views
How to set the PDFView so whenpdfView.displayMode = .singlePageContinuouseach page is scaled to fit the views bounds. Like iBooks
Posted
by RyanTCB.
Last updated
.
Post not yet marked as solved
0 Replies
596 Views
A few Qs regarding the PDFThumbnailViewHow to set which thumbnails are shown.?Rather than displaying the entire pdfView as thumbnails I want to show just 4 pages.For example user searches the document for a string and finds 4 pages that match said search. I want the thumbnail view to show those pages.Also how to scroll the PDFThumbnailView if more thumbnails than visibile on screen
Posted
by RyanTCB.
Last updated
.