Words Per Minute Iphone SDK - iphone

I need to calculate words per minute while typing in textfield. It is typing speed calculator and it provides user text need to be typed in the lable above textfield. Please give me some idea how to get started and what events to use.
Thanks you.

UITextField lets you set a delegate implementing UITextFieldDelegate. That object will be sent textField:shouldChangeCharactersInRange:replacementString: for each edit the user does (for example entering a char).
In there you can implement your logic - saving the timestamp of the first entry, comparing each entry against the correct string, and then, when the entire string has been entered by the user, dividing the number of words with the spent time.

Related

JSQMessageViewController - Add a label inside chat bubble, on the side of the text

I'm using JSQMessageViewController for a simple chat app I'm building, and since I'm new in Swift and iOS development in general, I need some help on how to achieve this:
I want to add a timestamp inside the chat bubble. I read that I need to change some related xib files, but I'm not quite sure how to do that.
I found this, and marcuschoong's comment gets pretty close, but I'm not sure how to find these xibs' classes, and how to connect the IBOutlets to that class (I don't have any experience in Objective C either). I need the timestamp for both incoming and outgoing messages. Any help would be appreciated!
There are 2 xib files depending on the type of message, incoming or outgoing:
JSQMessageCollectionViewCellIncoming.xib
JSQMessageCollectionViewCellOutgoing.xib
Both have the same structure: avatar, bubble container, cellTopLabel, cellBottomLabel...
In your case, you can move either cellTopLabel or cellBottomLabel into the bubble container (and adjust their constraints). If you use cellBottomLabel, you'll need to modify the following method in order to show the timestamp for every message (by default the timestamp is only displayed every 3 messages, "indexPath.item % 3"):
- (NSAttributedString *)collectionView:(JSQMessagesCollectionView *)collectionView attributedTextForCellBottomLabelAtIndexPath:(NSIndexPath *)indexPath
{
JSQMessage *message = messages[indexPath.item];
return [[JSQMessagesTimestampFormatter sharedFormatter] attributedTimestampForDate:message.date];
}

How do I "add" time to firebase timestamp in Swift?

This question is best stated in an example:
It is currently 9:00am. User wants to do activity at 4:00pm the following day. They use UIDatePicker to select 4:00pm the next day, and then hit a button. I know firebase does times in milliseconds from 1970, so what I want to do is "add" the number of milliseconds from 9:00am to 4:00pm the following day to the ServerValue.timestamp(), like so:
activitiesRef.child(newActivity.id).setValue([
"id": newActivity.id,
"name": newActivity.name,
"isActive": newActivity.isActive,
"locString": newActivity.locationString,
"locLat": newActivity.locLat,
"locLong": newActivity.locLong,
"privacySetting": newActivity.privacySetting,
"targetTime": ServerValue.timestamp()]) // + some added value of time
//"targetTime": [".sv": "timestamp"]])
The reason for this is because I will be displaying a countdown timer elsewhere in the app until it reaches the targetTime. If I can push to firebase the targetTime, then the countdown timer will be a simple comparison of the current time on the user's phone to the targetTime itself.
The error I keep getting when trying to add a double value to the ServerValue.timestamp() is "Contextual type 'Any' cannot be used with dictionary literal"
If it is not possible to do so, what other options do I have? Thank you.
ServerValue.timestamp() is not a number that you can use to perform date arithmetic. It's a special placeholder value that the server side interprets with its sense of time.
The best you can do is write the timestamp, read it back out as a number, then perform math on it.

How to get the time and date details from pasteboard

when i copy the content in iphone the content is available in the pastebpard ,how do i get the time and date from the pasteboard
By putting a date and time on the pasteboard in the first place?
Your comment fills in some rather critical missing information. I suggest that you edit your question to include the missing information.
(1) if there is a date & time in what is copied, you'll need to detect it and parse it. How you do that is entirely dependent on what is being copied.
(2) If you want the date/time of when the pasteboard was taken, then you would want to look to the UIPasteboard's API. There isn't anything that captures the date of when a pasteboard was created, though.
Now, if you are looking to see if the pasteboard has changed since the last time you looked, use the [changeCount][2].

Count-Up Timer Required, iPhone Programming

I am new to iPhone programming so am hoping someone can help me out here. I have searched the web, but can only find information on count down timers.
What I am looking to do is start a count up timer when a button is pressed and then stop it when a certain value drops by, say 5, and finally display that time. I can display values on screen once I have them, but getting the time in the first place is proving difficult for me.
I apologize if this is a simple question, but I look forward to reading your responses.
Thanks in advance,
stu
NSDate will provide the current date. You can use - (NSTimeInterval)timeIntervalSinceNow
to get the time since the first call and now.
There's no difference between an up-counter and down-counter. Just change the order of your subtraction.
UpcounterElapsedTime = UpcounterCurrentTime - UpcounterStartTime;
DowncounterElapsedTime = DownCounterStartTime - DownCounterCurrentTime;

AutoCompletion on UISearchBar

I am developing applcation with UISearchBar & TableView. On UISearchBar's text enter event I am reading char. & for entered text I am geeting results from database. But problem is that it is kind of blocking call. so I have wait till result gets back but again I pressess next char. I have to query from database. For each chars enter, I have query with entire text enterd from database. I want to implement AutoCompeltion like google search bar. As In google search bar, to get list for entred chars user has to wait.
Iwant that to be implemented in my applcation. I am using iPhoneSDK 3.0.
Same thing is running while I am pressing BackSpace. but the problem is that on iPhone Simulatior it application crashes if I press BackSpace continuously.
Can anybody give me hint ???
You could always implement your text lookup on a separate thread -- it might not offer suggestions as often, but it at least wouldn't block.
If you do this, make sure to "remember" the text the lookup is based on -- then, if the text in the UISearchBar no longer matches it, throw out the results you had -- the will no longer apply.
Example:
The user has typed "bri". Tour lookup determines that possible suggestions are "bridle", "bridge", "bride" and "brigand". If by the time your lookup returns the user has added a 'd', you don't want to suggest "brigand" any more. You don't necessarily have to throw out the whole list, but you want to at least remove the items that no longer work.