Would the general iPhone pasteboard ever contain more than one item? - iphone

Would pasteboard.numberOfItems (in the code below) ever be greater than 1? How would the user cause this to happen?
UIPasteboard *pasteBoard = [UIPasteboard generalPasteboard];
pasteBoard.numberOfItems
Note that I'm not asking if a single pasteboard item can have more than one representation type. That they can is clear.
Update: I understand that programmatically one could put more than one item in the pasteboard (using addItems as Kevin Ballard points out, or by setting the items property to an array containing more than one dictionary). But could the user do this using any of the built-in apps? I suppose one could easily write an app that puts more than one item in the pasteboard (so for my app to be robust, it should handle that situation).

There's an -addItems: method on UIPasteboard, so I think it's pretty clear that it's certainly possible to have multiple items.

Not with Apple's provided apps. It's entirely possible for a third party app to add multiple items as far as I know.
EDIT: On second thought, I may have had multiple items a few times while testing my app, but I didn't determine from where, or whether it was an Apple app. In either case, I'd write a test for it. My app -- right now -- only looks at the first item, and I've never had problems with built in apps in testing.

The built-in Photos app allows you to place multiple photos on the general pasteboard. Just use the "Share" button, select several photos, and then press "Copy".
The general pasteboard will then have each photo as an item with two representations: "public.jpeg" and "public.utf8-plain-text". The second representation (text) seems to be a file name, however in this case Photos always returns "image" plus a sequential number (i.e. image1.jpg, image2.jpg, etc.).
In addition, the user may use a clipboard app (several of which are present in the App store) to place multiple items in the general pasteboard. I'm currently building a clipboard sharing app.

Related

Is it possible to provide additional info about my app to the system search?

There's a system search in iOS that allows users to search though the whole device by searching entered keyword for app names, mail messages, calendar and etc. Is it possible to provide some additional information (content info) about my app to system search? We are developing some rich-graphic-content app and there are various objects there.
The customer asked us, is it possible to implement such use case: a user enters the name of some object and system search finds that object and shows our app name in the result list :) Maybe it's possible to create some "sitemap" with information about the app content, to put that somewhere into plist and to ask system search to use that for search index. I'm pretty sure it's impossible, just want to be 100% sure :)
UPDATE: One thought on that - maybe system search also uses app description text from itunes? If so then we could place additional information there and to workaround that :)
For static keywords (that are pre-defined when building the app), you can do this: How to get an iPhone app to appear in Spotlight with a query that doesn't exactly match
Unfortunately, there doesn't seem to be any way to add keywords dynamically, e.g. for the objects/files created with your app, like the Apple-provided apps do. Hopefully, the ability to add your app's contents to Spotlight will be added in a future version of iOS (7+).

What to do with "rude" app store promo codes..?

I recently generated promo codes for the iOS app store and at least one contains some combinations of letters that you better not pronounce on TV (to say the least). Is there any way to return or change such codes? I mean, I can't send that code to a reviewer, not even to a friend.
Edit: with "generated" I mean that I used iTunes Connect to get promo codes, i.e. Apple creates them and I just download them as a text file. One of the codes reads xxMFxxxxANAL. No joke! (x=arbitrary character not disclosed here). Not exactly the kind of code you want to send to somebody whom you would like to review your app...
Is there anything I can do about this? For example returning the code and getting a new one? And do you have to check every code Apple gives you by hand? If you want to give a batch to a website to give them out to their users, such a code could slip through easily.
Remove vowels from your character set?
Before returning the generated promo code, check it against a list of words you don't want to send. If it is in that list, regenerate it.
EDIT
However, that is really not the best solution. It might serve you well to change how you generate the code.
One possibility: in C# there is a Guid class that generates a guaranteed unique string. You may be able to use a subset of a Guid as your promo code.
Another Possibility: You could alternate letters and numbers.

save the state for table items

