my error it No visible #interface for 'WHMailActivity' declares the selector 'activityDidFinish:'
I get a one night but I did not succeed. . . Why are so used elsewhere but I can not. . .
Which I hope to help me. . .
Thanks in advance !
this it my .h
#import <Foundation/Foundation.h>
#import <MessageUI/MessageUI.h>
#import "WHMailActivityItem.h"
#interface WHMailActivity : UIViewController
#end
and this it my .m
#import "WHMailActivity.h"
#interface WHMailActivity() <MFMailComposeViewControllerDelegate>
#property (nonatomic, strong)WHMailActivityItem *activityItem;
#end
#implementation WHMailActivity
#pragma mark - UIActivity Overrides
- (NSString *)activityType {
return NSStringFromClass([self class]);
}
- (NSString *)activityTitle {
return NSLocalizedString(#"Mail", #"title for Mail activity item");
}
- (UIImage *)activityImage {
return [UIImage imageNamed:#"mailActivity.png"];
}
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
if (![MFMailComposeViewController canSendMail]) {
return NO;
}
for (id item in activityItems) {
if ([item isKindOfClass:[WHMailActivityItem class]]) {
return YES;
}
}
return NO;
}
- (void)prepareWithActivityItems:(NSArray *)activityItems {
for (id item in activityItems) {
if ([item isKindOfClass:[WHMailActivityItem class]]){
self.activityItem = item;
}
}
}
- (UIViewController *)activityViewController {
MFMailComposeViewController *composeController = [[MFMailComposeViewController alloc] init];
if (self.activityItem.onMailActivitySelected) {
self.activityItem.onMailActivitySelected(composeController);
}
composeController.mailComposeDelegate = self;
return composeController;
[self performSelector:#selector(mailComposeController)];
}
#pragma mark - MFMailComposeViewControllerDelegate
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[self activityDidFinish:result == MFMailComposeResultSent];
}
#end
In your .h file you have:
#interface WHMailActivity : UIViewController
but it should be:
#interface WHMailActivity : UIActivity
assuming the class is a custom UIActivity.
Related
I am not getting Chat Bubble in JSQMessageViewController but not able to get what to method to be add to get chat bubble in my chat page in IOS I am getting only Textbox and send button when I type text and click send not getting bubbles I am new please help me.
// .h File content
// ChatpageViewController.h
// ChatApp
#import <UIKit/UIKit.h>
#import <JSQMessagesViewController/JSQMessages.h>
#import <JSQMessagesViewController.h>
#import "JSQMessagesCollectionViewFlowLayout.h"
#import "JSQMessages.h"
#import "JSQPhotoMediaItem.h"
#import "JSQLocationMediaItem.h"
#import "JSQVideoMediaItem.h"
#import "JSQMessagesMediaViewBubbleImageMasker.h"
#import "JSQMessagesAvatarImage.h"
#import "JSQMessagesAvatarImageFactory.h"
#import "JSQMessagesBubbleImage.h"
#import "JSQMessagesBubbleImageFactory.h"
#import "UIImage+JSQMessages.h"
#interface ChatpageViewController : JSQMessagesViewController<JSQMessagesCollectionViewDataSource,JSQMessagesCollectionViewDelegateFlowLayout,JSQMessagesCollectionViewCellDelegate,JSQMessageData,JSQMessageMediaData,JSQMessageAvatarImageDataSource,JSQMessageBubbleImageDataSource>
#property(nonatomic,strong)NSDictionary * receivedict;
#property (strong, nonatomic) IBOutlet UILabel *name;
#property (strong, nonatomic) IBOutlet UILabel *mobile;
- (IBAction)cancelbtn:(id)sender;
#end
M File starts from here
//
// ChatpageViewController.m
// ChatApp
//
#import "ChatpageViewController.h"
#interface ChatpageViewController ()
{
}
#end
#implementation ChatpageViewController
#synthesize receivedict,name,mobile;
-(void)viewWillAppear:(BOOL)animated
{
self.collectionView.collectionViewLayout.springinessEnabled = YES;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.navigationController setNavigationBarHidden:YES animated:YES];
NSLog(#"%#",receivedict);
name.text = [receivedict objectForKey:#"Name"];
id.text =[receivedict objectForKey:#"Id"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSString *)senderId
{
return [receivedict objectForKey:#"Id"];
}
- (NSString *)senderDisplayName
{
return [receivedict objectForKey:#"Name"];
}
- (NSDate *)date
{
return 18/03/2016;
}
- (void)didPressSendButton:(UIButton *)button withMessageText:(NSString *)text senderId:(NSString *)senderId senderDisplayName:(NSString *)senderDisplayName date:(NSDate *)date
{
[JSQSystemSoundPlayer jsq_playMessageSentSound];
JSQMessage *message = [[JSQMessage alloc] initWithSenderId:senderId
senderDisplayName:senderDisplayName
date:date
text:text];
// [demoData.messages addObject:message];
[self finishSendingMessageAnimated:YES];
NSLog(#"%#",message);
}
- (IBAction)cancelbtn:(id)sender
{
[self.navigationController popViewControllerAnimated:YES];
}
#end
There is lots of problem in your code .. You are not implementing all JSQ methods .. kindly check how to integrate JSQMessageViewController and than for bubbles that is you main question check answer below :-
You have to use JSQMessagesBubbleImage class to get bubbles like ...
in .h file define
#property (strong, nonatomic) JSQMessagesBubbleImage *outgoingBubbleImageData;
#property (strong, nonatomic) JSQMessagesBubbleImage *incomingBubbleImageData;
in .m file in viewDidLoad
JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] init];
self.outgoingBubbleImageData = [bubbleFactory outgoingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleBlueColor]];
self.incomingBubbleImageData = [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]];
than provide JSQMessages CollectionView DataSource
- (id<JSQMessageBubbleImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView messageBubbleImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
JSQMessage *message = [messages objectAtIndex:indexPath.item];
if ([message.senderId isEqualToString:self.senderId]) {
return self.outgoingBubbleImageData;
}
return self.incomingBubbleImageData;
}
I tried after adding the bellow methods in my coding then I have got the bubble with the bellow post other functions - (void)didPressSendButton:(UIButton *)button etc.
- (id<JSQMessageBubbleImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView messageBubbleImageDataForItemAtIndexPath:(NSIndexPath *)indexPath
{
JSQMessage *message = [fularray objectAtIndex:indexPath.item];
if ([message.senderId isEqualToString:self.senderId]) {
return self.outgoingBubbleImageData;
}
return self.incomingBubbleImageData;
}
- (id<JSQMessageAvatarImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView avatarImageDataForItemAtIndexPath:(NSIndexPath *)indexPath {
return [JSQMessagesAvatarImageFactory avatarImageWithUserInitials:#"JL" backgroundColor:[UIColor blueColor] textColor:[UIColor whiteColor] font:[UIFont systemFontOfSize:12.0] diameter:30.0];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [fularray count];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (id<JSQMessageData>)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath {
return fularray[indexPath.row];
}
I have integrated the ZXingObjc framework,and ViewController as the RootViewController.
the codes in ViewController.m follows:
#import <AudioToolbox/AudioToolbox.h>
#import "ViewController.h"
#interface ViewController ()
#property (nonatomic, strong) ZXCapture *capture;
#property (nonatomic, weak) IBOutlet UIView *scanRectView;
#property (nonatomic, weak) IBOutlet UILabel *decodedLabel;
#end
#implementation ViewController
#pragma mark - View Controller Methods
- (void)dealloc {
[self.capture.layer removeFromSuperlayer];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.capture = [[ZXCapture alloc] init];
self.capture.camera = self.capture.back;
self.capture.focusMode = AVCaptureFocusModeContinuousAutoFocus;
self.capture.rotation = 90.0f;
self.capture.layer.frame = self.view.bounds;
[self.view.layer addSublayer:self.capture.layer];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.capture.delegate = self;
self.capture.layer.frame = self.view.bounds;
self.capture.scanRect = self.scanRectView.frame;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return toInterfaceOrientation == UIInterfaceOrientationPortrait;
}
#pragma mark - Private Methods
- (NSString *)barcodeFormatToString:(ZXBarcodeFormat)format {
switch (format) {
case kBarcodeFormatAztec:
return #"Aztec";
case kBarcodeFormatCodabar:
return #"CODABAR";
case kBarcodeFormatCode39:
return #"Code 39";
case kBarcodeFormatCode93:
return #"Code 93";
case kBarcodeFormatCode128:
return #"Code 128";
case kBarcodeFormatDataMatrix:
return #"Data Matrix";
case kBarcodeFormatEan8:
return #"EAN-8";
case kBarcodeFormatEan13:
return #"EAN-13";
case kBarcodeFormatITF:
return #"ITF";
case kBarcodeFormatPDF417:
return #"PDF417";
case kBarcodeFormatQRCode:
return #"QR Code";
case kBarcodeFormatRSS14:
return #"RSS 14";
case kBarcodeFormatRSSExpanded:
return #"RSS Expanded";
case kBarcodeFormatUPCA:
return #"UPCA";
case kBarcodeFormatUPCE:
return #"UPCE";
case kBarcodeFormatUPCEANExtension:
return #"UPC/EAN extension";
default:
return #"Unknown";
}
}
#pragma mark - ZXCaptureDelegate Methods
- (void)captureCameraIsReady:(ZXCapture *)capture
{
NSLog(#"%s,%d",__FUNCTION__,__LINE__);
}
- (void)captureResult:(ZXCapture *)capture result:(ZXResult *)result {
if (!result) return;
NSLog(#"%s,%d",__FUNCTION__,__LINE__);
// We got a result. Display information about the result onscreen.
NSString *formatString = [self barcodeFormatToString:result.barcodeFormat];
NSString *display = [NSString stringWithFormat:#"Scanned!\n\nFormat: %#\n\nContents:\n%#", formatString, result.text];
[self.decodedLabel performSelectorOnMainThread:#selector(setText:) withObject:display waitUntilDone:YES];
// Vibrate
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
[self.capture stop];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self.capture start];
});
}
#end
I found that the mothod - (void)captureResult:(ZXCapture *)capture result:(ZXResult *)result doesn't work at all.
Next,the same codes i put it into the example of ZXingObjc,it works well.
I really don't know what's wrong with me.
Wish your help!
I had the same problem. In my situation, the view controller would launch, but would never detect a barcode. Turns out I needed to add '-ObjC' to 'Other Linker Flags'.
Reference: https://developer.apple.com/library/ios/technotes/iOSStaticLibraries/Articles/configuration.html
Did your Viewcontroller.h file adopt the ZXCapture protocol? Something like this:
//ViewController.h
#interface ViewController: NSObject <ZXCaptureDelegate> //<---- this guy
- (void)yourFunction;
- (void)anotherFunction;
#end
(I'm not sure what is its real name)
So perhaps this is a beginner's mistake and super easy to you guys, but i really do not know how to solve it,really appreciate for any suggestions:
Right Now:
1: I have to ViewController: EnterCommandViewController and DetectionViewController
2: I wrote Delegate protocol in EnterCommandViewController and set DetectionViewController as its delegate.
3: About delegate: I have a inputTextField in the EnterCommandView and a "Save" bar button item on the top toolbar in this view. Once I click the save , current view will be dismissed and return back to DetectionView and show the NSString just entered in the UILabel in DetectionView.
Finally, My question is that Why After I alloc and init a EnterCommandViewController instance , that is enterCVS, the instance is still nil as show in end of my post.
Code:
EnterCommandViewController.h
#import <UIKit/UIKit.h>
#import "RscMgr.h"
#protocol EnterCommandDelegate <NSObject>
#optional
-(void) commandEntered:(NSString*)command;
#end
#interface EnterCommandViewController : UIViewController <RscMgrDelegate,EnterCommandDelegate>
{
RscMgr* rscMgr;
IBOutlet UITextField *inputTextField;
// DetectionViewController* detectionViewController;
// __unsafe_unretained id<EnterCommandDelegate> delegate;
}
-(void)sendMessage:(NSString*)message;
-(id)initWithDelegate:(id)delegateToBe;
- (IBAction)cancelPressed;
- (IBAction)savePressed;
#property (nonatomic,weak) id<EnterCommandDelegate> delegate; //assign replaced
#end
EnterCommandVIewController.m
#import "EnterCommandViewController.h"
#import "DetectionViewController.h"
#interface EnterCommandViewController () <UITextFieldDelegate>
{
#private
BOOL connected;
}
#end
#implementation EnterCommandViewController
#synthesize delegate;
- (void)viewDidLoad {
[super viewDidLoad];
rscMgr = [[RscMgr alloc] init];
[rscMgr setDelegate:self];
// Do any additional setup after loading the view, typically from a nib.
[inputTextField becomeFirstResponder];
}
-(id)initWithDelegate:(id)delegateToBe{
if(self = [super init]){
delegate = delegateToBe;
}
return self;
}
-(void) viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
inputTextField.delegate = self;
}
-(void) viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
inputTextField.delegate = nil;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITextFieldDelegate Methods
-(BOOL) textFieldShouldReturn:(UITextField *)textField{
[self sendMessage:textField.text];
textField.text = nil;
return NO;
}
#pragma mark - Serial Tx/Rx Methods Implementation
-(void) sendMessage:(NSString *)message{
if(connected == YES) {
[rscMgr writeString:message];
}
else{
NSLog(#"CableDisconnected!");
NSLog(#"Attempted To Send: %#",message);
}
}
- (IBAction)cancelPressed {
[self dismissViewControllerAnimated:YES completion:^{}];
}
- (IBAction)savePressed {
//is anyone listening
if([[[UIDevice currentDevice]systemVersion] compare:#"7.0" options:NSNumericSearch] != NSOrderedAscending){
NSLog(#"SYStem version > 7.0");
}
if(delegate&&[delegate respondsToSelector:#selector(commandEntered:)]){
NSLog(#"SomeMethod is listening");
[delegate commandEntered:inputTextField.text];
}
[self dismissViewControllerAnimated:YES completion:nil]; //commened: ^{}
}
#pragma mark - RscMgrDelegate Methods Implementation
-(void) cableConnected:(NSString *)protocol{
inputTextField.text = #"cableConnected";
[rscMgr setBaud:9600];
[rscMgr open];
connected = YES;
}
-(void) cableDisconnected{
inputTextField.text = #"cableDisconnected";
connected = NO;
}
-(void) readBytesAvailable:(UInt32)length{}
-(void) portStatusChanged{}
#end
DetectionViewController.h
#import <UIKit/UIKit.h>
#import "EnterCommandViewController.h"
#interface DetectionViewController : UIViewController <EnterCommandDelegate>{
}
- (IBAction)showSettings:(UIBarButtonItem *)sender;
#property (nonatomic, strong) EnterCommandViewController* enterCVC;
#property (nonatomic, strong) IBOutlet UILabel *showReceivedCommand;
#end
DetectionViewController.m
#import <Foundation/Foundation.h>
#import "DetectionViewController.h"
#import "EnterCommandViewController.h"
#implementation DetectionViewController
#synthesize showReceivedCommand;
#synthesize enterCVC;
- (IBAction)showSettings:(UIBarButtonItem *)sender {
}
-(void) viewDidLoad{
[super viewDidLoad];
if(showReceivedCommand){
showReceivedCommand.text=#"Initial text";
NSLog(#"UILAbel in ViewDidload is not nil");
}else {
NSLog(#"UILAbel in viewDidload is nil");
}
enterCVC = [[EnterCommandViewController alloc] init];
if(enterCVC.delegate) NSLog(#"X nil");
[enterCVC setDelegate:self];
}
#pragma mark - EnterCommandDelegate function(s)
-(void)commandEntered:(NSString *)command{
dispatch_async(dispatch_get_main_queue(), ^{
if(showReceivedCommand){
NSLog(#"UILabel is not nil");
}else{NSLog(#"UILabel is nil");}
showReceivedCommand = [[UILabel alloc] init];
NSLog(#"command received: %#",command);
showReceivedCommand.text = command;
[showReceivedCommand setNeedsDisplay];
NSLog(#"text in showReceivedCommand is %#",showReceivedCommand.text);
});
}
#end
I set a break point at DetectionViewController.n --> ViewDidLoad() --> [enterCVC setDelegate:self];
I got:
self DetectionViewController * 0x15c50e850 0x000000015c50e850
UIViewController UIViewController
showReceivedCommand UILabel * 0x15c510650 0x000000015c510650
enterCVC EnterCommandViewController * 0x15c611360 0x000000015c611360
showReceivedCommand UILabel * 0x15c510650 0x000000015c510650
enterCVC EnterCommandViewController * 0x15c611360 0x000000015c611360
UIViewController UIViewController
rscMgr RscMgr * nil 0x0000000000000000
inputTextField UITextField * nil 0x0000000000000000
connected BOOL NO false
delegate id 0x0 0x0000000000000000
enterCVC = [[EnterCommandViewController alloc] init]
Try changing that to....
enterCVC = [[EnterCommandViewController alloc] initWithDelegate:self];
I created a subclass of UITextView to add a custom UIMenuItem. The problem is that when I press my custom action to display custom item, the text is not highlighted. Any idea?
ActionsTextView.h
#import <UIKit/UIKit.h>
#protocol ActionsDelegate <NSObject>
- (void)addDreamSignalWithText:(NSString *)text range:(NSRange)range;
#end
#interface ActionsTextView : UITextView
#pragma mark - Delegate
#property IBOutlet id<ActionsDelegate>actionsDelegate;
#pragma mark - Methods
- (void)addDreamSignalAction:(id)sender;
#end
ActionsTextView.m
#import "ActionsTextView.h"
#implementation ActionsTextView
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == #selector(addDreamSignalAction:)) {
return YES;
}
return NO;
}
#pragma mark - Methods
- (void)addDreamSignalAction:(id)sender {
if ([_actionsDelegate respondsToSelector:#selector(addDreamSignalWithText:range:)]) {
[_actionsDelegate addDreamSignalWithText:[self.text substringWithRange:self.selectedRange]
range:self.selectedRange];
}
// Deselect text
self.selectedTextRange = nil;
}
#end
Thanks!!
Thanks to rmaddy, I found the solution.
Here is the code:
ActionsTextView.h
#import <UIKit/UIKit.h>
#protocol ActionsDelegate <NSObject>
- (void)addDreamSignalWithText:(NSString *)text range:(NSRange)range;
#end
#interface ActionsTextView : UITextView
#pragma mark - Delegate
#property IBOutlet id<ActionsDelegate>actionsDelegate;
#pragma mark - Methods
- (void)addDreamSignalAction:(id)sender;
#pragma mark - Notifications
- (void)menuControllerWillShow:(NSNotification *)notification;
#end
ActionsTextView.m
#import "ActionsTextView.h"
#implementation ActionsTextView
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
if (action == #selector(addDreamSignalAction:)) {
return YES;
}
return NO;
}
#pragma mark - Methods
- (void)addDreamSignalAction:(id)sender {
if ([_actionsDelegate respondsToSelector:#selector(addDreamSignalWithText:range:)]) {
[_actionsDelegate addDreamSignalWithText:[self.text substringWithRange:self.selectedRange]
range:self.selectedRange];
}
// Deselect text
self.selectedTextRange = nil;
}
#pragma mark - Notifications
- (void)menuControllerWillShow:(NSNotification *)notification {
if (self.selectedRange.length == 0) {
[self select:self];
}
}
#end
I want to display a list of peoples in an UITableView (I write the name in the ViewController and display them as a list in the UITableViewController).
I just need to stock up the data. But my code add just one object in the NSMutableArray.
Is it because I use a singleton in my class "Customers"?
This is my code so far:
Customers.h
#import <Foundation/Foundation.h>
#interface Customers : NSObject
{
NSString *name;
float age;
}
- (id)initWithName:(NSString *)aname age:(float)aage ;
- (NSString*) name;
- (float) age;
- (void) setName:(NSString*) newName;
- (void) setAge:(float) newAge;
+(Customers*)instance;
#end
Customers.m
#import "Customers.h"
#implementation Customers
- (id)initWithName:(NSString *)aname age:(float)aage {
if ((self = [super init]))
{
self.name = aname;
age = aage;
}
return self;
}
- (NSString*) name{
return name;
}
- (float) age{
return age;
}
- (void) setName:(NSString*) newName
{
name = newName;
}
- (void) setAge:(float) newAge{
age = newAge;
}
+(Customers*)instance{
static dispatch_once_t once;
static Customers *sharedInstance;
dispatch_once(&once, ^{
sharedInstance = [[self alloc] initWithName:#"jean" age:24];
});
return sharedInstance;
}
#end
ViewController.h
#import <UIKit/UIKit.h>
#class Customers;
#interface ViewController : UIViewController
#property (strong, nonatomic) IBOutlet UITextField *nameLabel;
#property (strong, nonatomic) IBOutlet UITextField *ageLabel;
- (IBAction)goToTableView:(id)sender;
#end
ViewController.m
#import "ViewController.h"
#import "Customers.h"
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)goToTableView:(id)sender {
[[Customers instance] setName:_nameLabel.text];
}
#end
TableViewController.h
#import <UIKit/UIKit.h>
#class Customers;
#interface TableViewController : UITableViewController
{
NSMutableArray *peopleListe;
}
#end
TableViewController.m
#import "TableViewController.h"
#import "Customers.h"
#interface TableViewController ()
#end
#implementation TableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
Customers *koko = [[Customers alloc ] initWithName:[[Customers instance]name] age:[[Customers instance]age]];
peopleListe = [NSMutableArray arrayWithObjects: nil];
[peopleListe addObject: koko];
NSLog(#"%#",peopleListe);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return peopleListe.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:#"MyBasicCell"];
Customers *list = [peopleListe objectAtIndex:indexPath.row];
cell.textLabel.text = list.name;
return cell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
// Return NO if you do not want the specified item to be editable.
return NO;
}
#end
Thank you for your help in advance.
According to your comment, you want to add an object every time the controller gets loaded.
- (void)viewDidLoad {
[super viewDidLoad];
Customers *koko = [[Customers alloc ] initWithName:[[Customers instance] name]
age:[[Customers instance] age]];
peopleListe = [NSMutableArray arrayWithObjects: nil];
[peopleListe addObject: koko];
NSLog(#"%#",peopleListe);
}
I see multiple problems with this:
I'm not sure viewDidLoad is the correct method to embed this in, i don't think it is guaranteed to get called if the view is already in memory. (I don't have any ios experience, so I'm not sure.) It might even be that your controller gets removed and created from scratch every time you use it.
You replace your whole list when you allocate peopleList. You should check for its existence and only allocate it if it does not exist yet. (Obj-C initializes instance variables as nil, so a simple check is enough.)
Apart from that, you seem to mix controller and model code. If you have the time you should look into moving the array into the model and out of the controller code.