WatchKit How set a string when a certain table is pressed?(Swift) - swift

Im creating a watch app but i have a problem and that is that i want to set a string depending on which table the person pressed in the watch app.
Can anyone help me?????

If I understand correctly you're trying to perform an action when a user taps on a WKInterfaceTable row?
You can achieve this using table:didSelectRowAtIndex: by identifying the corresponding string based on the index and sending an appropriate message to the string.
See the WKInterfaceTable Class Reference

Related

When to use class vs struct in a specific case [duplicate]

This question already has answers here:
Why Choose Struct Over Class?
(17 answers)
Closed 3 years ago.
Here's my scenario:
I have a list of user present in a TableView, in each row I show some user's information like address, phone number.
I can tap on a user, I pass the user to another screen like Detail View Controller, in here I can change the user's information. Then I can tap back and those change affect to TableView.
In the scenario above, what class or struct should I use.
I've tried both, class might be easier when I only need to modify user's info in the Detail View Controller but can it lead any side effect ?
I've read some article and they says that always choose struct by default but it make me confused
Some one can give me some advice when to use one instead of another and explain why. Thanks a lot.
If you choose class then you don't need to do anything just pass the same object which exists in the user's array.
If you choose struct it will call by value and will not change anything in another instance, so you will need to inform your ViewController regarding the changes (May be in back button click) via delegate or notification. You can pass your user model in the delegate call back or notification object and replace it in your user's array by comparing its id.
Its better to use structs because they are value types and have a unique memory address(creates a copy). In your case its better because you have multiple users and each user will be unique.
Instead if you use classes for user and if there are multiple instances of the same user then changing the properties of one user will change another because classes are reference types and points to the same memory address.

Want to create custom reminder

I want to create custom reminder without using alarm, because I have requirement like when a uitextfield 's value increases than previous value the reminder need to be called.
So Is there any way for doing that ???
Thanks in advance
If you want to show an alert if the text entered in the textfield is greater than 1000 in length, then use
1.
UITextField delegate methods. There are methods that get called at every time you enter any character in the textfield. Read more here. You will find a method of your needs.
2.In that method use an if-else condition to check the length of the enteterd text.
Find a property in this link which helps you getting to the length of the text entetered so far in textfield.
3.Use UIAlertView to show alert. Here is the link.
PS: I could have given you the code, but I think it would be more beneficial for you to read these docs and try to implement. In case you stuck somewhere, ask specific questions and we will help you.
I think you have to be more specific, but as far as I get what you need is, if the value increase then previous values. For this you need to store last entered text onto string and if user type new text then compare it and if it is increase then set or show alert view.
Add your logic into this delegate.
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
Thanks. Hope it'll help.

how to use controll at run time after getting data from server

I want to make survey app in which i get question from server problem is that i want to place the controll as question like if i have question like having list then i want dropdown list if question type is yes or no then we can use toggle button like this and other type is to use slider so is there way to dynamically place and create controlls at run time aftaer getting question and then add to view
So how to add controls to view at run time in ipad application so that according to question type we have controls
Yes you can add runtime controls,
Just when you are getting your response from the service after that according to the response create controls programmatically,
OR
If you are aware about the response means only 4 kinds or 5 kinds of response will come than take all controls in .Xib file and use them after getting the server response.
Simply add the control whatever you have needed and hide all other.
This is a simple way, Hope you got my point:)

How Remember Me for email id Works

I have created one Login Screen where user enter their mail id.
But i want to insert one functionality where it should list the mail id automatically when user type first character of mail id
There is one way. I don't know how much feasible it is. So the Idea is : You can store somewhere all the email id after log in success. For example in sqlite database. Now, Implement Notification center for "UITextFieldTextDidChangeNotification" and search for the character in database when user start typing in TextField and show UITableview underneath UITextField with match results (which start from entered character).
When user tap on any cell of Tablview hide tableview and take that cell label value in UITextField. That's it. Hope this logic work.
You can save the emaid id in UserDefaults & use it whereever you want

Applying user-entered data in one view to a second view

I'm trying to write an iphone OS app that includes a logbook feature. The problem that I'm having is that I want each new logbook to have its own categories that are user-defined, for example a chemical receipt log would have chemical name, vendor, receipt date, expiration date and comments.
The way that I'm trying to go about this is by calling an editCategory view controller when a new logbook is created that contains a number of UITextields where the user can enter the categories. I want to take those strings and apply them to a newLogEntry view controller, so that when the user creates a new log entry, they are presented with each category followed by a UITextfield so they can enter the relevant data.
The trick is, I have no idea how to grab the category data from editCategory and apply it to newLogEntry. I'm currently using Core Data, as that seems to be the easiest way to go about this, but I'm not married to it if it interferes with a good solution. Also, I'm still more comfortable with genetic code than objective-C code, so please bear with my ignorance.
Have you considered using the App Delegate? You could keep those values in the App Delegate, and call on them in the ViewDidLoad method of your newLogEntry view controller.