If an in-app purchase is made when my app is not running, the next time the app launches Transaction.updates will emits a transaction for the purchase. That's great.
But if an in-app purchase is refunded when my app is not running, the next time the app launches Transaction.updates will NOT emits a transaction for the refund. Is that the expected behaviour?
If yes, in order to check for refunds at app launch, are we supposed to cycle trough Transaction.all and search for them?
Thank you
Post
Replies
Boosts
Views
Activity
Just found something weird with the String(localized:) method.
Let's say that I have a "%lld apples" sentence inside a string catalog.
If I call
String(localized:"\(1000) apples")
when on the device settings the number format is "1'234'567.89" and the device language is English, then the following string is returned:
1\'000 apples
Any idea why the ' character has a backslash?
It's a bug or I miss something?
Thank you
Is it possible to use a string catalog to localize a settings bundle?
Currently, to localize a Settings.bundle, we need to create a folder for each language with a single strings file inside.
For example:
Settings.bundle
en.lproj > Root.strings
fr.lproj > Root.strings
de.lproj > Root.strings
...
Any way to convert that to a string catalog?
Thank you
When using storyboards, string catalogs automatically grab translation comments from the "Localizer Hint" attribute of the objects in the storyboard.
The problem is that we can only specify a single comment per object. What if we need to specify a specific comment for some of the attributes of the object? For example, I often need to provide a specific comment to each segment title of segmented control objects. Currently, I'm doing that by setting the managed property of each string to "Manual" and setting the comment directly from the string catalog.
There is a better way to handle these cases?
I’m exploring the new Xcode 15 string catalog feature.
I see that for every sentence there is a “screenshots” field in the Xcode inspector (see image). How can we populate this field?
Thank you
Hi,
I have a controlled contained in a split view controller primary controller with a UISearchController assigned in navigationItem.searchController.
On iPhone the search bar is directly displayed in the navigation bar.
This is want I want.
But on iPad, the search bar is hidden and a search button is displayed in the top right of the navigation bar. In order to display the search bar the user must click on the icon to display the search bar.
I want the search bar to always be visible, like on iPhone.
How can I achieve that?
This is the code I use to include the UISearchController:
let searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.hidesNavigationBarDuringPresentation = false
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
And this is the result on both devices:
Thank you
I have an entity named Image with a binary attribute named imageData.
I need to cycle trough all Image objects and do something with the data contained inside the imageData attribute.
This is the code:
for image in managedObjectContext.allImages {
autoreleasepool {
var imageData = image.imageData
}
}
I have a lot of objects and every imageData has something like 500KB of data for a total of 3GB of data.
The problem is that each time the imageData attribute is used, the data go into memory and not released until the loop is done. This is causing the memory to grow up to 3GB crashing the app.
I also tried to turn the object into a fault when I'm done with it by calling refresh(_:mergeChanges:) but nothing changes:
for image in managedObjectContext.allImages {
autoreleasepool {
var imageData = image.imageData
managedObjectContext.refresh(image, mergeChanges: false)
}
}
How can I cycle trough all objects without filling up all the memory?
Thank you
In a Core Data store I have a binary data attribute with “Allows External Storage” set to true. Everything work as expected, i.e. the data of this attribute is saved inside the _EXTERNAL_DATA folder. For every data stored into that attribute, a file is created inside _EXTERNAL_DATA with a UUID as file name and without extension. That's expected.
For some reason the _EXTERNAL_DATA folder of a particular user was full of files with an “.interim” extension.
Somebody know what are this files? In which cases files are saved with the ".interim" extension? Do we need to do anything with these files? Can they be deleted?
Thank you
Hi,
I have a UITextView with allowsEditingTextAttributes set to true.
On iOS 15 and before, users can select part of the text and tap on the BIU button in order to set the text to bold, italic or underline. On iOS 16 the BIU button is missing.
How can the user change the formatting of the text contained inside an UITextView on iOS 16? There is something I need to specify on UITextView?
Thank you
Hi,
I'm looking for a way to do something when the user presses the window red close button on a Catalyst app. For example, in some cases, I need to display an alert and prevent the window from closing.
On AppKit we can use the windowShouldClose delegate method of NSWindowDelegate. Unfortnuately this is not available on Catalyst.
Did someone found a way on Catalyst to prevent a window from closing? Maybe there is a way to expose the AppKit NSWindowDelegate object?
Thank you
Hi,
I just discovered a weird bug with UITextView on iOS 16 beta 4.
For some reason now, when the scrolling is disabled, the intrinsic content size of the text view is considering the line spacing even when the textview is empty.
For example, in the below code we are setting a big lineSpacing of 50 to the text view typingAttributes attribute.
class ViewController: UIViewController {
@IBOutlet weak var textView: UITextView! {
didSet {
//Let's set the textView typingAttributes with a lineSpacing of 50.
var attributes = [NSAttributedString.Key: Any]()
let paragraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 50
attributes[NSAttributedString.Key.paragraphStyle] = paragraphStyle
attributes[NSAttributedString.Key.font] = UIFont.preferredFont(forTextStyle: .body)
textView.typingAttributes = attributes
}
}
}
On previous iOS versions, everyting it's ok and the line spacing is added only when there are more than one line (see below image).
However, on iOS 16 beta 4, the line spacing is added also when the content is empty (see below image on the left). A soon as we type something the height collapse to the correct height (see below image in the center).
Is this a new expected behavior or a bug? If it is a bug, someone has found a temporary fix for that?
Thank you
Hi,
I have a controller where the user can search for map locations or points of interest by typing inside a search box.
To retrieve the list of results I set the queryFragment parameter of a MKLocalSearchCompleter with the search content.
This correctly gives me back a list of MKLocalSearchCompletion of locations and points of interest.
When a user tap on one of this locations, I need to load the coordinates.
In order to do that I do a MKLocalSearch passing the selected MKLocalSearchCompletion, like so:
let item = items[indexPath.row]
let request = MKLocalSearch.Request(completion: item)
let search = MKLocalSearch(request: request)
search.start { (response, error) in
//Do stuff with the result.
//For some specific items I receive an MKErrorDomain 4 error.
}
This works most of the time, but for some specific items the MKLocalSearch call return the error:
Error Domain=MKErrorDomain Code=4 "(null)" UserInfo={MKErrorGEOError=-8}
This error correspond to "placemarkNotFound", ie MapKit is not able to find a placemark for the specific MKLocalSearchCompletion.
I just don't understant why this should be the case.
The MKLocalSearchCompletion is returned by MapKit.
If it is returned by MapKit then a corresponding placemark should exist, right?
Why then is MapKit unable to perform a local search on it?
The problem now is that I present the user with a list of completions returned by MapKit but tapping some of them nothing happens because I cannot determine their respective coordinates.
Why is the search failing sometime? I miss something?
Thank you
Hi,
I want to set the glyphImage property for an annotation view (MKMarkerAnnotationView) of a cluster annotation (MKClusterAnnotation).
Using the below code, inside the marker I get, instead of the glyphImage, the standard cluster number.
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if let cluster = annotation as? MKClusterAnnotation {
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "GroupMapClusterAnnotation")
if annotationView == nil {
annotationView = MKMarkerAnnotationView(annotation: cluster, reuseIdentifier: "GroupMapClusterAnnotation")
}
(annotationView as? MKMarkerAnnotationView)?.glyphImage = UIImage(systemName: "star.fill")
return annotationView
}
}
I think that the problem is that if you keep the glyphText property empty, MapKit automatically set it with the number of the cluster member annotations.
The documentation for glyphImage says:
Use this property or the glyphText property to specify the marker balloon content. If you specify both an image and text, MapKit displays the text.
So, MapKit is setting glyphText with a value an therefore the glyphImage property is ignored.
How can we use the glyphImage property for a cluster annotation?
Thank you
Hi,
I have a controller with a UITableView.
If the user, on an iPad with a keyboard or on the Mac, press the tab key, the first cell is focused showing a border.
The user can then move the focus using the keyboard arrows.
That's ok.
The problem is that the cell is focused also when the cell is selected manually, i.e. by tapping on it.
It is possibile to keep the cell focus feature when the user use the tab key, but stop focusing the cell when it's activated directly by tapping on it?
Thank you
Hi,
I'm trying to define the style of an UIButton using UIButton.Configuration in a Mac Catalyst app.
I was able to configure the component as I want except one thing.
I want to change the style of the button when the window is not active.
The default filled style automatically do this.
For example below you can see a button configured with
UIButton.Configuration.filled().
If the window become inactive (for example by activating another application) the color of the button change, like so:
Now, If I configure a button with this configuration:
var configuration = UIButton.Configuration.plain()
configuration.background.strokeColor = .gray
configuration.baseForegroundColor = .red
configuration.baseBackgroundColor = .clear
the button display with this configuration when the window is active:
but also when it's not active:
I want to change the text color from red to gray when the window is not active.
Someone know how to do it?
Thank you