Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm new to iOS, and I want to construct a for loop that says "for every object in my array, create a new UIView". I know this would be considered very basic and simple, but how would I code this?
for (Object *object in Array) {
UIView *view = [[UIView alloc] initWithFrame:???];
// Do whatever else you need here
[??? addSubView:view];
}
I have done "for (Object *object in Array)" in case you need data from said object inside your views subviews.
You want to read the documentation for UICollectionViewController and UITableViewController. They manage collections of subviews for you.
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 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
I'm having trouble creating completion blocks. I found the solution here
. It works for me, but I don't quite understand this. Now I'm still confused and don't know how to write a block myself. Are there any batter ways to understand blocks? Also, when should I use it? Is there anything that can replace blocks?
Should I create it as a property? Method perimeter? Do they have difference in efficiency?
Thank you!
check out http://fuckingblocksyntax.com for syntax.
For personal choice I like to return value and error in the completion block (similar to iOS framework pattern)
As an example;
declaration
- (void)fetchStuff:(void (^)(id value,NSError *error))completion;
calling the function
// async fetch
[object fetchStuff:^(id value, NSError *error) {
// do stuff with value
}];
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
When running analyze in Xcode I get this warning:
Argument to 'NSArray' method 'arrayWithObject:' cannot be nil
The line of code that it is happening on for me:
if (indexPath) {
indexPath = [self differentPath:indexPath];
}
NSArray *exampleArray = [NSArray arrayWithObject:indexPath];
Which is inside a NSFetchedResultsController delegate method.
How do I fix this warning?
The warning is pretty clearly pointing to the fix: make sure the object cannot be nil. There are two different easy ways to fix this.
First you could make sure you are setting your pointer to a valid object within the same method as the arraryWithObject: call.
Or you could you could wrap your arraryWithObject: call in an if statement that checks that your object isn't nil.
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.
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.