I am having some trouble with this.. I see that we are supposed to be using the property:
predicateForSelectionOfProperty
for determining which properties get 'selected', and I'm actually kind of bummed for there not being a
predicateForEnablingProperty
because I only want phone numbers, for my use case.
That said, nothing I use for predicateForSelectionOfProperty seems to do what I want. What I want is, when I select a contact's phone number, it should call the delegate callback.. but instead, right now, it is calling them!
Maybe I'm just completely missing something, because I would actually rather just have a list of my contacts, with phone numbers, and only show the phone numbers.. maybe I'm not even heading in the right direction with this.
Thanks for any help you can offer!
If you don't want it to call the number, you should:
specify the peoplePickerDelegate; and
implement peoplePickerNavigationController:didSelectPerson:property:identifier:
don't specify a predicateForSelectionOfProperty (or if you do, make sure it returns true, e.g. NSPredicate(value: true))
Obviously, if you don't even want it to show you unrelated information about contacts, specify the displayedProperties array, e.g.
controller.displayedProperties = [NSNumber(int: kABPersonPhoneProperty)]
Alternatively, if you wanted to customize this UI further, you could just use the AddressBook.framework to extract the phone numbers from the address book and present whatever UI you want.
Related
What would be the best way to uniquely identify an MSConversation when developing an iMessages application?
In my case I want to give to a game object an ID of the conversation where it belongs to.
Take the localParticipant ID, add to it the remoteParticipants ID ;)
Something like that :
var conversationID = yourConversation.localParticipantIdentifier
for participant in yourConversation.remoteParticipantIdentifiers {
conversationID += participant
}
EDIT:
As noticed in comments, by doing so, you could end up with a very long ID. So the idea is to apply an hash to it, to have a constant size (MD5 is suffisant, we don't need something secure here). If it is still too long, you could crop that hash, but be aware that in that case there is a small probability for two conversations to have the same ID (depending on how much your crop).
The current top answer has a corruption issue in that if a new person is added to a group chat (or if someone is removed) your hashed ID will change.
A more elegant solution in my opinion is to just create your own serial number at the time of the first message being created and add it as meta-data to your message itself. (Using NSURLComponents of course). Then just grab that anytime a message is opened (thus launching your message app) and use that ID. Just keep it in the header of any message sent/received.
But, it depends on what you are trying to do really. The solution I've provided is great for turn-based multi-player games. It might not be good for other scenarios.
I have a Book class and I want to allow my users to share their progress for each book. To do that I present a UIActivityViewController, but I wanted to add different texts for Facebook, Twitter etc., so I had Book conform to the UIActivityItemSource protocol, and then I can return a different value for its methods depending on the activityType. So far so good.
Now I want to also share an image when the user selects Facebook or Twitter, but just text for all other options. The methods in UIActivityItemSource only let me return one object, though. To share both a string and an image it seems I'd have to add them as different activity items, but then I don't know which activityType the user will pick to decide if I should include the image or not.
So how can I share a different number of objects of various classes and values depending on activityType?
Thanks in advance,
Daniel
Edit: Now I'm trying to do this with UIActivityItemProvider… the thing is, sometimes I want to share just some text and sometimes I want to share an image too. So my UIActivityItemProvider would have to return multiple objects conditionally (sometimes it would return an image and sometimes it would not) or I would need to use more than one provider and have the image's provider return nil sometimes, but that doesn't seem to be possible. Now what?
I found a way to work around my problem. It's not great, though, so I won't accept this answer, but I'll leave it here in case it helps someone.
I can't have a UIActivityItemProvider return nil but I can have it return an empty string, so that's what I did – for the activityTypes I want an image I return an image, for the ones I don't I return an empty string. Then I have another provider for the text.
There are a few drawbacks, though. Returning an empty string creates a new line, which isn't a deal breaker, but it's annoying. Also there will always be a string item, even if I return an empty string for my text provider, so options like saving to the camera roll won't ever be available.
I'll do this for now, but if anybody has a better suggestion please let me know.
Context: Just starting to get into automation. Unfortunately, my only practice app has a changing UI. E.g., I have buttons that are hidden for some users, and shown for others depending on access permission levels.
Goal: What I want to test is when a fail is a pass; that the buttons are indeed absent when they should be. I have overlays and stuff to contend with too, but I think I can extrapolate from a button example once I'm shown how to do it.
Before this section, the login tests have already passed. This person cannot see sometimesHiddenButton, so I need it to pass the fact that it can't find the button, not fail it. How do I tell it to do that? Is there a special kind of assert I can use, or conditionals, or what?
let tablesQuery = app.tables
app.navigationBars["LandingScreen"].buttons["Hamburger"].tap()
tablesQuery.staticTexts["alwaysShownButton"].tap()
app.navigationBars["alwaysAccessibleScreen"].buttons["Hamburger"].tap()
tablesQuery.staticTexts["sometimesHiddenButton"].staticTexts.tap() <-fails
The .exists param is definitely the one you want - I think the problem is that you are calling .exists on .staticTexts instead of on the XCUIElement returned by .staticTexts["sometimesHiddenButton"]
this:
tablesQuery.staticTexts["sometimesHiddenButton"].exists
should return you a boolean you can switch on or make assertions with.
You can check the .existsvalue.
if !tablesQuery.staticTexts["sometimesHiddenButton"].staticTexts.exists {
//do something for users that don't need to see this
} else {
//do something for users that do see the button
}
This sort of thing has been asked a million times in a million different scenarios, but all of them revolve around obvious ways to break up the action and bypass the problem. This may also be the case for me, but I am not seeing it.
I have a collection of Person objects that have multiple values for various attributes. I need the user to chose which of those attributes to use for each object. So, for example, I have aliases and addresses as attributes of the Person. I need to enumerate the Persons, and ask the user which alias to use, then ask which address to use, then move on to the next Person.
I thought a UIActionSheet would handle that, but it does not block.
Currently, I am thinking I need to roll my own ActionSheet subclass, and stuff the Person object into it as a model, and then set the values in the actionSheet:clickedButtonAtIndex: method, but am hoping there is some other way to do it.
Any input greatly appreciated.
Cheers!
In pseudocode, here's what I'd try. self.persons is the array to loop over, self.cursor keeps track of where you are in that array.
- (void)actionSheet:didSelectButtonAtIndex:
{
Person *p = self.persons[self.cursor]
p.property = [self propertyForButtonIndex:]
self.cursor++
[self presentSheetForCursor]
}
I am using SWFAddress in actionscript 3 to control urls for navigation and controls, and while I am able to target and change specific parameters, I feel like I am missing a cleaner and more consistent way of handling it, perhaps even a feature or method I am not aware of.
Say I have a url and I want to change just the second param of def to xyz.
http://localhost/some-page/#/?param1=abc¶m2=def¶m3=ghi changed to
http://localhost/some-page/#/?param1=abc¶m2=xyz¶m3=ghi
I currently am doing:
if (SWFAddress.getParameterNames().indexOf("param2") >= 0) {
SWFAddress.setValue(SWFAddress.getPath() + "?"
+ SWFAddress.getQueryString().replace("param2=" + SWFAddress.getParameter("param2"), "param2=xyz"))
Essentially, checking if the param exists, checking what its current value is, then recreating the whole url using base, '?", and query, making sure I replace the the parameter and the parameter's value, making sure I don't miss the equal sign. This get's sloppy, and is error prone if the param exists but is not set to anything, or whether or not there is an equal sign, and a host of other pitfalls.
So, I can not just tell SWFAddress to update that one parameter in the url? A theoretical function of SWFAddress.setParam("param2, "xyz").
Has anyone coded their own method to micro-manipulate SWFAddress and the url, beyond the single function they supply you with of setValue(val:String)?
I think the short answer is no. According to the documentation there is no setParameter to go with the getParameter method. Looking at the code, it seems that the URL is not cached as a property in the class and therefore cannot be manipulated other than via the setValue method which, of course, updates the URL in the browser.
Presumably you're already parsing the URL in your onChange event so you can use the values to set your application state? If so, you shouldn't need to do so again when you come to rebuild the URL prior to updating it from Flash. If you store the deep-link properties on a Model class somewhere you can handle the defaulting, updating, and error checking without needing to resort to String manipulation. You would then rebuild the URL using those properties, a process you could abstract into a method in your Model class if required.
You should also note that the following line is not particularly robust since it will return true for properties such as param22 and sparam2:
if (SWFAddress.getParameterNames().indexOf("param2") >= 0) { }