Search Results

Search found 1263 results on 51 pages for 'retain'.

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

  • Problem with parsing strings

    - by Peter Small
    I am trying to put a line of dialog on each of a series of images. To match the dialog line with the correct image, I end each line with a forward slash (/) followed by a number to identify the matching image. I then parse each line to get the dialog and then the reference number for the image. It all works fine except that when I put the dialog line into a textView I get the whole line in the textView instead of the dialog part. What is confusing is that the console seems to indicate that the parsing of the dialog line has been carried out correctly. Here are the details of my coding: @interface DialogSequence_1ViewController : UIViewController { IBOutlet UIImageView *theImage; IBOutlet UITextView *fullDialog; IBOutlet UITextView *selectedDialog; IBOutlet UIButton *test_1; IBOutlet UIButton *test_2; IBOutlet UIButton *test_3; NSArray *arrayLines; IBOutlet UISlider *readingSpeed; NSArray *cartoonViews; NSMutableString *dialog; NSMutableArray *dialogLineSections; int lNum; } @property (retain,nonatomic) UITextView *fullDialog; @property (retain,nonatomic) UITextView *selectedDialog; @property (retain,nonatomic) UIButton *test_1; @property (retain,nonatomic) UIButton *test_2; @property (retain,nonatomic) UIButton *test_3; @property (retain,nonatomic) NSArray *arrayLines; @property (retain,nonatomic) NSMutableString *dialog; @property (retain,nonatomic) NSMutableArray *dialogLineSections; @property (retain,nonatomic) UIImageView *theImage; @property (retain,nonatomic) UISlider *readingSpeed; -(IBAction)start:(id)sender; -(IBAction)counter:(id)sender; -(IBAction)runNextLine:(id)sender; @end @implementation DialogSequence_1ViewController @synthesize fullDialog; @synthesize selectedDialog; @synthesize test_1; @synthesize test_2; @synthesize test_3; @synthesize arrayLines; @synthesize dialog; @synthesize theImage; @synthesize readingSpeed; @synthesize dialogLineSections; -(IBAction)runNextLine:(id)sender{ //Get dialog line to display from the arrayLines array NSMutableString *dialogLineDetails; dialogLineDetails =[arrayLines objectAtIndex:lNum]; NSLog(@"dialogLineDetails = %@",dialogLineDetails); //Parse the dialog line dialogLineSections = [dialogLineDetails componentsSeparatedByString: @"/"]; selectedDialog.text =[dialogLineSections objectAtIndex: 0]; NSLog(@"Dialog part of line = %@",[dialogLineSections objectAtIndex: 0]); NSMutableString *imageBit; imageBit = [dialogLineSections objectAtIndex: 1]; NSLog(@"Image code = %@",imageBit); //Select right image int im = [imageBit intValue]; NSLog(@"imageChoiceInteger = %i",im); //------more code } I get a warning on the line: dialogLineSections = [dialogLineDetails componentsSeparatedByString: @"/"]; warning: incompatible Objective-C types assigning 'struct NSArray *', expected 'struct NSMutableArray *' I don't quite understand this and have tried to change the types but to no avail. Would be grateful for some advice here.

    Read the article

  • NSData in CoreData is not saving properly

    - by abisson
    I am currently trying to store images I download from the web into an NSManagedObject class so that I don't have to redownload it every single time the application is opened. I currently have these two classes. Plant.h @property (nonatomic, retain) NSString * name; @property (nonatomic, retain) PlantPicture *picture; PlantPicture.h @property (nonatomic, retain) NSString * bucketName; @property (nonatomic, retain) NSString * creationDate; @property (nonatomic, retain) NSData * pictureData; @property (nonatomic, retain) NSString * slug; @property (nonatomic, retain) NSString * urlWithBucket; Now I do the following: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { PlantCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath]; Plant *plant = [self.fetchedResultsController objectAtIndexPath:indexPath]; cell.plantLabel.text = plant.name; if(plant.picture.pictureData == nil) { NSLog(@"Downloading"); NSMutableString *pictureUrl = [[NSMutableString alloc]initWithString:amazonS3BaseURL]; [pictureUrl appendString:plant.picture.urlWithBucket]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:pictureUrl]]; AFImageRequestOperation *imageOperation = [AFImageRequestOperation imageRequestOperationWithRequest:request success:^(UIImage *image) { cell.plantImageView.image = image; plant.picture.pictureData = [[NSData alloc]initWithData:UIImageJPEGRepresentation(image, 1.0)]; NSError *error = nil; if (![_managedObjectContext save:&error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); } }]; [imageOperation start]; } else { NSLog(@"Already"); cell.plantImageView.image = [UIImage imageWithData:plant.picture.pictureData]; } NSLog(@"%@", plant.name); return cell; } The plant information is present, as well as the picture object. However, the NSData itself is NEVER saved throughout the application opening and closing. I always have to REDOWNLOAD the image! Any ideas!? [Very new to CoreData... sorry if it is easy!] thanks!

    Read the article

  • iphone: Help with AudioToolbox Leak: Stack trace/code included here...

    - by editor guy
    Part of this app is a "Scream" button that plays random screams from cast members of a TV show. I have to bang on the app quite a while to see a memory leak in Instruments, but it's there, occasionally coming up (every 45 seconds to 2 minutes.) The leak is 3.50kb when it occurs. Haven't been able to crack it for several hours. Any help appreciated. Instruments says this is the offending code line: [appSoundPlayer play]; that's linked to from line 9 of the below stack trace: 0 libSystem.B.dylib malloc 1 libSystem.B.dylib pthread_create 2 AudioToolbox CAPThread::Start() 3 AudioToolbox GenericRunLoopThread::Start() 4 AudioToolbox AudioQueueNew(bool, AudioStreamBasicDescription const*, TCACallback const&, CACallbackTarget const&, unsigned long, OpaqueAudioQueue*) 5 AudioToolbox AudioQueueNewOutput 6 AVFoundation allocAudioQueue(AVAudioPlayer, AudioPlayerImpl*) 7 AVFoundation prepareToPlayQueue(AVAudioPlayer*, AudioPlayerImpl*) 8 AVFoundation -[AVAudioPlayer prepareToPlay] 9 Scream Queens -[ScreamViewController scream:] /Users/laptop2/Desktop/ScreamQueens Versions/ScreamQueens25/Scream Queens/Classes/../ScreamViewController.m:210 10 CoreFoundation -[NSObject performSelector:withObject:withObject:] 11 UIKit -[UIApplication sendAction:to:from:forEvent:] 12 UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] 13 UIKit -[UIControl sendAction:to:forEvent:] 14 UIKit -[UIControl(Internal) _sendActionsForEvents:withEvent:] 15 UIKit -[UIControl touchesEnded:withEvent:] 16 UIKit -[UIWindow _sendTouchesForEvent:] 17 UIKit -[UIWindow sendEvent:] 18 UIKit -[UIApplication sendEvent:] 19 UIKit _UIApplicationHandleEvent 20 GraphicsServices PurpleEventCallback 21 CoreFoundation CFRunLoopRunSpecific 22 CoreFoundation CFRunLoopRunInMode 23 GraphicsServices GSEventRunModal 24 UIKit -[UIApplication _run] 25 UIKit UIApplicationMain 26 Scream Queens main /Users/laptop2/Desktop/ScreamQueens Versions/ScreamQueens25/Scream Queens/main.m:14 27 Scream Queens start Here's .h: #import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> #import <MediaPlayer/MediaPlayer.h> #import <AudioToolbox/AudioToolbox.h> #import <MessageUI/MessageUI.h> #import <MessageUI/MFMailComposeViewController.h> @interface ScreamViewController : UIViewController <UIApplicationDelegate, AVAudioPlayerDelegate, MFMailComposeViewControllerDelegate> { //AudioPlayer related AVAudioPlayer *appSoundPlayer; NSURL *soundFileURL; BOOL interruptedOnPlayback; BOOL playing; //Scream button related IBOutlet UIButton *screamButton; int currentScreamIndex; NSString *currentScream; NSMutableArray *screams; NSMutableArray *personScreaming; NSMutableArray *photoArray; int currentSayingsIndex; NSString *currentButtonSaying; NSMutableArray *funnyButtonSayings; IBOutlet UILabel *funnyButtonSayingsLabel; IBOutlet UILabel *personScreamingField; IBOutlet UIImageView *personScreamingImage; //Mailing the scream related IBOutlet UILabel *mailStatusMessage; IBOutlet UIButton *shareButton; } //AudioPlayer related @property (nonatomic, retain) AVAudioPlayer *appSoundPlayer; @property (nonatomic, retain) NSURL *soundFileURL; @property (readwrite) BOOL interruptedOnPlayback; @property (readwrite) BOOL playing; //Scream button related @property (nonatomic, retain) UIButton *screamButton; @property (nonatomic, retain) NSMutableArray *screams; @property (nonatomic, retain) NSMutableArray *personScreaming; @property (nonatomic, retain) NSMutableArray *photoArray; @property (nonatomic, retain) UILabel *personScreamingField; @property (nonatomic, retain) UIImageView *personScreamingImage; @property (nonatomic, retain) NSMutableArray *funnyButtonSayings; @property (nonatomic, retain) UILabel *funnyButtonSayingsLabel; //Mailing the scream related @property (nonatomic, retain) IBOutlet UILabel *mailStatusMessage; @property (nonatomic, retain) IBOutlet UIButton *shareButton; //Scream Button - (IBAction) scream: (id) sender; //Mail the scream - (IBAction) showPicker: (id)sender; - (void)displayComposerSheet; - (void)launchMailAppOnDevice; @end Here's the top of .m: #import "ScreamViewController.h" //top of code has Audio session callback function for responding to audio route changes (from Apple's code), then my code continues... @implementation ScreamViewController @synthesize appSoundPlayer; // AVAudioPlayer object for playing the selected scream @synthesize soundFileURL; // Path to the scream @synthesize interruptedOnPlayback; // Was application interrupted during audio playback @synthesize playing; // Track playing/not playing state @synthesize screamButton; //Press this button, girls scream. @synthesize screams; //Mutable array holding strings pointing to sound files of screams. @synthesize personScreaming; //Mutable array tracking the person doing the screaming @synthesize photoArray; //Mutable array holding strings pointing to photos of screaming girls @synthesize personScreamingField; //Field updates to announce which girl is screaming. @synthesize personScreamingImage; //Updates to show image of the screamer. @synthesize funnyButtonSayings; //Mutable array holding the sayings @synthesize funnyButtonSayingsLabel; //Label that updates with the funnyButtonSayings @synthesize mailStatusMessage; //did the email go out @synthesize shareButton; //share scream via email Next line begins the block with the offending code: - (IBAction) scream: (id) sender { //Play a click sound effect SystemSoundID soundID; NSString *sfxPath = [[NSBundle mainBundle] pathForResource:@"aClick" ofType:@"caf"]; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:sfxPath],&soundID); AudioServicesPlaySystemSound (soundID); // Because someone may slam the scream button over and over, //must stop current sound, then begin next if ([self appSoundPlayer] != nil) { [[self appSoundPlayer] setDelegate:nil]; [[self appSoundPlayer] stop]; [self setAppSoundPlayer: nil]; } //after selecting a random index in the array (did that in View Did Load), //we move to the next scream on each click. //First check... //Are we past the end of the array? if (currentScreamIndex == [screams count]) { currentScreamIndex = 0; } //Get the string at the index in the personScreaming array currentScream = [screams objectAtIndex: currentScreamIndex]; //Get the string at the index in the personScreaming array NSString *screamer = [personScreaming objectAtIndex:currentScreamIndex]; //Log the string to the console NSLog (@"playing scream: %@", screamer); // Display the string in the personScreamingField field NSString *listScreamer = [NSString stringWithFormat:@"scream by: %@", screamer]; [personScreamingField setText:listScreamer]; // Gets the file system path to the scream to play. NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: currentScream ofType: @"caf"]; // Converts the sound's file path to an NSURL object NSURL *newURL = [[NSURL alloc] initFileURLWithPath: soundFilePath]; self.soundFileURL = newURL; [newURL release]; [[AVAudioSession sharedInstance] setDelegate: self]; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil]; // Registers the audio route change listener callback function AudioSessionAddPropertyListener ( kAudioSessionProperty_AudioRouteChange, audioRouteChangeListenerCallback, self ); // Activates the audio session. NSError *activationError = nil; [[AVAudioSession sharedInstance] setActive: YES error: &activationError]; // Instantiates the AVAudioPlayer object, initializing it with the sound AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error: nil]; //Error check and continue if (newPlayer != nil) { self.appSoundPlayer = newPlayer; [newPlayer release]; [appSoundPlayer prepareToPlay]; [appSoundPlayer setVolume: 1.0]; [appSoundPlayer setDelegate:self]; //NEXT LINE IS FLAGGED BY INSTRUMENTS AS LEAKY [appSoundPlayer play]; playing = YES; //Get the string at the index in the photoArray array NSString *screamerPic = [photoArray objectAtIndex:currentScreamIndex]; //Log the string to the console NSLog (@"displaying photo: %@", screamerPic); // Display the image of the person screaming personScreamingImage.image = [UIImage imageNamed:screamerPic]; //show the share button shareButton.hidden = NO; mailStatusMessage.hidden = NO; mailStatusMessage.text = @"share!"; //Get the string at the index in the funnySayings array currentSayingsIndex = random() % [funnyButtonSayings count]; currentButtonSaying = [funnyButtonSayings objectAtIndex: currentSayingsIndex]; NSString *theSaying = [funnyButtonSayings objectAtIndex:currentSayingsIndex]; [funnyButtonSayingsLabel setText: theSaying]; currentScreamIndex++; } } Here's my dealloc: - (void)dealloc { [appSoundPlayer stop]; [appSoundPlayer release], appSoundPlayer = nil; [screamButton release], screamButton = nil; [mailStatusMessage release], mailStatusMessage = nil; [personScreamingField release], personScreamingField = nil; [personScreamingImage release], personScreamingImage = nil; [funnyButtonSayings release], funnyButtonSayings = nil; [funnyButtonSayingsLabel release], funnyButtonSayingsLabel = nil; [screams release], screams = nil; [personScreaming release], personScreaming = nil; [soundFileURL release]; [super dealloc]; } @end Thanks so much for reading this far! Any input appreciated.

    Read the article

  • How to retain the values of the filters and its result using asp.net c#?

    - by user144842
    Question:- Page is a typical search page with few filters on it. When search for records based on filters, it shows result in Gridview. From grid view records, user can click on any record to see the details which takes the focus on new page. Its working fine so far. Now when user comes back from details page to search page. I am loosing selected filters values and no result in grid view. How can i display selected filters and its results in gridview when user is coming back on search page? Any example etc.? FYI, I am using sessions to pass parameters to the ObjectDatasource.

    Read the article

  • How can I retain carriage returns when I'm encrypting data?

    - by William Calleja
    I have this following setup, a textarea named with some data in it that may have carriage returns and another textarea that has style='display:none' in order to make it hidden as follows: <textarea id="myTextarea" onBlur="encryptMyData()"></textarea> <textarea name="encryptedText" style='display:none'></textarea> the user enters data in the first textarea and when that text area loses focus the 'encryptMyData()' javascript function is calling an ajax call to take whatever the user entered in the first textfield, encrypt it using rijndael, and paste it in the encryptedText textarea so that it is stored in the database later. Now what I need to do is this, find a way to convert the carriage returns before encryption to a tag like so [cr] so that when I retrieve the data, all formatting is retained. Any idea how I do this? I'm using asp.net and c# to perform the encryption.

    Read the article

  • iPhone and Core Data: how to retain user-entered data between updates?

    - by Shaggy Frog
    Consider an iPhone application that is a catalogue of animals. The application should allow the user to add custom information for each animal -- let's say a rating (on a scale of 1 to 5), as well as some notes they can enter in about the animal. However, the user won't be able to modify the animal data itself. Assume that when the application gets updated, it should be easy for the (static) catalogue part to change, but we'd like the (dynamic) custom user information part to be retained between updates, so the user doesn't lose any of their custom information. We'd probably want to use Core Data to build this app. Let's also say that we have a previous process already in place to read in animal data to pre-populate the backing (SQLite) store that Core Data uses. We can embed this database file into the application bundle itself, since it doesn't get modified. When a user downloads an update to the application, the new version will include the latest (static) animal catalogue database, so we don't ever have to worry about it being out of date. But, now the tricky part: how do we store the (dynamic) user custom data in a sound manner? My first thought is that the (dynamic) database should be stored in the Documents directory for the app, so application updates don't clobber the existing data. Am I correct? My second thought is that since the (dynamic) user custom data database is not in the same store as the (static) animal catalogue, we can't naively make a relationship between the Rating and the Notes entities (in one database) and the Animal entity (in the other database). In this case, I would imagine one solution would be to have an "animalName" string property in the Rating/Notes entity, and match it up at runtime. Is this the best way to do it, or is there a way to "sync" two different databases in Core Data?

    Read the article

  • How do I tell eclipse to auto-generate or retain stubs when it starts and does a clean build?

    - by Erick Robertson
    I'm working on a Java application that uses JavaSpace. We're developing this in Eclipse. There are a couple instances where we are inserting code into the JavaSpace to do some more advanced space notification logic. Doing this requires that we generate stubs for the classes used within the JavaSpace. We use an external script to generate these stubs. The problem is that whenever Eclipse restarts, it does a clean build of the whole application. When it does this, it deletes all the stubs and we have to regenerate them. I would like to find a way to either tell Eclipse not to remove the _stub.class and _skel.class files within the bin folder where the .class files are placed. Either that, or somehow teach Eclipse to generate the stub files whenever it does a rebuild (and I suppose whenever the source files from which the stubs are generated changes). How can I do one of these, so that we don't have to manually build the stubs every time we start up Eclipse?

    Read the article

  • How to retain headers for all the pages of an exported pdf in php?

    - by udaya
    Hi I am exporting data from php page to pdf when the datas exceeed the page limit the header is not available for the consecutive pages function where i call the export to pdf is function changeDetails() { $bType = $this-input-post('textvalue'); if($bType == "pdf") { $this->load->library('table'); $this->load->plugin('to_pdf'); $data['countrytoword'] = $this->AddEditmodel1->export(); $this->table->set_heading('Country','State','Town','Name'); $out = $this->table->generate($data['countrytoword']); $html = $this->load->view( 'newpdf',$data, true); pdf_create($html, $cur_date); } } This is my view page from which i export data to pdf Name Country State Town Here I am getting the result as page:1 Name country State Town udaya india Tamilnadu kovai chandru srilanka columbo aaaaa page:2 vivek england gggkj gjgjkj in the page 2 i dont get the headers name, country ,state and town

    Read the article

  • objective c - memory managment

    - by Amir
    lets say I have aclass @interface Foo :NSobject { NSstring *a; NSDate *b; } Foo *temp; my question is: when i use [temp retain] does the counter of the members also retain? lets say that i got ref of the class from some method and i want to retain the class do i need to retain each member?

    Read the article

  • How to retain headers for all the pages of an exported word document in php?

    - by udaya
    Hi I exported data from php page to word document but the problm is the header is not available in all pages I got the same problem while i am exporting the datas to pdf but i got the result for that one by using fpdf library In pdf i got the results like this ex page1 slno name 1 udaya 2 sankar In page 2 slno name 3 chendu 4 Akila I want the same kind of result in word how to get that This is the function i used function changeDetails() { $bType = $this->input->post('textvalue'); if($bType == "word") { $this->load->library('table'); $data['countrytoword'] = $this->AddEditmodel1->export(); $this->table->set_heading('Name','Country','State','Town'); $out = $this->table->generate($data['countrytoword']); header("Content-Type: application/vnd.ms-word"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-disposition: attachment; filename=$cur_date.doc"); echo '<br><br>'; echo '<strong>CountryList</strong><br><br>'; print_r($out); } } <? if(isset($countrytoword)) { ?> <table align="center" border="0"> <tr> <td> Name </td> <td> Country </td> <td> State </td> <td> Town </td> </tr> <? foreach($countrytoword as $dsasffd) { ?> <tr> <td><?= $dsasffd['dbName'] ?></td> <td><?= $dsasffd['dbCountry']; ?></td> <td><?= $dsasffd['dbState']; ?></td> <td><?= $dsasffd['dbTown']; ?></td> <? } } ?> </tr> </table>

    Read the article

  • Does a HashMap retain the order of its elements on the next read if it is constructed as a LinkedHas

    - by javanix
    Suppose I have a Java method that returns a HashMap object. Because a LinkedHashMap is a subclass of HashMap, I can return a LinkedHashMap from this method just fine. On the next "read" action (no adding/removing/modifying of K/V pairs), would iterating over the keys of the resulting method (which returns a HashMap) go in the same order as the originating LinkedHashMap, even though the HashMap lacks the key links?

    Read the article

  • how to retain one million of simultanous TCP connections?

    - by cow
    i am to design a server that needs to serve millions of clients that are simultaneously connected with the server via TCP. the data traffic between the server and the clients may be sparse. so bandwidth issue can be ignored. one important requirement is that whenever the server needs to send data to any client it can use the existing TCP connection instead of opening a new connection toward the client (because client can be behind a firewall). does anybody know how to do it and what hardware/software is needed (at the least cost)? thanks in advance for any suggestion.

    Read the article

  • Retain a list of objects and pass it to the create/edit view when validation fails in ASP.NET MVC 2

    - by brainnovative
    I am binding a Foreign key property in my model. I am passing a list of possible values for that property in my model. The model looks something like this: public class UserModel { public bool Email { get; set; } public bool Name { get; set; } public RoleModel Role { get; set; } public IList<RoleModel> Roles { get; set; } } public class RoleModel { public string RoleName { get; set; } } This is what I have in the controller: public ActionResult Create() { IList<RoleModel> roles = RoleModel.FromArray(_userService.GetAllRoles()); UserModel model = new UserModel() { Roles = roles }; return View(model); } In the view I have: <div class="editor-label"> <%= Html.LabelFor(model => model.Role) %> </div> <div class="editor-field"> <%= Html.DropDownListFor(model => model.Role, new SelectList(Model.Roles, "RoleName", "RoleName", Model.Role))%> <%= Html.ValidationMessageFor(model => model.Role)%> </div> What do I need to do to get the list of roles back to my controller to pass it again to the view when validation fails. This is what I need: [HttpPost] public ActionResult Create(UserModel model) { if (ModelState.IsValid) { // insert logic here } //the validation fails so I pass the model again to the view for user to update data but model.Roles is null :( return View(model); } As written in the comments above I need to pass the model with the list of roles again to my view but model.Roles is null. Currently I ask the service again for the roles (model.Roles = RoleModel.FromArray(_userService.GetAllRoles());) but I don't want to add an extra overhead of getting the list from DB when I have already done that.. Anyone knows how to do it?

    Read the article

  • How do I retain a requested url with parameters after redirecting to a login page?

    - by Brent Parker
    I have been asked to set up some authentication for some content on our website using JSP. What I would like to do seems simple to me but I can't quite figure out how to do it in JSP. What I would like to do is this: When a user requests a page that you must be logged in to see, I have a tag that checks their cookies for an authentication token. If it is not there, they are redirected to a login page. After they log in, I want to redirect them back to the page they first requested along with any parameters they were sending. Now, I have the tag that is checking their authentication and redirecting them to the login page. That part is working just fine. But I'm not sure how to maintain the first requested url and parameters so they can be redirected after they login. How might I accomplish this?

    Read the article

  • How to retain focus on an editable html after deleting an element.

    - by Lukasz
    Hello, I have a website with design mode on (aka. content editable = true) with some basic text on it. To that site I hooked up a shortcut so that at any point in the text I can insert an input box that serves me as an autocomplete. For that input however I want it to disappear right after I hit ENTER so that I can continue typing. It is an easy task to just make the input box disappear but I always loose focus from my document. I would greatly appreciate any suggestions on how to make this work?

    Read the article

  • Convert unstructured SVN folders to trunk/branches style and retain history?

    - by joelpt
    I have a SVN repository which is currently structured like so: /versions /1.0.0 /1.0.1 /1.0.2 /1.1.0 /(etc) What happened here is that when it was time to start a new release, a team member would make a copy of the previous version's folder and rename that folder; then add/commit that new folder into SVN. As a consequence, all of the revision history for a given version-folder is limited just to changes made in that version-folder. SVN thinks that each file in each version-folder was created anew at the time of version-folder creation. So what I'd like to do is convert this series of folders into a traditional trunk/branches/tag SVN structure. Is it possible to somehow "reconcile" the revision histories of each of these versioned folders back into one common revision-history tree?

    Read the article

  • How do I filter or retain duplicates in Perl?

    - by manu
    I have one text string which is having some duplicate characters (FFGGHHJKL). These can be made unique by using the positive lookahead: $ perl -pe 's/(.)(?=.*?\1)//g'] For example, with "FFEEDDCCGG", the output is "FEDCG". My question is how to make it work on the numbers (Ex. 212 212 43 43 5689 6689 5689 71 81 === output should be 212 43 5689 6689 71 81) ? Also if we want to have only duplicate records to be given as the output from a file having n rows 212 212 43 43 5689 6689 5689 71 81 66 66 67 68 69 69 69 71 71 52 .. Output: 212 212 43 43 5689 5689 66 66 69 69 69 71 71 How can I do this?

    Read the article

  • I'm trying to pass a string from my first ViewController to my second ViewController but it returns NULL

    - by Dashony
    In my first view controller I have 3 input fields each of them take the user input into and saves it into a string such as: address, username and password as NSUserDefaults. This part works fine. In my second view controller I'm trying to take the 3 strings from first controller (address, username and password) create a html link based on the 3 strings. I've tried many ways to access the 3 strings with no luck, the result I get is NULL. Here is my code: //.h file - first view controller with the 3 input fields CamSetup.h #import <UIKit/UIKit.h> @interface CamSetup : UIViewController <UITextFieldDelegate> { NSString * address; NSString * username; NSString * password; IBOutlet UITextField * addressField; IBOutlet UITextField * usernameField; IBOutlet UITextField * passwordField; } -(IBAction) saveAddress: (id) sender; -(IBAction) saveUsername: (id) sender; -(IBAction) savePassword: (id) sender; @property(nonatomic, retain) UITextField *addressField; @property(nonatomic, retain) UITextField *usernameField; @property(nonatomic, retain) UITextField *passwordField; @property(nonatomic, retain) NSString *address; @property(nonatomic, retain) NSString *username; @property(nonatomic, retain) NSString *password; @end //.m file - first view controller CamSetup.m #import "CamSetup.h" @interface CamSetup () @end @implementation CamSetup @synthesize addressField, usernameField, passwordField, address, username, password; -(IBAction) saveAddress: (id) sender { address = [[NSString alloc] initWithFormat:addressField.text]; [addressField setText:address]; NSUserDefaults *stringDefaultAddress = [NSUserDefaults standardUserDefaults]; [stringDefaultAddress setObject:address forKey:@"stringKey1"]; NSLog(@"String [%@]", address); } -(IBAction) saveUsername: (id) sender { username = [[NSString alloc] initWithFormat:usernameField.text]; [usernameField setText:username]; NSUserDefaults *stringDefaultUsername = [NSUserDefaults standardUserDefaults]; [stringDefaultUsername setObject:username forKey:@"stringKey2"]; NSLog(@"String [%@]", username); } -(IBAction) savePassword: (id) sender { password = [[NSString alloc] initWithFormat:passwordField.text]; [passwordField setText:password]; NSUserDefaults *stringDefaultPassword = [NSUserDefaults standardUserDefaults]; [stringDefaultPassword setObject:password forKey:@"stringKey3"]; NSLog(@"String [%@]", password); } - (void)viewDidLoad { [addressField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey1"]]; [usernameField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey2"]]; [passwordField setText:[[NSUserDefaults standardUserDefaults] objectForKey:@"stringKey3"]]; [super viewDidLoad]; } @end //.h second view controller LiveView.h #import <UIKit/UIKit.h> #import "CamSetup.h" @interface LiveView : UIViewController { NSString *theAddress; NSString *theUsername; NSString *thePassword; CamSetup *camsetup; //here is an instance of the first class } @property (nonatomic, retain) NSString *theAddress; @property (nonatomic, retain) NSString *theUsername; @property (nonatomic, retain) NSString *thePassword; @end //.m second view LiveView.m file #import "LiveView.h" @interface LiveView () @end @implementation LiveView @synthesize theAddress, theUsername, thePassword; - (void)viewDidLoad { [super viewDidLoad]; theUsername = camsetup.username; //this is probably not right? NSLog(@"String [%@]", theUsername); //resut here is NULL NSLog(@"String [%@]", camsetup.username); //and here NULL as well } @end

    Read the article

  • CoreData, transient atribute and EXC_BAD_ACCESS.

    - by Lukasz
    I'm trying to build simple file browser and i'm stuck. I defined classes, build window, add controllers, views.. Everything works but only ONE time. Selecting again Folder in NSTableView or trying to get data from Folder.files causing silent EXC_BAD_ACCESS (code=13, address0x0) from main. Info about files i keep outside of CoreData, in simple class, I don't want to save them: #import <Foundation/Foundation.h> @interface TPDrawersFileInfo : NSObject @property (nonatomic, retain) NSString * filename; @property (nonatomic, retain) NSString * extension; @property (nonatomic, retain) NSDate * creation; @property (nonatomic, retain) NSDate * modified; @property (nonatomic, retain) NSNumber * isFile; @property (nonatomic, retain) NSNumber * size; @property (nonatomic, retain) NSNumber * label; +(TPDrawersFileInfo *) initWithURL: (NSURL *) url; @end @implementation TPDrawersFileInfo +(TPDrawersFileInfo *) initWithURL: (NSURL *) url { TPDrawersFileInfo * new = [[TPDrawersFileInfo alloc] init]; if (new!=nil) { NSFileManager * fileManager = [NSFileManager defaultManager]; NSError * error; NSDictionary * infoDict = [fileManager attributesOfItemAtPath: [url path] error:&error]; id labelValue = nil; [url getResourceValue:&labelValue forKey:NSURLLabelNumberKey error:&error]; new.label = labelValue; new.size = [infoDict objectForKey: @"NSFileSize"]; new.modified = [infoDict objectForKey: @"NSFileModificationDate"]; new.creation = [infoDict objectForKey: @"NSFileCreationDate"]; new.isFile = [NSNumber numberWithBool:[[infoDict objectForKey:@"NSFileType"] isEqualToString:@"NSFileTypeRegular"]]; new.extension = [url pathExtension]; new.filename = [[url lastPathComponent] stringByDeletingPathExtension]; } return new; } Next I have class Folder, which is NSManagesObject subclass // Managed Object class to keep info about folder content @interface Folder : NSManagedObject { NSArray * _files; } @property (nonatomic, retain) NSArray * files; // Array with TPDrawersFileInfo objects @property (nonatomic, retain) NSString * url; // url of folder -(void) reload; //if url changed, load file info again. @end @implementation Folder @synthesize files = _files; @dynamic url; -(void)awakeFromInsert { [self addObserver:self forKeyPath:@"url" options:NSKeyValueObservingOptionNew context:@"url"]; } -(void)awakeFromFetch { [self addObserver:self forKeyPath:@"url" options:NSKeyValueObservingOptionNew context:@"url"]; } -(void)prepareForDeletion { [self removeObserver:self forKeyPath:@"url"]; } -(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (context == @"url") { [self reload]; } } -(void) reload { NSMutableArray * result = [NSMutableArray array]; NSError * error = nil; NSFileManager * fileManager = [NSFileManager defaultManager]; NSString * percented = [self.url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSArray * listDir = [fileManager contentsOfDirectoryAtURL: [NSURL URLWithString: percented] includingPropertiesForKeys: [NSArray arrayWithObject: NSURLCreationDateKey ] options:NSDirectoryEnumerationSkipsHiddenFiles error:&error]; if (error!=nil) {NSLog(@"Error <%@> reading <%@> content", error, self.url);} for (id fileURL in listDir) { TPDrawersFileInfo * fi = [TPDrawersFileInfo initWithURL:fileURL]; [result addObject: fi]; } _files = [NSArray arrayWithArray:result]; } @end In app delegate i defined @interface TPAppDelegate : NSObject <NSApplicationDelegate> { IBOutlet NSArrayController * foldersController; Folder * currentFolder; } - (IBAction)chooseDirectory:(id)sender; // choose folder and - (Folder * ) getFolderObjectForPath: path { //gives Folder object if already exist or nil if not ..... } - (IBAction)chooseDirectory:(id)sender { //Opens panel, asking for url NSOpenPanel * panel = [NSOpenPanel openPanel]; [panel setCanChooseDirectories:YES]; [panel setCanChooseFiles:NO]; [panel setMessage:@"Choose folder to show:"]; NSURL * currentDirectory; if ([panel runModal] == NSOKButton) { currentDirectory = [[panel URLs] objectAtIndex:0]; } Folder * folderObject = [self getFolderObjectForPath:[currentDirectory path]]; if (folderObject) { //if exist: currentFolder = folderObject; } else { // create new one Folder * newFolder = [NSEntityDescription insertNewObjectForEntityForName:@"Folder" inManagedObjectContext:self.managedObjectContext]; [newFolder setValue:[currentDirectory path] forKey:@"url"]; [foldersController addObject:newFolder]; currentFolder = newFolder; } [foldersController setSelectedObjects:[NSArray arrayWithObject:currentFolder]]; } Please help ;)

    Read the article

  • iphone - UIViewController header view errors

    - by Fiona
    Hi there, So to give a little background: I've an app that has a UITableViewController- (ContactDetailViewController) In this view at the top, I require a few labels and buttons, followed by a group style tableview. So I've created a nib file containing these elements. (ContactHeaderView.xib) Then in the viewDidLoad of ContactDetailViewController I've loaded this nib as the headerView. See implementation file below: #import "ContactDetailViewController.h" #import "DisplayInfoViewController.h" #import "ActionViewController.h" @implementation ContactDetailViewController @synthesize name; @synthesize date; @synthesize nextAction; @synthesize nameLabel; @synthesize usernameLabel; @synthesize nextActionTextField; @synthesize dateLabel; @synthesize contactInfoButton; @synthesize backgroundInfoButton; @synthesize actionDoneButton; - (void)viewDidLoad { [super viewDidLoad]; } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } // Customize the number of rows in the table view. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { if (section == 0){ UIViewController *chv = [[[UIViewController alloc] initWithNibName:@"ContactHeaderView" bundle:nil] autorelease]; // self.nameLabel.text = self.name; return chv.view; }else{ return nil; } } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 300.0; } // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Set up the cell... return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Navigation logic may go here. Create and push another view controller. // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil]; // [self.navigationController pushViewController:anotherViewController]; // [anotherViewController release]; } /* // Override to support conditional editing of the table view. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return YES; } */ - (void)dealloc { [name release]; [date release]; [nextAction release]; [nameLabel release]; [usernameLabel release]; [nextActionTextField release]; [dateLabel release]; [contactInfoButton release]; [backgroundInfoButton release]; [actionDoneButton release]; [super dealloc]; } -(IBAction)displayContactInfo:(id)sender{ DisplayInfoViewController *divc = [[DisplayInfoViewController alloc] init]; divc.textView = self.nextAction; divc.title = @"Contact Info"; [self.navigationController pushViewController:divc animated:YES]; [divc release]; } -(IBAction)displayBackgroundInfo:(id)sender{ DisplayInfoViewController *divc = [[DisplayInfoViewController alloc] init]; divc.textView = self.nextAction; divc.title = @"Background Info"; [self.navigationController pushViewController:divc animated:YES]; [divc release]; } -(IBAction)actionDone:(id)sender{ ActionViewController *avc = [[ActionViewController alloc] init]; avc.title = @"Action"; avc.nextAction = self.nextAction; [self.navigationController pushViewController:avc animated:YES]; [avc release]; } @end Here's the Header File: #import <UIKit/UIKit.h> @interface ContactDetailViewController : UITableViewController { NSString *name; NSString *date; NSString *nextAction; IBOutlet UILabel *nameLabel; IBOutlet UILabel *usernameLabel; IBOutlet UITextField *nextActionTextField; IBOutlet UILabel *dateLabel; IBOutlet UIButton *contactInfoButton; IBOutlet UIButton *backgroundInfoButton; IBOutlet UIButton *actionDoneButton; } @property (nonatomic, retain) NSString *name; @property (nonatomic, retain) NSString *date; @property (nonatomic, retain) NSString *nextAction; @property (nonatomic, retain) IBOutlet UILabel *nameLabel; @property (nonatomic, retain) IBOutlet UILabel *usernameLabel; @property (nonatomic, retain) IBOutlet UITextField *nextActionTextField; @property (nonatomic, retain) IBOutlet UILabel *dateLabel; @property (nonatomic, retain) IBOutlet UIButton *contactInfoButton; @property (nonatomic, retain) IBOutlet UIButton *backgroundInfoButton; @property (nonatomic, retain) IBOutlet UIButton *actionDoneButton; -(IBAction)displayContactInfo: (id)sender; -(IBAction)displayBackgroundInfo: (id)sender; -(IBAction)actionDone: (id)sender; @end However when I run it, I get the following error message: * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key nameLabel.' In IB I've hooked up the labels/buttons/textbox to the File's Owner (set the File's Owner Class to: ContactDetailViewController) Anyone any idea what I'm doing wrong? Regards, Fiona

    Read the article

  • How to implement Cocoa copyWithZone on derived object in MonoMac C#?

    - by Justin Aquadro
    I'm currently porting a small Winforms-based .NET application to use a native Mac front-end with MonoMac. The application has a TreeControl with icons and text, which does not exist out of the box in Cocoa. So far, I've ported almost all of the ImageAndTextCell code in Apple's DragNDrop example: https://developer.apple.com/library/mac/#samplecode/DragNDropOutlineView/Listings/ImageAndTextCell_m.html#//apple_ref/doc/uid/DTS40008831-ImageAndTextCell_m-DontLinkElementID_6, which is assigned to an NSOutlineView as a custom cell. It seems to be working almost perfectly, except that I have not figured out how to properly port the copyWithZone method. Unfortunately, this means the internal copies that NSOutlineView is making do not have the image field, and it leads to the images briefly vanishing during expand and collapse operations. The objective-c code in question is: - (id)copyWithZone:(NSZone *)zone { ImageAndTextCell *cell = (ImageAndTextCell *)[super copyWithZone:zone]; // The image ivar will be directly copied; we need to retain or copy it. cell->image = [image retain]; return cell; } The first line is what's tripping me up, as MonoMac does not expose a copyWithZone method, and I don't know how to otherwise call it. Update Based on current answers and additional research and testing, I've come up with a variety of models for copying an object. static List<ImageAndTextCell> _refPool = new List<ImageAndTextCell>(); // Method 1 static IntPtr selRetain = Selector.GetHandle ("retain"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell() { Title = Title, Image = Image, }; Messaging.void_objc_msgSend (cell.Handle, selRetain); return cell; } // Method 2 [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell() { Title = Title, Image = Image, }; _refPool.Add(cell); return cell; } [Export("dealloc")] public void Dealloc () { _refPool.Remove(this); this.Dispose(); } // Method 3 static IntPtr selRetain = Selector.GetHandle ("retain"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell() { Title = Title, Image = Image, }; _refPool.Add(cell); Messaging.void_objc_msgSend (cell.Handle, selRetain); return cell; } // Method 4 static IntPtr selRetain = Selector.GetHandle ("retain"); static IntPtr selRetainCount = Selector.GetHandle("retainCount"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone (IntPtr zone) { ImageAndTextCell cell = new ImageAndTextCell () { Title = Title, Image = Image, }; _refPool.Add (cell); Messaging.void_objc_msgSend (cell.Handle, selRetain); return cell; } public void PeriodicCleanup () { List<ImageAndTextCell> markedForDelete = new List<ImageAndTextCell> (); foreach (ImageAndTextCell cell in _refPool) { uint count = Messaging.UInt32_objc_msgSend (cell.Handle, selRetainCount); if (count == 1) markedForDelete.Add (cell); } foreach (ImageAndTextCell cell in markedForDelete) { _refPool.Remove (cell); cell.Dispose (); } } // Method 5 static IntPtr selCopyWithZone = Selector.GetHandle("copyWithZone:"); [Export("copyWithZone:")] public virtual NSObject CopyWithZone(IntPtr zone) { IntPtr copyHandle = Messaging.IntPtr_objc_msgSendSuper_IntPtr(SuperHandle, selCopyWithZone, zone); ImageAndTextCell cell = new ImageAndTextCell(copyHandle) { Image = Image, }; _refPool.Add(cell); return cell; } Method 1: Increases the retain count of the unmanaged object. The unmanaged object will persist persist forever (I think? dealloc never called), and the managed object will be harvested early. Seems to be lose-lose all-around, but runs in practice. Method 2: Saves a reference of the managed object. The unmanaged object is left alone, and dealloc appears to be invoked at a reasonable time by the caller. At this point the managed object is released and disposed. This seems reasonable, but on the downside the base type's dealloc won't be run (I think?) Method 3: Increases the retain count and saves a reference. Unmanaged and managed objects leak forever. Method 4: Extends Method 3 by adding a cleanup function that is run periodically (e.g. during Init of each new ImageAndTextCell object). The cleanup function checks the retain counts of the stored objects. A retain count of 1 means the caller has released it, so we should as well. Should eliminate leaking in theory. Method 5: Attempt to invoke the copyWithZone method on the base type, and then construct a new ImageAndTextView object with the resulting handle. Seems to do the right thing (the base data is cloned). Internally, NSObject bumps the retain count on objects constructed like this, so we also use the PeriodicCleanup function to release these objects when they're no longer used. Based on the above, I believe Method 5 is the best approach since it should be the only one that results in a truly correct copy of the base type data, but I don't know if the approach is inherently dangerous (I am also making some assumptions about the underlying implementation of NSObject). So far nothing bad has happened "yet", but if anyone is able to vet my analysis then I would be more confident going forward.

    Read the article

  • Objective-C Getter Memory Management

    - by Marian André
    I'm fairly new to Objective-C and am not sure how to correctly deal with memory management in the following scenario: I have a Core Data Entity with a to-many relationship for the key "children". In order to access the children as an array, sorted by the column "position", I wrote the model class this way: @interface AbstractItem : NSManagedObject { NSArray * arrangedChildren; } @property (nonatomic, retain) NSSet * children; @property (nonatomic, retain) NSNumber * position; @property (nonatomic, retain) NSArray * arrangedChildren; @end @implementation AbstractItem @dynamic children; @dynamic position; @synthesize arrangedChildren; - (NSArray*)arrangedChildren { NSArray* unarrangedChildren = [[self.children allObjects] retain]; NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"position" ascending:YES]; [arrangedChildren release]; arrangedChildren = [unarrangedChildren sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]]; [sortDescriptor release]; [unarrangedChildren release]; return [arrangedChildren retain]; } @end I'm not sure whether or not to retain unarrangedChildren and the returned arrangedChildren (first and last line of the arrangedChildren getter). Does the NSSet allObjects method already return a retained array? It's probably too late and I have a coffee overdose. I'd be really thankful if someone could point me in the right direction. I guess I'm missing vital parts of memory management knowledge and I will definitely look into it thoroughly.

    Read the article

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