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 9 years ago.
Improve this question
When I create a new file in Xcode I can specify a subclass of my new class. But when it is already created, how can I know which subclass has it?
Thanks.
You see that in the class definition / .h file, for example:
#interface BCFrequencyPlot : NSView
BCFrequencyPlot is a subclass of NSView.
During compilation, you can type:
po [self class]
It will show you class of self. You can check class for any object currently in scope.
Related
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 4 years ago.
Improve this question
import UIKit
import Foundation
open class podview: UIView {
open var strk = UIColor.black
.
.
}
I have to change the value of "strk" from another view controller. Is it possible to do it.
YES, You can do it. There are two way to do this.
Local Notification (NSNotification)
NSNotificationCenter addObserver in Swift
Delegatation
Examples of Delegates in Swift
If you want to Change View controller B Value from View controller A then you can directly access to it.
For EX ViewcontrollerB.yourVariable = Assign value - From View Controller A
Please review and understand both concepts.
Happy Coding..:)
I'm just providing you trick.
Yes you can change it. First you need to import model of the pod.
then you need to create object of the podview and then you will be able to access strk like
objectOfPodView.strk
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 5 years ago.
Improve this question
I put this function in a class and I don't understand this error.
My Code:
Can help me?
Thanks.
You're assigning the delegation of your XMLParser to your class which does not conform to the protocol.
Your class Login should implement the XMLParserDelegate protocol :
extension Login: XMLParserDelegate{
}
I suggest you to read this :
https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html#//apple_ref/doc/uid/TP40014097-CH25-ID276
And to google around "swift delegation", there are a lot of good example that explain this concept
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 6 years ago.
Improve this question
Using a singleton object in a block will create a strong reference cycle in the code ?
As I have more then 5 singleton object in application.
You have to use weak reference of singleton inside blocks.
YourSingleton *singletonInstance = ---- //get your singleton instance here
typeof(YourSingleton) __weak weakSingletonInstance = singletonInstance;
// your block
^
{
// Now use weakSingletonInstance inside the block.
}];
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 7 years ago.
Improve this question
I have an Objective-C project, and need hints on how to call a ViewController which is in Swift from another controller in Objective-C?
Apparently it's quite easy.
You have to first make sure you're prepending your class declaration with #objc so that it's available to your Objective-C ones.
For example:
import Foundation
// Belongs to target 'TestProject'
#objc class SwiftController: UIViewController {
//... truncated
}
Now you simply have to import the name of your target (that the swift controller belongs to), appended with '-Swift.h'—exposing its interface—like so:
#import "TestProject-Swift.h"
Create a new file "YourAppName-Bridging-Header.h" and in this file you have to import "Your objective-C view controller.h"
Go to Build setting and search for bridging header and link with your birdging-header path.
Now you are able to write code in swift as usual.
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
Hai I am new to xcode My code is below,
-(void)XYZ:(NSString *)id1 {
int id2 = [id1 intValue];
NSLog(#"%d",id2);
}
I need to use the id2 value in another class like below,
-(NSArray *)Vehicles {
NSString *urlString=[NSString stringWithFormat:#"http://www.xxxxxx.com/xxx_webservice/vehiclelist.php?uid=%d&format=json",id2];
}
Please guide me to pass the value thanks in advance...
First, you should read some docs about objective-c and OOP.
What you are calling classes, are methods. And if you want to pass one variable to a method, you have to declare it in the method declaration:
-(NSArray *)Vehicles:(NSInteger) id2 {
NSString *urlString=[NSString stringWithFormat:#"http://www.tranzlogix.com/tranzlogix_webservice/vehiclelist.php?uid=%d&format=json",id2];
}
And you have to pass it when you call it, if you are calling the method from your class, a correct way will be: [self Vehicles:id2]
But i suggest you to read a lot before asking so basic questions.