Difference between Object and Category? [closed] - ios

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Difference between subclass and category? Which place used effectively in both items?And difference between category and protocol? Need real time example.
Thanks

Really short explanation. I can point you in a direction at least.
Subclass
Inherit functions of a class. You want to have the same behaviour as the class you just subclassed but with some of your own custom functionality.
Category
Add extra functionality to a class that fits your needs. In other words you could add a method to a class (NSString for example) that lets you count the characters. This can later be called on your NSString class.
Protocol
You can delegate tasks to another class that has set itself as a delegate. You can force classes to implement certain methods.

Related

What is the difference between view.isHidden vs view.isVisible? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
Improve this question
Can both be used interchangeably or one is preferred over the other in certain situations where one is better?
They are different and not interchangeable.
Like already mentioned in the comments isVisible is not even a part of UIView.
With isHidden you can hide a view, it has a getter and setter.
https://developer.apple.com/documentation/uikit/uiview/1622585-ishidden
isVisible is a property of some classes like NSWindow. It's read only and tells you if the instance is visible on the screen.
https://developer.apple.com/documentation/appkit/nswindow/1419132-isvisible

update UI of view controller from another class Swift [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a ViewController with a progressView, label and button. A task runs in background in task.swift when user clicks on the button on ViewController. I want to update the label and progressView in ViewController based on progress of tasks in task.swift.
Swift Communication Patterns
You have multiple ways of setting up communication between 2 classes in Swift:
Method call / return
Delegate pattern
Closure
Notification pattern
Publishers subscribers
Respect MVC (Model - View - Controller)
Because you want your model (here Task) to not be aware about the ViewController in order to respect MVC, you cannot apply just a simple method call through the reference.
Pick the right one
However all the others ways are totally valid. Because it seems to be a 1 to 1 relationship between ViewController and Task, the most simple solutions would be to use a delegate or a closure. If your classes relationship would have been a one to many, you could have picked notification. Publishers would be for reactive programming and if you like Combine.

Is it possible to call an IBAction UIButton from another view? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm new to swift and programming in general. I'm working on an app I didn't write, and am struggling to understand the existing code. To avoid dealing with protocol errors, I want to know if it's possible to reuse the functionality of a UIButtons IBAction on one view and call it's IBAction function in another view. If so How would I go about doing this. Your help is appreciated!
ContextScreen
https://controlc.com/1a91efca
(the button I'm trying to reuse)ContextMenuScreenViewController [a https://controlc.com/90847f01
the original location of the buttonOrderCreateViewController [a https://:controlc.com/3b52eefc
the original location of the refer order button(OrderCreateViewController)
ContextMenuScreenController: where I'd like to reuse the refer order button
Yoy can easily move the logic from IBAction to som function and call this function in IBAction and from any View what you need!

What iOS control is correct to use for a custom selectable list? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm trying to make a list that will contain an x number of items loaded from a web service. The list would look custom (example below) and selecting a list item would take you to another screen that shows you more details.
I've considered using a table view for this which seems to make the most sense but I'm not sure if that would allow for the level of customization that is needed. Also considering a Collection View which would give more control to how to style it but might bring it's own set of challenges.
Anyone have a recommendation of which one to use or if there's something else that is a better fit that I haven't mentioned?
That would be the UITableView and UITableViewController. You can easily create custom cell classes, insert and remove cells at runtime, and have a separate datasource or delegate from the UITableViewController if you desire.

Apply class to object iOS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am creating a custom table view controller because I want to access a search bar on the table view controller.
How can I apply the new class to my existing tableviewcontroller in my story board?
Edit:
Question was answered, for those unclear as to what I was asking, I had an object in interface builder which was using the standard class for that object, and was wondering how to apply a custom class which I made, thanks!
Select your tableViewController in the Storyboard, and enter your custom class name in the Class field of the Identity Inspector on the right-hand side:

Resources