I'm new to memory-management, and am reading different things about how to best release properties.
If I have:
in .h:
@property(retain) NSString *myStr;
and in .m:
@synthesize myStr = _iVarStr;
Should my dealloc have:
[_iVarStr release];
or
self.myStr = nil;
or something else?
Thanks!
Hello,
How to get file size of pdf,gif,doc etc using xcode.
suppose to i get pdf file form resorce folder so how can i get size of for this file.
is there any way?
Thanks you,
Hi,
How can I detect a self signed certificate from a revoked or expired ones?
I'm using NSURLConnection and implementing connection:didReceiveAuthenticationChallenge: on delegate:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]){
NSURLProtectionSpace *tmpSpace=[challenge protectionSpace];
SecTrustRef currentServerTrust=[tmpSpace serverTrust];
SecTrustResultType trustResult;
OSStatus err = SecTrustEvaluate(currentServerTrust, &trustResult);
BOOL trusted = (err == noErr) && ((trustResult == kSecTrustResultProceed) || (trustResult == kSecTrustResultUnspecified));
if (trusted){
// Do something
}
}
}
Currently the "if (trusted){}" block only work for certificates trusted by iOS, I want it to work for others as well, but only if the certificate isn't revoked or expired.
The documentation is using SecTrustSettingsSetTrustSettings for changing the settings and reevaluate the trust. but I couldn't find this method (or the SecTrustSetting) for iOS, only for Mac.
Thanks
sir
I'm getting 2 different values
in back button click
My question is,
*If I want to back to view as per my value coming in int variable.
how is it possible?
*My second question is that my project is based on UINavigationController
So,how should i do that?
bcoz i'm using PushviewController to puch the new view from olderview
Thanks in advance
So I dynamically create 3 UIButtons (for now), with this loop:
NSMutableArray *sites = [[NSMutableArray alloc] init];
NSString *one = @"Constution Center";
NSString *two = @"Franklin Court";
NSString *three = @"Presidents House";
[sites addObject: one];
[one release];
[sites addObject: two];
[two release];
[sites addObject: three];
[three release];
NSString *element;
int j = 0;
for (element in sites)
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//setframe (where on screen)
//separation is 15px past the width (45-30)
button.frame = CGRectMake(a, b + (j*45), c, d);
[button setTitle:element forState:UIControlStateNormal];
button.backgroundColor = [SiteOneController myColor1];
[button addTarget:self action:@selector(showCCView:)
forControlEvents:UIControlEventTouchUpInside];
[button setTag:j];
[self.view addSubview: button];
j++;
}
The @Selector method is here:
- (void) showCCView:(id) sender {
UIButton *button = (UIButton *)sender;
int whichButton = button.tag;
NSString* myNewString = [NSString stringWithFormat:@"%d", whichButton];
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view.backgroundColor = [UIColor whiteColor];
UINavigationBar *cc = [SiteOneController myNavBar1:@"Constitution Center Content"];
UINavigationBar *fc = [SiteOneController myNavBar1:@"Franklin Court Content"];
UINavigationBar *ph = [SiteOneController myNavBar1:@"Presidents House Content"];
if (whichButton = 0)
{
NSLog(myNewString);
[self.view addSubview:cc];
}
else if (whichButton = 1)
{
NSLog(myNewString);
[self.view addSubview:fc];
}
else if (whichButton = 2)
{
NSLog(myNewString);
[self.view addSubview:ph];
}
}
Now, it is printing the correct button tag to NSLog, as shown in the method, however EVERY SINGLE BUTTON is displaying a navigation bar with "Franklin Court" as the title, EVERY SINGLE ONE, even though when I click button 0, it says "Button 0 clicked" in the console, but still performs the else if (whichButton = 1) code.
Am I missing something here?
I have a set of 100 rows, pretty similar to values which can be selected in a picker. When the user scrolls the table, I want the rows to be appended like an forever-ongoing assembly-belt. So when the user scrolls down and reaches the row 100, and scrolls even further, the table view will show again row 1, and so on. Reverse direction same thing.
My thoughts:
don't display scroll indicators (they would make not much sense, probably)
what value to return in the numberOfRows delegate method? This infinity constant?
in cellForRowAtIndexPath: simply wrap the index around when it exceeds bounds?
Hi,
I have a UIView which I can zoom to (as it is set as a subview of UIScrollView). UIView has UILabel, UITextField, etc.
If I just zoom to the UIView, then of course label and text field get fuzzy (the same effect if you are zooming to the image file without changing image resolution).
To solve the problem I need to increase the font size and sizes of the UILable and UITextField in according to the scale used to zoom in (scale is passed as a param by the UIScrollView).
This is where I am getting confused.
Changing frame (by increasing it width and height by zooming scale) I get all my elements (sub-views) repositions (because changing frame effects center and bounds)
Question:
1. What would I need to do to zoom in to the sub-views and just increase the sub-view sizes while keeping them in the exactly the same position?
thanks
I have a 'Contact' class with two properties : firstName and lastName.
When I want to display a contact's full name, here is what I do:
NSString *fullName = [NSString stringWithFormat:@"%@ %@", contact.firstName, contact.lastName];
But when the firstName and/or lastName is set to nil, I get a "(null)" in the fullName string. To prevent it, here's what I do:
NSString *first = contact.firstName;
if(first == nil) first = @"";
NSString *last = contact.lastName;
if(last == nil) last = @"";
NSString *fullName = [NSString stringWithFormat:@"%@ %@", first, last];
Does someone know a better/more concise way to do this?
I have a UITableView with 3 sections inside of a UIViewController. Is it possible to have other controls above the UITableView for example a UISlider or a UIImage? If so, how can this be accomplished?
Note: These controls should not be in a UITableViewCell, they should be part of the view.
Fo styled text (bold, italic, diff fonts and sizes), what's the best solution for putting a chunk of text within a cell? The text can of various lengths, so the cell would have to change it's height accordingly.
I am new to iOS development. I am trying to connect to a storyboard from xib file. My xib View Controller has a "Login" which if successful should connect to storyboard. I have googled and searched on stackoverflow for a solution and I am using this code that is given everywhere:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
YourViewController * yourView = (YourViewController *)[storyboard instantiateViewControllerWithIdentifier:@"identifier ID"];
I have created an identifier for my storyboard as well. However, I am not being redirected to the storyboard no matter what I try. When the login finishes, I go back to my main View Controller (xib). I should be instead redirected to the storyboard. Here is what my code looks like in a file called ProfileTabView.m:
-(void) loginViewDidFinish:(NSNotification*)notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
ProfileTabView * yourView = (ProfileTabView *)[storyboard instantiateViewControllerWithIdentifier:@"myID"];
}
I have implemeted this code in the function that gets called once the login is successful. However, the storyboard "Storyboard" never gets called. Am i doing this right? Am I supposed to be writing this code anywhere else?
Thanks a lot for any help :)
Hi,
I have here a view with an image and the text view (with finite frame size) .
I've already implemented the textview keyboard notification but the problem is that when inputting in the textview it still behind the keyboard (the text is not visible). It seems this problem occur when I have an Image view as background.
Pls advise me how to fix this.
Here's my sample code:
http://snipplr.com/view/35758/textview-input-is-behind-the-keyboard/
Thanks
Hi i am developing an app for my QA department. I need to programically get how many phone numbers are there in the entire address book. No user input. Just click a button and then get how many phonenumbers are there in the ENTIRE addressbook.
Please email me at [email protected]
I'm having an odd problem with CATransform3DMakeRotation. When the rotated view is in the center of the superview, it looks like this:
This is how it's supposed to look. However, when it's somewhere else in the superview, say, in the lower left corner, it looks like this:
Note that it is tilted to the right. Same thing happens when it's in the lower right corner, only that it tilts to the left. Is there some way to make it tilt the way it should all the time and in every position?
We use WPF and Expression Blend 4. I'm trying to improve our workflow by tutoring one of our designers to use it for styling and animation.
Slowly but surely I get the impression Blend in itself is to technical for the designer in question. I myself use it only occasionally (it's great for Visual States for instance) because a lot of things are easier done in code or not possible at all in Blend alone. It seems a developer with design experience is a lot more productive with it than a sole designer.
Are there any good resources or advice as to how I can improve this workflow?
Hi,
hope someone can help me on learning some new stuff about delegates in iOS-programming.
I have a "MainViewController" which is the first VC when the app starts. I´ve a kind of modelselection with different UIImageViews and after choosing one of them, i´m pushing a new VC. I want to handle the modelChoice with a delegate, so all other viewControllers can listen to that and act based on the users choice.
But does that mean that i have to alloc a new instance of that "MainViewController" in every VC? Whats the solution on that? How do i create (i think its called) static delegate?
Would be great to learn that..
Thanks for sharing..
O have an NSDictionary. Inside the dictionary there is an array. I want to sort the dictionary and display it's value in ascending order so please any one help me how can I get sorted data?
The problem:
Can this button be killed in a popover? I can remove the button in the ABPeoplePicker*Controller that appears when picking Contacts by editing the private VC's navigation item on the fly, but this one eludes me (no UINavigationControllerDelegate methods are called by the UIIPC).
A beginner's question:
If, in your nib, you have the File's Owner linked to the ViewController class, and you also have a NSObject-derived class, how do you communicate between the ViewController class and the NSObject class within code?
For instance, suppose ScientificCalculatorView.xib looks like this
File's Owner (class: ScientificCalculatorViewController)
FirstResponder
View
Calculator (an object that has been linked to the Calculator class)
Obviously, I'd want Calculator to be reusable, so it could be used with a NormalCalculatorViewController or something like that. So that UI and the calculator code are separate. Does Calculator even need to be in the nib?
It's a beginners question, but I'm just trying to get my head around it.
I am working with an app similar to apple's core data recipes sample code. I want to be able to delete the entry from the detail view, much like apple's contacts app.
The code below is deleting the 1st entry and not the selected entry. Not sure what I am doing wrong.
NSIndexPath *indexPath = [myTableView indexPathForSelectedRow];
NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
[context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]];
[myTableView reloadData];