I have one requirement that I need to mark the table item when the user has already viewed that item in the table.
It is exactly like emails in the inbox. when the user reads the mail, the font will be changed to normal. The same way I need to implement. For that I used Font for the table. Now i need to save the state for the table item. When the application restarts, the table item which the user has already viewed should be seen as viewed item. I mean normal font. Is ther any way to save the state for the table item?
Thanks
Bhanu
An alternative - if we are only talking very little data, e.g. a pointer to the last read item - you can use the view state. See IViewPart.init(IViewSite site, IMemento memento) and IViewPart.saveState(IMemento memento). This method is not very useful if you have lots of data as the storage is rather ineffective.
If your bundle activator subclasses org.eclipse.ui.plugin.AbstractUIPlugin or org.eclipse.core.runtime.Plugin you can use org.eclipse.core.runtime.Plugin.getStateLocation() to get your plugin state location. You can use java.io.File and FileReader/FileWriter to store information there across sessions. See org.eclipse.ui.plugin.AbstractUIPlugin.saveDialogSettings() for an example of how a this plugin stores dialog settings there.

How did twitter implement new autocomplete feature in iPhone app?

Twitter has an awesome new way to enter "#" and "#" in the latest iPhone app.
http://blog.twitter.com/2011/03/twitter-for-iphone-ipad-even-better.html
When you type "#" or "#" and then type characters it instantly starts to autocomplete in a table below. How are they doing this? It feels native, but is it?
If it's native, how did they do it? UITextView with an active UITableView? It's really fast and smooth, so I'm guessing they load the phone with trending #'s and your #'s and it's fast because the data is local (it goes to just typing if it's not there).
But I'm wondering if there was a way to achieve this affect with data that is remote on a webserver using async calls.
Any thoughts on how to do this / get started?
If by 'native' you mean, build into the SDK, then I have to disappoint you, this is not a build-in SDK feature (there is something similar with the UISearchController/UISearchBar classes, but that's not what Twitter is leveraging).
This however, does not mean that you cannot build it yourself. I believe it would be quite simple. All you would have to do is monitor every time the user inputs text into the UITextView (this can easily be done using the UITextView delegate methods). You do a check on all the text, and if the user enters an '#' or a '#', or any other symbol you want to watch for, you create/show a UITableView beneath the text view (or wherever you want it).
As for the table view's datasource, it would have to be based on information you gather through search. When Twitter shows you a list of trending tags, etc. I would think it is something they have pulled down when you synced your feed, and then cached somewhere. If you were using a web server, you could do the same. When the user starts entering specific text, you could do a search on the server. If you do the network requests asynchronously, you can display a UIActivityIndicator in the table view, until you've gotten a response from the server. If the user enters more text before the server has 'replied' to you, simply cancel the old server request, and start a new one.
I haven't implemented something like this myself, and I have no knowledge of how it would perform in real-life, but if I was to implement something similar off the top of my head, this would be the aproach I would pursue. It might not suit your case perfectly, but hopefully, it will have given you some inspiration :)

iPhone Objective-C: Select from table and diplay selected ones in the style of the "To:" part of iPhone's SMS, email, etc

I want to be able to select items from a table and display them like how the iPhone displays the list of recipients for SMS, email, etc. It would be great if you could lead me to any resources and/or direction for this kind of thing. (I wasn't really sure how to Google this kind of thing too.)
Thanks in advance!
If you mean the interface with each email address in a little bubble, and they get highlighted if you hit backspace and deleted if you hit backspace again, it's kind of complicated to reproduce (I've done it). This is partly because (at least prior to iOS4) the way you interact with the keyboard is a bit limited. You need to have a hidden space character at the beginning of your UITextField to even get a call when the user hits backspace when there are no other characters left.
As for creating the table that shows the addresses from the user's address book, use a standard UITableView and do yourself a favor and use Erica Sadun's address book utilities to get the data from the address book.
There is something very similar in the Three20 framework, so I'd suggest you have a look at that.