Search Results

Search found 1916 results on 77 pages for 'ref'.

Page 5/77 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • weak or strong for IBOutlet and other

    - by Piero
    I have switched my project to ARC, and I don't understand if I have to use strong or weak for IBOutlets. Xcode do this: in interface builder, if a create a UILabel for example and I connect it with assistant editor to my ViewController, it create this: @property (nonatomic, strong) UILabel *aLabel; It uses the strong, instead I read a tutorial on RayWenderlich website that say this: But for these two particular properties I have other plans. Instead of strong, we will declare them as weak. @property (nonatomic, weak) IBOutlet UITableView *tableView; @property (nonatomic, weak) IBOutlet UISearchBar *searchBar; Weak is the recommended relationship for all outlet properties. These view objects are already part of the view controller’s view hierarchy and don’t need to be retained elsewhere. The big advantage of declaring your outlets weak is that it saves you time writing the viewDidUnload method. Currently our viewDidUnload looks like this: - (void)viewDidUnload { [super viewDidUnload]; self.tableView = nil; self.searchBar = nil; soundEffect = nil; } You can now simplify it to the following: - (void)viewDidUnload { [super viewDidUnload]; soundEffect = nil; } So use weak, instead of the strong, and remove the set to nil in the videDidUnload, instead Xcode use the strong, and use the self... = nil in the viewDidUnload. My question is: when do I have to use strong, and when weak? I want also use for deployment target iOS 4, so when do I have to use the unsafe_unretain? Anyone can help to explain me well with a small tutorial, when use strong, weak and unsafe_unretain with ARC?

    Read the article

  • Automatically created NSManagedObject subclasses don't use ARC

    - by Jordan
    My project is ARC enabled (the build settings have Objective-C Reference Counting set to YES). There are no file exceptions to this, it is enabled project wide. (Latest stable version of Xcode). When I create an NSManagedObject subclass via File New for a Core Data entity, the generated header uses the following in its property declarations: @property (nonatomic, retain) But 'retain' is not ARC!! Is this a bug, or is there something I'm missing or not understanding? There are no build warnings - if this is a bug though, how can I remedy it?

    Read the article

  • realloc() & ARC

    - by RynoB
    How would I be able to rewrite the the following utility class to get all the class string values for a specific type - using the objective-c runtime functions as shown below? The ARC documentation specifically states that realloc should be avoided and I also get the following compiler error on this this line: classList = realloc(classList, sizeof(Class) * numClasses); "Implicit conversion of a non-Objective-C pointer type 'void *' to '__unsafe_unretained Class *' is disallowed with ARC" The the below code is a reference to the original article which can be found here. + (NSArray *)classStringsForClassesOfType:(Class)filterType { int numClasses = 0, newNumClasses = objc_getClassList(NULL, 0); Class *classList = NULL; while (numClasses < newNumClasses) { numClasses = newNumClasses; classList = realloc(classList, sizeof(Class) * numClasses); newNumClasses = objc_getClassList(classList, numClasses); } NSMutableArray *classesArray = [NSMutableArray array]; for (int i = 0; i < numClasses; i++) { Class superClass = classList[i]; do { superClass = class_getSuperclass(superClass); if (superClass == filterType) { [classesArray addObject:NSStringFromClass(classList[i])]; break; } } while (superClass); } free(classList); return classesArray; } Your help will be much appreciated. Thanks

    Read the article

  • Refcounted pointers on iPhone

    - by anon
    1) Refcounted pointers need stack variables to have constructors / destructors called at predictable places. 2) Objective-C, afaik, does not support the above. 3) The cocoa libraries are bound in Objective-C, not C++. Thus, my question: is there a easy way to use the Cocoa libraries, yet still have most of my app in C++ (and thus use my refcounted pointers)? Thanks! (iPhone in the title since this is mainly targeted at the iPhone)

    Read the article

  • [PHP] Condition for array with string as keys

    - by Kel
    My PL/SQL procedure returns a cursor. It always returns data. I fetch (oci_fetch_assoc) it and save it in an array. If results were found the keys of the array will be strings. If the cursor didn't find data, it will return value 0, thus the key of the array will be numeric. while($data = oci_fetch_assoc($cursor)){ if(!isset($data[0])){ ... } ... ... } What's the best way to check that the array is not just 0, but contains data? Thanks

    Read the article

  • How to add objects to NSArray from a different class with ARC

    - by Space Dust
    I needed to convert my code to ARC. I have an NSArray that I use to draw a path. I fill the objects of NSArray values from a different class. Problem is after converting to ARC, NSArray returns always null I can not see what I am doing wrong. bug.h @interface Ladybug : CCSprite <CCTargetedTouchDelegate>{ CCArray *linePathPosition; } @property (nonatomic, strong) CCArray *linePathPosition; @end bug.m @synthesize linePathPosition; -(id) init { if( (self=[super init] )) { self.linePathPosition = [[CCArray alloc] init]; } return self; } -(void) updatePosition:(CGPoint) position { [self.linePathPosition addObject:[NSValue valueWithCGPoint:position]]; NSLog(@"line path %@",linePathPosition); } -(void) breakMoveLadyBug { [self.linePathPosition removeAllObjects]; } In main .m - (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event { Ladybug *ladybug1 = (Ladybug *)[self getChildByTag:99]; CCMotionStreak* streak = (CCMotionStreak *)[self getChildByTag:999]; CGPoint touchLocation = [touch locationInView: [touch view]]; CGPoint curPosition = [[CCDirector sharedDirector] convertToGL:touchLocation]; if (ladybug1.isSelected) { streak.position = curPosition; [ladybug1 updatePosition:curPosition]; NSLog(@"Cur position %@",NSStringFromCGPoint(curPosition)); if (!ladybug1.isMoving) { [ladybug1 startMoveLadyBug]; } } } Log: Cur position {331, 110} line path (null) What am I doing wrong? What is the proper way to define and init NSArray with ARC?

    Read the article

  • NSWindowController window?

    - by Ilija Tovilo
    I have a menu-bar based application, which displays a window, when the icon is clicked. It all works fine on Mac OS X Lion, but for some reason, an error occurs on Snow Leopard an sooner versions of Mac OS X. Anytime [TheWindowController window] is called the method stops, but the app keeps running. Because of this, I don't think that the window is just nil, it's corrupt, in some way. I have no Idea why this happens, and like I said, it only happens in Mac OS X Snow Leopard. Btw. I use ARC, if that matters at all. Thank you!

    Read the article

  • iOS: Assignment to iVar in Block (ARC)

    - by manmal
    I have a readonly property isFinished in my interface file: typedef void (^MyFinishedBlock)(BOOL success, NSError *e); @interface TMSyncBase : NSObject { BOOL isFinished_; } @property (nonatomic, readonly) BOOL isFinished; and I want to set it to YES in a block at some point later, without creating a retain cycle to self: - (void)doSomethingWithFinishedBlock:(MyFinishedBlock)theFinishedBlock { __weak MyClass *weakSelf = self; MyFinishedBlock finishedBlockWrapper = ^(BOOL success, NSError *e) { [weakSelf willChangeValueForKey:@"isFinished"]; weakSelf -> isFinished_ = YES; [weakSelf didChangeValueForKey:@"isFinished"]; theFinishedBlock(success, e); }; self.finishedBlock = finishedBlockWrapper; // finishedBlock is a class ext. property } I'm unsure that this is the right way to do it (I hope I'm not embarrassing myself here ^^). Will this code leak, or break, or is it fine? Perhaps there is an easier way I have overlooked? SOLUTION Thanks to the answers below (especially Krzysztof Zablocki), I was shown the way to go here: Define isFinished as readwrite property in the class extension (somehow I missed that one) so no direct ivar assignment is needed, and change code to: - (void)doSomethingWithFinishedBlock:(MyFinishedBlock)theFinishedBlock { __weak MyClass *weakSelf = self; MyFinishedBlock finishedBlockWrapper = ^(BOOL success, NSError *e) { MyClass *strongSelf = weakSelf; strongSelf.isFinished = YES; theFinishedBlock(success, e); }; self.finishedBlock = finishedBlockWrapper; // finishedBlock is a class ext. property }

    Read the article

  • ARC, worth it or not?

    - by MSK
    When I moved to Objective C (iOS) from C++ (and little Java) I had hard time understanding memory management in iOS. But now all this seems natural and I know retain, autorelease, copy and release stuff. After reading about ARC, I am wondering is there more benefits of using ARC or it is just that you dont have to worry about memory management. Before moving to ARC I wanted to know how worth is moving to ARC. XCode has "Convert to Objective C ARC" menu. Is the conversion is that simple (nothing to worry about)? Does it help me in reducing my apps memory foot-print, memory leaks etc (somehow ?) Does it has much testing impact on my apps ? What are non-obvious advantages? Any Disadvantage os moving to it?

    Read the article

  • With ARC why use @properties anymore?

    - by trapper
    In non-ARC code retained properties handily take care of memory management for you using the self.property = syntax, so we were taught to use them for practically everything. But now with ARC this memory management is no longer an issue, so does the reason for using properties evaporate? is there still any good reason (obviously other than providing public access to instance variables) to use properties anymore?

    Read the article

  • Core Animation bad access on device

    - by user1595102
    I'm trying to do a frame by frame animation with CAlayers. I'm doing this with this tutorial http://mysterycoconut.com/blog/2011/01/cag1/ but everything works with disable ARC, when I'm try to rewrite code with ARC, it's works on simulator perfectly but on device I got a bad access memory. Layer Class interface #import <Foundation/Foundation.h> #import <QuartzCore/QuartzCore.h> @interface MCSpriteLayer : CALayer { unsigned int sampleIndex; } // SampleIndex needs to be > 0 @property (readwrite, nonatomic) unsigned int sampleIndex; // For use with sample rects set by the delegate + (id)layerWithImage:(CGImageRef)img; - (id)initWithImage:(CGImageRef)img; // If all samples are the same size + (id)layerWithImage:(CGImageRef)img sampleSize:(CGSize)size; - (id)initWithImage:(CGImageRef)img sampleSize:(CGSize)size; // Use this method instead of sprite.sampleIndex to obtain the index currently displayed on screen - (unsigned int)currentSampleIndex; @end Layer Class implementation @implementation MCSpriteLayer @synthesize sampleIndex; - (id)initWithImage:(CGImageRef)img; { self = [super init]; if (self != nil) { self.contents = (__bridge id)img; sampleIndex = 1; } return self; } + (id)layerWithImage:(CGImageRef)img; { MCSpriteLayer *layer = [(MCSpriteLayer*)[self alloc] initWithImage:img]; return layer ; } - (id)initWithImage:(CGImageRef)img sampleSize:(CGSize)size; { self = [self initWithImage:img]; if (self != nil) { CGSize sampleSizeNormalized = CGSizeMake(size.width/CGImageGetWidth(img), size.height/CGImageGetHeight(img)); self.bounds = CGRectMake( 0, 0, size.width, size.height ); self.contentsRect = CGRectMake( 0, 0, sampleSizeNormalized.width, sampleSizeNormalized.height ); } return self; } + (id)layerWithImage:(CGImageRef)img sampleSize:(CGSize)size; { MCSpriteLayer *layer = [[self alloc] initWithImage:img sampleSize:size]; return layer; } + (BOOL)needsDisplayForKey:(NSString *)key; { return [key isEqualToString:@"sampleIndex"]; } // contentsRect or bounds changes are not animated + (id < CAAction >)defaultActionForKey:(NSString *)aKey; { if ([aKey isEqualToString:@"contentsRect"] || [aKey isEqualToString:@"bounds"]) return (id < CAAction >)[NSNull null]; return [super defaultActionForKey:aKey]; } - (unsigned int)currentSampleIndex; { return ((MCSpriteLayer*)[self presentationLayer]).sampleIndex; } // Implement displayLayer: on the delegate to override how sample rectangles are calculated; remember to use currentSampleIndex, ignore sampleIndex == 0, and set the layer's bounds - (void)display; { if ([self.delegate respondsToSelector:@selector(displayLayer:)]) { [self.delegate displayLayer:self]; return; } unsigned int currentSampleIndex = [self currentSampleIndex]; if (!currentSampleIndex) return; CGSize sampleSize = self.contentsRect.size; self.contentsRect = CGRectMake( ((currentSampleIndex - 1) % (int)(1/sampleSize.width)) * sampleSize.width, ((currentSampleIndex - 1) / (int)(1/sampleSize.width)) * sampleSize.height, sampleSize.width, sampleSize.height ); } @end I create the layer on viewDidAppear and start animate by clicking on button, but after init I got a bad access error -(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; NSString *path = [[NSBundle mainBundle] pathForResource:@"mama_default.png" ofType:nil]; CGImageRef richterImg = [UIImage imageWithContentsOfFile:path].CGImage; CGSize fixedSize = animacja.frame.size; NSLog(@"wid: %f, heigh: %f", animacja.frame.size.width, animacja.frame.size.height); NSLog(@"%f", animacja.frame.size.width); richter = [MCSpriteLayer layerWithImage:richterImg sampleSize:fixedSize]; animacja.hidden = 1; richter.position = animacja.center; [self.view.layer addSublayer:richter]; } -(IBAction)animacja:(id)sender { if ([richter animationForKey:@"sampleIndex"]) {NSLog(@"jest"); } if (! [richter animationForKey:@"sampleIndex"]) { CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"]; anim.fromValue = [NSNumber numberWithInt:0]; anim.toValue = [NSNumber numberWithInt:22]; anim.duration = 4; anim.repeatCount = 1; [richter addAnimation:anim forKey:@"sampleIndex"]; } } Have you got any idea how to fix it? Thanks a lot.

    Read the article

  • UIVIewController not released when view is dismissed

    - by Nelson Ko
    I have a main view, mainWindow, which presents a couple of buttons. Both buttons create a new UIViewController (mapViewController), but one will start a game and the other will resume it. Both buttons are linked via StoryBoard to the same View. They are segued to modal views as I'm not using the NavigationController. So in a typical game, if a person starts a game, but then goes back to the main menu, he triggers: [self dismissViewControllerAnimated:YES completion:nil ]; to return to the main menu. I would assume the view controller is released at this point. The user resumes the game with the second button by opening another instance of mapViewController. What is happening, tho, is some touch events will trigger methods on the original instance (and write status updates to them - therefore invisible to the current view). When I put a breakpoint in the mapViewController code, I can see the instance will be one or the other (one of which should be released). I have tried putting a delegate to the mainWindow clearing the view: [self.delegate clearMapView]; where in the mainWindow - (void) clearMapView{ gameWindow = nil; } I have also tried self.view=nil; in the mapViewController. The mapViewController code contains MVC code, where the model is static. I wonder if this may prevent ARC from releasing the view. The model.m contains: static CanShieldModel *sharedInstance; + (CanShieldModel *) sharedModel { @synchronized(self) { if (!sharedInstance) sharedInstance = [[CanShieldModel alloc] init]; return sharedInstance; } return sharedInstance; } Another post which may have a lead, but so far not successful, is UIViewController not being released when popped I have in ViewDidLoad: // checks to see if app goes inactive - saves. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resignActive) name:UIApplicationWillResignActiveNotification object:nil]; with the corresponding in ViewDidUnload: [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil]; Does anyone have any suggestions? EDIT: - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ NSString *identifier = segue.identifier; if ([identifier isEqualToString: @"Start Game"]){ gameWindow = (ViewController *)[segue destinationViewController]; gameWindow.newgame=-1; gameWindow.delegate = self; } else if ([identifier isEqualToString: @"Resume Game"]){ gameWindow = (ViewController *)[segue destinationViewController]; gameWindow.newgame=0; gameWindow.delegate = self;

    Read the article

  • UINavigationController not working under ARC in iPhone

    - by user1811427
    I have creared a new project "Empty Application" template in Xcode 4.3, it is having only two classes AppDelegate.h & .m I cheaked with ARC to use automatic reference count while creating the app. I added two new files "RootViewController" & "NewProjectViewControllers". I implemented code to set navigation controller as follows in AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. rootViewController = [[MainViewController alloc] init]; UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:rootViewController]; [self.window addSubview:navigation.view]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } and in hte home view (Root view controller) implemented as follows - (void)viewDidLoad { [super viewDidLoad]; self.title = @"Projects"; UINavigationBar *navigationBar = [self.navigationController navigationBar]; [navigationBar setTintColor: [UIColor colorWithRed:10/255.0f green:21/255.0f blue:51/255.0f alpha:1.0f]]; //To set the customised bar item UIButton *rightBarBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [rightBarBtn setBackgroundImage:[UIImage imageNamed:@"plus_new.png"] forState:UIControlStateNormal]; rightBarBtn.frame=CGRectMake(0.0, 100.0, 30.0, 30.0); [rightBarBtn addTarget:self action:@selector(addProject) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem* rightBarItem = [[UIBarButtonItem alloc] initWithCustomView:rightBarBtn]; self.navigationItem.rightBarButtonItem = rightBarItem; // Do any additional setup after loading the view from its nib. } - (void) addProject { NewProjViewController *editProject = [[NewProjViewController alloc] init]; [self.navigationController pushViewController:editProject animated:YES]; NSLog(@"xxxxxxxxxxxxxxx"); } But since i used ARC the navigation may dealoc immediately and it doesn't work, All the actions in method works except push to the next view if i do same thing with out ARC it works fine How to resolve this issue..? Thanks in advance

    Read the article

  • UIDocumentInteractionController & ARC: [UIPopoverController dealloc] reached while popover is still visible

    - by muffel
    This issue or similar issues have been discussed here before, but I didn't find any working solution for me. I am using the following code to display a UIDocumentInteractionController on an ARC-enabled iOS 7 project: - (void) exportDoc{ // [...] docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]]; docController.delegate = self; [docController presentOpenInMenuFromBarButtonItem:mainMenuButton animated:YES]; } First I didn't want to create a property that holds the controller reference, but as many people said that there are not alternatives to it. It is defined as @property (strong) UIDocumentInteractionController* docController; exportDoc is run in the main thread using NSOperationQueue. Whenever it is executed, I get the following error message: Terminating app due to uncaught exception 'NSGenericException', reason: '-[UIPopoverController dealloc] reached while popover is still visible.' This is what the backtrace says: (lldb) bt * thread #1: tid = 0x1c97d9, 0x000000019a23c1c0 libobjc.A.dylibobjc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1 frame #0: 0x000000019a23c1c0 libobjc.A.dylibobjc_exception_throw frame #1: 0x000000018d982e90 CoreFoundation+[NSException raise:format:] + 128 frame #2: 0x0000000190bc348c UIKit-[UIPopoverController dealloc] + 96 frame #3: 0x0000000190e18fc8 UIKit-[UIDocumentInteractionController dealloc] + 168 frame #4: 0x000000019a255474 libobjc.A.dylib(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 524 frame #5: 0x000000018d881988 CoreFoundation_CFAutoreleasePoolPop + 28 frame #6: 0x000000018e42cb18 Foundation-[NSOperationInternal _start:] + 892 frame #7: 0x000000018e4eea38 Foundation__NSOQSchedule_f + 76 frame #8: 0x000000019a813fd4 libdispatch.dylib_dispatch_client_callout + 16 frame #9: 0x000000019a8171dc libdispatch.dylib_dispatch_main_queue_callback_4CF + 336 frame #10: 0x000000018d942c2c CoreFoundation__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 12 frame #11: 0x000000018d940f6c CoreFoundation__CFRunLoopRun + 1452 frame #12: 0x000000018d881c20 CoreFoundationCFRunLoopRunSpecific + 452 frame #13: 0x0000000193511c0c GraphicsServicesGSEventRunModal + 168 frame #14: 0x00000001909b2fdc UIKitUIApplicationMain + 1156 * frame #15: 0x000000010000947c MyApplicationmain(argc=1, argv=0x000000016fdfbc80) + 108 at main.m:16 frame #16: 0x000000019a82faa0 libdyld.dylibstart + 4 As far as I understand the autoreleasepool just releases the controller. Shouldn't this be prevented by using a strong property just as I did? Do you have any idea what the problem can be and how I can solve it?

    Read the article

  • Disable ARC with Xcode 5

    - by user2187565
    First, sorry for my bad english, I'm french and had 15years old but StackOverFlow is for me the best forum for developers. So, in the previous versions of Xcode, we can disable ARC (Automatic Reference Counting) in the project settings when we create the project. Not now with Xcode 5 and ARC to pose me a problem: with an property list file, for the reading step, Xcode send me an error: "implicit conversion of 'int' to 'id' is disallowed with ARC". I had not the problem with the same code with Xcode 4. In my property list file, The keys are numbers and also in my viewController.m . NIKOS M.: No problem, but I don't see how I can add compiler flag with the 5th version of Xcode. The code (with french string...): NSString *error; NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *plistPath = [rootPath stringByAppendingPathComponent:@"Save.plist"]; NSArray *keys = [NSArray arrayWithObjects:@"valeurCompteur1", @"valeurCompteur2", @"valeurCompteur3", @"valeurCompteur4", @"valeurCompteur5", @"nomCompteur1", @"nomCompteur2", @"nomCompteur3", @"nomCompteur4", @"nomCompteur5", nil]; NSArray *objs = [NSArray arrayWithObjects: compteur1, compteur2, compteur3, compteur4, compteur5, nameC1, nameC2, nameC3, nameC4, nameC5, nil]; REVIEW: When I disallow ARC for the target, an warning persist. How I can resolve that please ? Thank you very much.

    Read the article

  • ARC and __unsafe_unretained

    - by J Shapiro
    I think I have a pretty good understanding of ARC and the proper use cases for selecting an appropriate lifetime qualifiers (__strong, __weak, __unsafe_unretained, and __autoreleasing). However, in my testing, I've found one example that doesn't make sense to me. As I understand it, both __weak and __unsafe_unretained do not add a retain count. Therefore, if there are no other __strong pointers to the object, it is instantly deallocated. The only difference in this process is that __weak pointers are set to nil, and __unsafe_unretained pointers are left alone. If I create a __weak pointer to a simple, custom object (composed of one NSString property), I see the expected (null) value when trying to access a property: Test * __weak myTest = [[Test alloc] init]; myTest.myVal = @"Hi!"; NSLog(@"Value: %@", myTest.myVal); // Prints Value: (null) Similarly, I would expect the __unsafe_unretained lifetime qualifier to cause a crash, due to the resulting dangling pointer. However, it doesn't. In this next test, I see the actual value: Test * __unsafe_unretained myTest = [[Test alloc] init]; myTest.myVal = @"Hi!"; NSLog(@"Value: %@", myTest.myVal); // Prints Value: Hi! Why doesn't the __unsafe_unretained object become deallocated?

    Read the article

  • UIViewController maintains state after being nilled

    - by Eric
    In my app, I made a BookViewController class that displays and animates the pages of a book and a MainMenuViewController class that displays a set of books the user can read. In the latter class, when the user taps on one of the books, a function is called that should create a completely new instance of BookViewController, but for some reason the instance maintains its state (i.e. it resumes from the page the user left off). How can this be if I set it to nil? What am I missing here? (Note that I'm using ARC). MainMenuViewController.m @interface MainMenuViewController () @property (strong) BookViewController *bookViewController; @end @implementation MainMenuViewController @synthesize bookViewController; -(void)bookTapped:(UIButton *)sender{ NSString *bookTitle; if(sender == book1button) bookTitle = @"book1"; else if(sender == book2button) bookTitle = @"book2"; bookViewController = nil; bookViewController = [[BookViewController alloc] initWithBookTitle:bookTitle]; [self presentViewController:bookViewController animated:YES completion:nil]; } BookViewController.h @interface BookViewController : UIViewController -(id)initWithBookTitle:(NSString *)bookTitle; @end BookViewController.m @implementation BookViewController -(id)initWithBookTitle:(NSString *)theBookTitle{ self = [super init]; if(self){ bookTitle = [NSString stringWithFormat:@"%@", theBookTitle]; [self setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; NSLog(@"init a BookViewController with bookTitle: %@", bookTitle); } return self; } Every time a book is tapped, bookTapped: is called, and thee console always prints: 2012-08-31 16:29:51.750 AppName[25713:c07] init a BookViewController with bookTitle: book1 So if a new instance of BookViewController is being created, how come it seems to be returning the old one?

    Read the article

  • Objective C @autoreleasepool directive

    - by Cemre
    I am reading a book which says (if I am not getting it wrong) wrapping some code with @autoreleasepool statement enables the ARC. First of all is this the case ? My second concern is when I am doing some iOS example programs, although I enable ARC when creating a new project, I never see this directive being used anywhere (in the automatically generated code). Does this mean that ARC is not being used ? Any ideas/pointers is appreciated.

    Read the article

  • iOS: Releasing Object Thats In Use (ARC)

    - by RileyE
    I have an object that I have created that subscribes to some NSNotificationCenter notifications, but it is being released, since I don't have a pointer to the instantiation. The instantiation has a delegate that will call a method back to another class I have, so I felt it unnecessary to also have a pointer to it, since the pointer doesn't serve any purpose. Basically, I have an instantiation of a class, DelegateListener (name is just for example purposes), which subscribes to some of the default NSNotificationCeneter's notifications. This instantiation isn't assigned to any pointer after the instantiation ends. The instantiation, however, has a property, delegate. I assign a value to that delegate during the instantiation. That delegate implements methods that I want the DelegateListener to call when the notifications that it subscribed to fire. The problem with this is that the instantiation of DelegateListener that I create gets released, unless if I assign it to a retained pointer. Is there a way to avoid this automatic release of my DelegateListener instantiation within ARC?

    Read the article

  • ref and out parameters in C# and cannot be marked as variant.

    - by Water Cooler v2
    What does the statement mean? From here ref and out parameters in C# and cannot be marked as variant. 1) Does it mean that the following can not be done. public class SomeClass<R, A>: IVariant<R, A> { public virtual R DoSomething( ref A args ) { return null; } } 2) Or does it mean I cannot have the following. public delegate R Reader<out R, in A>(A arg, string s); public static void AssignReadFromPeonMethodToDelegate(ref Reader<object, Peon> pReader) { pReader = ReadFromPeon; } static object ReadFromPeon(Peon p, string propertyName) { return p.GetType().GetField(propertyName).GetValue(p); } static Reader<object, Peon> pReader; static void Main(string[] args) { AssignReadFromPeonMethodToDelegate(ref pReader); bCanReadWrite = (bool)pReader(peon, "CanReadWrite"); Console.WriteLine("Press any key to quit..."); Console.ReadKey(); } I tried (2) and it worked.

    Read the article

  • How do I compare 2 fields and return the lowest value of each record?

    - by BigRob
    I'm slowly learning access to make a database of products and suppliers for my parents' business. What i've got is a table of products indexed by our product reference and 2 more tables for 2 different suppliers that contains the suppliers product reference and price that links with our reference. I've made a query that performs a left outer join such that it returns a table of our products with each supplier's reference and price, i.e: Ref | Product Name | Supplier 1 Ref | Supplier 1 Price | Supplier 2 Ref | Supplier 2 Price Here's the query I used: SELECT Catalog.Ref, Catalog.[Product Name], Catalog.Price, [D Products].[Supplier Ref], [D Products].Cost, [GS Products].[Supplier Ref], [GS Products].Cost FROM ([Catalog] LEFT JOIN [D Products] ON Catalog.Ref = [D Products].Ref) LEFT JOIN [GS Products] ON Catalog.Ref = [GS Products].Ref; Not all products are available from both suppliers, hence the outer join. What I want to do (with a query?) is to take the table produced by the query above and simply show the product reference, cheapest supplier reference and cheapest supplier price, i.e: Ref | Cheapest Suppplier Ref | Cheapest Supplier Price Unfortunately my SQL knowledge isn't quite good enough to figure this out, but if anyone can help i'd really appreciate it. Thanks, Rob

    Read the article

  • Why can't we use strong ref cursor with dynamic SQL Statement?

    - by Vineet
    Hi ALL, I am trying to use a strong ref cur with dynamic sql statment but it is giving out an error,but when i use weak cursor it works,Please explain what is the reason and please forward me any link of oracle server architect containing matter about how compilation and parsing is done in Oracle server. THIS is the error along with code. ERROR at line 6: ORA-06550: line 6, column 7: PLS-00455: cursor 'EMP_REF_CUR' cannot be used in dynamic SQL OPEN statement ORA-06550: line 6, column 2: PL/SQL: Statement ignored declare type ref_cur_type IS REF CURSOR RETURN employees%ROWTYPE; --Creating a strong REF cursor,employees is a table emp_ref_cur ref_cur_type; emp_rec employees%ROWTYPE; BEGIN OPEN emp_ref_cur FOR 'SELECT * FROM employees'; LOOP FETCH emp_ref_cur INTO emp_rec; EXIT WHEN emp_ref_cur%NOTFOUND; END lOOP; END;

    Read the article

  • How to send hashed data in SOAP request body?

    - by understack
    I want to imitate following request using Zend_Soap_Client for this wsdl. <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:clr="http://schemas.microsoft.com/soap/encoding/clr/1.0" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Header> <h3:__MethodSignature xsi:type="SOAP-ENC:methodSignature" xmlns:h3="http://schemas.microsoft.com/clr/soap/messageProperties" SOAP-ENC:root="1" xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections">xsd:string a2:Hashtable</h3:__MethodSignature> </SOAP-ENV:Header> <SOAP-ENV:Body> <i4:ReturnDataSet id="ref-1" xmlns:i4="http://schemas.microsoft.com/clr/nsassem/Interface.IRptSchedule/Interface"> <sProc id="ref-5">BU</sProc> <ht href="#ref-6"/> </i4:ReturnDataSet><br/> <a2:Hashtable id="ref-6" xmlns:a2="http://schemas.microsoft.com/clr/ns/System.Collections"> <LoadFactor>0.72</LoadFactor> <Version>1</Version> <Comparer xsi:null="1"/> <HashCodeProvider xsi:null="1"/> <HashSize>11</HashSize> <Keys href="#ref-7"/> <Values href="#ref-8"/> </a2:Hashtable> <SOAP-ENC:Array id="ref-7" SOAP-ENC:arrayType="xsd:anyType[1]"> <item id="ref-9" xsi:type="SOAP-ENC:string">@AppName</item> </SOAP-ENC:Array><br/> <SOAP-ENC:Array id="ref-8" SOAP-ENC:arrayType="xsd:anyType[1]"> <item id="ref-10" xsi:type="SOAP-ENC:string">AAGENT</item> </SOAP-ENC:Array> </SOAP-ENV:Body> </SOAP-ENV:Envelope> It seems somehow I've to send hashed "ref-7" and "ref-8" array embedded inside body? How can I do this? Function ReturnDataSet takes two parameters, how can I send additional "ref-7" and "ref-8" array data? $client = new SoapClient($wsdl_url, array('soap_version' => SOAP_1_1)); $result = $client->ReturnDataset("BU", $ht); I don't know how to set $ht, so that hashed data is sent as different body entry. Thanks.

    Read the article

  • Recursive insert-method for a linked list

    - by user3726477
    I'm learning C# and I've made a recursive insert-method for a linked list: public static int recursiveInsert(ref int value, ref MyLinkedList list) { if (list == null) return new MyLinkedList(value, null); else { list.next = recursiveInsert(ref int value, ref list.next); return list; } } How would you modify this method to make the recursive call look like this: recursiveInsert(value, ref list.next) instead of: list.next = recursiveInsert(ref int value, ref list.next);

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >