I want to add a NSDatePicker in the sidebar of my app, to help select a date , or a range of dates. I could use the standard NSDatePicker, but it only seems to come in a single size, and doesn't seem to be resizable. I've dropped the NSDatePicker component into a xib file, and added auto-layout constraints, but they don't seem to work. Is there a way to make them respond to auto-layout and be resizable? Or should I be looking for 3rd-party frameworks to integrate with (if so, any recommendations)?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi,
In my Core Data schema, I have a 'transformable' attribute in an entity, which is using a custom NSValueTransformer, the purpose of which is to convert a UIImage into NSData with some compression (basically to save a small thumbnail from the image). From this attribute, I had recently started getting these warnings about using NSKeyedUnarchiveFromData:
'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
So I read about this, and figured I'd need to change the NSValueTransformer to using NSSecureUnarchiveFromDataTransformer ... but after making the changes (as best as I understood them) I can't get it to work, and now the app crashes when the attribute is accessed.
This is the existing NSValueTransformer that I was using:
@interface ImageToDataTransformer : NSValueTransformer {
}
@implementation ImageToDataTransformer (BOOL)allowsReverseTransformation {
return YES;
}
(Class)transformedValueClass {
return [NSData class];
}
(id)transformedValue:(id)value {
// for our smaller views this uses much less data and makes for faster syncing
NSData *compressedData = UIImageJPEGRepresentation(value, 0.2);
return compressedData;
}
(id)reverseTransformedValue:(id)value {
UIImage *uiImage = [[UIImage alloc] initWithData:value];
NSData *data = (NSData *) value;
//NSLog(@"reverseTransformedValue: image size: %@", [NSByteCountFormatter stringFromByteCount:data.length countStyle:NSByteCountFormatterCountStyleFile]);
return uiImage;
}
So I changed it to subclass from NSSecureUnarchiveFromDataTransformer instead, and added the following to the implementation:
(NSArrayClass *)allowedTopLevelClasses {
return @[[ImageToDataTransformer class]];
}
(void)setValueTransformer:(nullable NSValueTransformer *)transformer forName:(NSValueTransformerName)name {
NSLog(@"ImageToDataTransfer: calling setValueTransformer");
[NSValueTransformer setValueTransformer:transformer forName:name];
}
(NSArrayNSValueTransformerName *)valueTransformerNames {
return @[@"ImageToDataTransformerName"];
}
Before the Core Data persistent store is accessed, I 'register' the transformer:
[ImageToDataTransformer setValueTransformer: [[ImageToDataTransformer alloc] init] forName:@"ImageToDataTransformerName"];
Now the app crashes when the image is read:
[__NSCFData _rasterizedImage]: unrecognized selector sent to instance 0x7ff53c108800
If I change the transformer back to NSValueTransformer, it works fine. So I'm not sure if I'm missing something from the implementation, or I have misunderstood the premise of 'NSSecureUnarchiveFromDataTransformer'. Would love to know what I can do to fix this.
Hi,
I have an 'uploader' function in my app that can populate the CloudKit private database with a lot of user data. I batch the records into multiple CKModifyRecordsOperations, across the different record types, before I upload them. When I do this with a lot of data, I sometimes get CKErrorRequestRateLimited errors, with a value for CKErrorRetryAfterKey specified in the CKError, for a few of the modify operations. I usually respond by creating new operations for the same records, delaying them by the specified CKErrorRetryAfterKey key, and then retrying the operations. But those operations end up getting more errors with CKErrorServiceUnavailable or CKErrorRequestRateLimited again.
So my question is .... is the CKErrorRetryAfterKey value supposed to be cumulative, and does it apply across operations? For e.g. if I have Operations 1, 2 and 3, and each of them returns with a 'retry' error value (say 5, 10, and 15 seconds) ... can I retry them with the retry values for each operation (5 secs for Op1 etc), or should I choose the highest retry value before trying another operation (15 secs), or should I add them up and not try anything for the sum of their retry values (30 secs)? And is this ‘retry’ value limited to each record type, or is it generally for the whole container?
If anyone has an insight into this, I would love to know.
Thanks,
Zulfi Shah.
I am having a hard time uploading data to my CloudKit container in a series of operations. I have an 'uploader' function in my app that can populate the CloudKit private database with a lot of user data. I batch the records into multiple CKModifyRecordsOperations (with 300 records in each operation as a maximum), before I upload them. When I do this with a lot of data (less than 50MB even), I get CKErrorRequestRateLimited errors for some of the operations, with a value for CKErrorRetryAfterKey specified in the CKError. I respond by creating new operations for the same records, delaying them by the specified CKErrorRetryAfterKey key, and then retrying the operations. But those operations end up getting more CKErrorRequestRateLimited errors again. Usually one or two operations go through at a time, and all others have the same error, and then I have to retry again after 90 seconds or whatever the retry-key says. Doing all of this can take dozens of minutes to do a simple upload.
I checked the CloudKit dashboard, and for the container's 'developer' telemetry section, the 'server latency' seems very very high (over 100,000 for 95% percentile). It also suggests the 'average request size' is 150KB on average across the last few days as I've been testing this, which doesn't seem like a lot.
I've tried throttling the requests so only 20 modify operations are sent at a time, but it doesn't seem to help. I'm not sure what else I can try to improve this. I have 'query' indexes for 'recordName' field for each recordType, and 'query, searchable, sortable' on some of the custom fields on the recordTypes (though not all). The CKModifyRecordsOperations' configurations have 'qualityOfService' set to 'userInitiated'.
Is there anything else I can try to improve the upload speeds? Or is it out of my control?
Hi,
I am using a rich, detailed view to show information in an MKAnnotationView's detailAccessoryView. As such, I don't need to use the 'title' or 'subtitle' fields that come with the callout view. However, I also want to show the 'title' under the MKMarkerAnnotationView on the map. Unfortunately it looks like the same MKAnnotation's 'title' property is used for both the marker's name on the map, as well as in the callout view. So I'm trying to figure out if there's any way to hide the 'title' in just the callout view. One thing I was considering was hiding the 'title' when an annotationView is selected, but doing this in 'didSelectAnnotationView' is too late to take affect for the callout view, and there doesn't seem to be an option for a delegate call like 'willSelectAnnotationView'. Is there any other way to figure out just before the annotation is selected?
I am adding a small SwiftUI view to my NSTableViewCell, using NSHostingView. Occasionally (randomly) I get this crash in the debugger, but I don't understand what it means:
#0 0x00007fff4309ace6 in AG::data::table::grow_region() ()
#1 0x00007fff4309b155 in AG::data::table::alloc_page(AG::data::zone&, unsigned int) ()
#2 0x00007fff4309b430 in AG::data::zone::alloc_slow(unsigned int, unsigned int) ()
#3 0x00007fff430a1bad in AG::Graph::add_attribute(AG::Subgraph&, unsigned int, void const*, void const*) ()
#4 0x00007fff430b87fe in Attribute.initτ_0_0(body:value:flags:update:) ()
#5 0x00007fff42e8da29 in GraphHost.Data.init() ()
#6 0x00007fff4273e532 in ViewGraph.initτ_0_0(rootViewType:requestedOutputs:) ()
#7 0x00007fff4273e3be in ViewGraph.__allocating_initτ_0_0(rootViewType:requestedOutputs:) ()
#8 0x00007fff42d795d6 in NSHostingView.init(rootView:) ()
#9 0x00007fff42d785dd in NSHostingView.__allocating_init(rootView:) ()
#10 0x00000001036494ff in ContactsCountIconsInterface.makeContactsCountView() at /Users/z/Documents/Git/branches/SimpleList/Mac/ContactsCountIconsInterface.swift:23
#11 0x0000000103649558 in @objc ContactsCountIconsInterface.makeContactsCountView() ()
#12 0x000000010347ed1a in -[ContactDataCellView setupIconsCountViewWithCountForLogsCount:todosCount:filesCount:] at /Users/z/Documents/ContactsJournalGit/branches/SimpleList/ContactDataCellView.m:40
#13 0x0000000103445f88 in -[MacContactsViewController outlineView:viewForTableColumn:item:] at /Users/z/Documents/ContactsJournalGit/branches/SimpleList/Mac/MacContactsViewController.m:745
#14 0x00007fff22dde8b5 in -[NSTableView(NSTableViewViewBased) makeViewForTableColumn:row:] ()
#15 0x00007fff22dddf03 in -[NSTableRowData _addViewToRowView:atColumn:row:] ()
#16 0x00007fff22dddc38 in -[NSTableRowData _addViewsToRowView:atRow:] ()
#17 0x00007fff22ddbf41 in -[NSTableRowData _initializeRowView:atRow:] ()
#18 0x00007fff22dda3d3 in -[NSTableRowData _preparedRowViewForRow:storageHandler:] ()
#19 0x00007fff22dda21e in -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] ()
#20 0x00007fff22dda034 in -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] ()
#21 0x00007fff22dd8f2a in -[NSTableRowData _updateVisibleRowEntries] ()
#22 0x00007fff236dedbb in __59-[NSTableRowData _automaticRowHeightsUpdateVisibleRowViews]_block_invoke.1371 ()
#23 0x00007fff22fff21b in -[NSTableRowData _keepTopRowStable:andDoWorkUntilDone:] ()
#24 0x00007fff22ffeff8 in -[NSTableRowData _automaticRowHeightsUpdateVisibleRowViews] ()
#25 0x00007fff22dd8873 in -[NSTableRowData updateVisibleRowViews] ()
#26 0x00007fff22f089da in -[NSTableRowData prepareContentInRect:] ()
#27 0x00007fff22f0896f in -[NSTableView prepareContentInRect:] ()
#28 0x00007fff22f086d6 in __38-[NSView _pullInExtraTilesForOverdraw]_block_invoke ()
#29 0x00007fff22f07fd2 in -[NSView _performWorkOnTilesFromRect:renderedContentRect:maximumRect:scrollVelocity:handler:] ()
#30 0x00007fff22f07767 in -[NSView _pullInExtraTilesForOverdraw] ()
#31 0x00007fff22f073ef in -[NSView _doIdlePrefetch] ()
Can anyone comment on how to decipher this crash?
I'm deliberating on whether to use CloudKit for an app that requires sharing data amongst self-created groups of users (for e.g. sharing company-wide directories). I would use a public database for this, but I had a couple of questions:- if I create a subscription to listen to record changes for a partcular record type, will all the users get a notification when data changes, or only the logged-in iCloud user amongst his/her multiple devices? can there by 'group' notifications that cross iCloud users?- if there's no way for a 'group' of users to get notifications, I guess polling from the app to CloudKit would work, with the groupID part of the predicate? Or is there another options?Thanks.
Hi,
I just saw the "Use the camera for keyboard input in your app" talk, and had a question about it's capability that wasn't covered. From what I could tell, you have to designate a particular UITextField / UITextView as the 'target' (or is it 'responder'?). If I want to parse different types of content (name, email, phone number) into different UITextFields, for e.g to fill out a form ... how would that work? I don't want the user to launch the camera 3 times, one for each text field. Or would it be best to dump the contents into a UITextView and then have it parse the contents and detect the content types?
Thanks.
Hi,
I am using the (deprecated) UILocalNotification class in my app right now, because it fulfills a need that the UserNotification framework doesn't fulfill even 5 years after it was introduced. In my app, users can setup 'reminders' for different tasks, and those could be one-off tasks, or repeating tasks that start from a particular date/time. The UserNotifications system doesn't work with the latter requirement; it doesn't allow for you to setup a repeating alert which starts at a specific date/time. You can either setup a one-off alert in the future, or you can setup a repeating alert which starts as soon you set it up. As an example, I want to be reminded to call a friend of mine every week, from July 10th onward ... with the UserNotification framework, setting a 'repeat' will mean it'll fire an alert every week, starting from today.
So what's the best way to build a solution to this? Is there a way to 'intercept' the alert before it's shown (if it's before the date we want it to start firing)? Should I be looking at some 3rd-party services to do this remotely?
Thanks!
Hi,
With iOS15, is there still a limit for how many UserNotifications can be scheduled locally on a device? A lot of places suggest that the limit is for 64 notifications at a time, and this limit has been there since UILocalNotifications were a thing. Has that changed at all? Considering that modern devices are so much more powerful than in the past, one would imagine that they should be handle more than a few local notifications in the system.
I filed a Radar for this 5 years ago, which was changed to this Feedback Request: FB5978935
If we are presenting a sheet controller without any dimming view, would we be able to drop drag-and-drop between the sheet view and the presenting view controller (if the views themselves supported drag-and-drop)?
Thanks.
Hi,I'm starting to work on adding a auto-renewable subscription in my app to unlock certain features. I understand the StoreKit and iTC details, but one thing that's not clear to me is *why* we need to do receipt validation for in-app purchases? There seems to be a lot of empasis on doing this, and it gets complicated because you need to either import different libraries to do this client-side (which isn't the recommended option) or do it server-side, which adds a lot of overhead. In my case, I don't have any server running at all, and my whole app relies on CloudKit instead. So I'm wondering why it's so essential in case of IAP. a) if it's for preventing piracy, shouldn't that apply to paid-apps as well? But no one talks about reciept validation for paid-up-front apps.b) when StoreKit's paymentQueue "updatedTransactions" delegate tells us that someone has purchased an IAP, is that something that can be spoofed? I would imagine not, and even so, this would only be possible with jailbroken devices. Is that what people are worried about? How much of a problem is this in the real world? c) is there certain information in the reciept that is essential for subscriptions to work correctly? In my mind, the simplest implementation would be this: display the IAP products, implement the storekit delegate to see when the user purchased the product and mark that user's CloudKit "User" record with the type and date of subscription (this can also be used to restore the IAP on another device) and unlock the features. When the next billing cycle comes, I can wait for StoreKit to tell me whether the user cancelled or continued the subscription, and lock/unlock the feature accordingly. I don't see the necessity of receipt validation in this case. But I might be wrong and misguided about my assumptions. Would love some comments about this.
Hi,I am rrying to add unit tests for my CloudKit error handling code. One of my tests requires me to set the 'recordChangeTag' property to something that's not nil (so it can simulate an existing server record) ... but I can't figure out a way how to set this. Setting a value using the record.recordChangeTag doesn't work, wont even compile. I tried using [record setObject: @"aad" forKey:@"recordChangeTag"]; but even that fails at run-time, failing with this:"caught "NSInvalidArgumentException", ""recordChangeTag" is a reserved key name"Is there any other way to set this? I need to test some conflict-handling code, and the only way to do this sensibly is to simulate an existing server record, which you can't do without a 'recordChangeTag'.
Hi,
I am trying to build my project with Xcode12, and I am running into this error:
<unknown>:0: error: module compiled with Swift 5.2.4 cannot be imported by the Swift 5.3 compiler: /Users/zs/Documents/CJ/branches/CJ-400/SimpleList/Carthage/Build/iOS/PhoneNumberKit.framework/Modules/PhoneNumberKit.swiftmodule/x86_64-apple-ios-simulator.swiftmodule
Not sure how to resolve this. I've tried:
cleaning the build directory and building again
cleaning build dir, plus deleting DerivedData, and restarting Xcode and building again
running 'carthage update PhoneNumberKit --platform iOS', and doing another clean build
changing the Xcode command-line tool to Xcode 12, and building again
None of these have worked. What else can I try? Why am I getting this error? Would love some more information
I am working with a UIKit app, which has an MKMapView in it, which displays a bunch of MKAnnotationViews. For each annotation view, I'm using a SwiftUI view to draw the detailAccessoryView. This works, but whenever a keyboard is presented (even if it's in another view controller), I see a major memory spike in the app. For e.g., it goes from using 130MB to 600MB+ on an iPhone8 (the exact values don't matter of course). This explains a crash that seems to be happening with the same app in production as well, which I reported in this DevForums Thread
From what I can tell, whenever a keyboard is shown, the SwiftUI views seem go repeatedly resize or re-layout themselves, maybe trying to reconfigure their internal layout or something. If I reduce the number of views in my SwiftUI view, it reduces the memory spike; if I remove the SwiftUI view and just use a plain UIView, the spike completely disappears.
My question is: how can I get the SwiftUI views to ignore what's happening with the keyboard in some other view? I've read in some other threads that there is a 'keyboard avoidance' issue with iOS14 and above ... though in my SwiftUI view, there isn't any text field in it's own views. I've tried adding the modifier to the top-level SwiftUI view:
.ignoresSafeArea(.keyboard)
But it doesn't make a difference
Can anyone shed some light on this? Is there another way to avoid keyboard changes in a SwiftUI view?